DecodeMarketing FloWeinert Claude Opus 4.7 (1M context) commited on
Commit
93ccd43
·
unverified ·
1 Parent(s): a38680e

Deploy: ruff lint cleanup (green language-gate) (#21)

Browse files

* ci: add CODEOWNERS for restructure

* docs: add github-security-posture per decode-ai-standards

* Refresh CODEOWNERS + posture doc to match current branch-protection model (#6)

* Refresh .github/CODEOWNERS to match current branch-protection model

* Refresh docs/github-security-posture.md to match current branch-protection model

* [ai-standards][slice-2] structure and dependency reproducibility (#8)

* [ai-standards][slice-1] orientation and deploy boundary (#7)

Adds docs-only governance artifacts per the shrunken slice-1 plan
(post hardening commits 1878a50..c7599a7). No changes to app code,
requirements, devcontainer, .streamlit, existing workflows, existing
.claude/.githooks, or CLAUDE.md. README.md changes are additive only.

Artifacts:
- AGENTS.md (thin entrypoint -> CLAUDE.md + docs/INDEX.md)
- SECURITY.md (HF_TOKEN handling, deploy boundary)
- docs/ (INDEX, architecture, reference, guides, progress)
- .github/pull_request_template.md (deploy-boundary checklist)
- scripts/repo_validate.py (py_compile sweep + requirements parse)
- .github/workflows/repo_validate.yml (PR-only, parallel to gate.yml)
- README.md: additive Verification + Branch & Deploy + Architecture sections

Refs decode-ai-standards@81c3f17.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [ai-standards][slice-2] structure and dependency reproducibility

Adds dependency reproducibility artifacts and policy/runbook documentation
per the shrunken slice-2 plan (workflow hardening deferred to a later slice
on user instruction to keep deploy risk at zero for this slice).

Artifacts:
- pyproject.toml (PEP 621 metadata; no [project.dependencies] to avoid
drift; requirements.txt remains the source of truth consumed by HF Spaces)
- requirements.lock (47 packages, autogenerated by
`uv pip compile --python-version=3.12 requirements.txt`)
- .python-version (3.12; matches runtime.txt and HF Spaces)
- .env.example (comment-only; declares no local env vars; documents
HF_TOKEN as a GitHub Actions secret consumed only by main.yml)
- docs/policies/naming-conventions.md (tab<N>.py rule, helper.py role,
what we explicitly do NOT do)
- docs/policies/root-artifact-policy.md (what is tracked at root, what is
gitignored, what is tolerated locally)
- docs/runbooks/local-setup.md (Windows / macOS / Linux setup walkthrough,
troubleshooting table)
- docs/INDEX.md (link the three new docs under new ## policies and
## runbooks sections; remove their entries from the "planned" stub)

Out of scope (deferred):
- Workflow SHA pinning + permissions blocks on main.yml, gate.yml,
check-file-size.yml — deferred to a later slice because main.yml is the
HF deploy pipeline and deserves its own focused PR + verification cycle
- .gitignore additions for .ruff_cache/, .venv/, .pytest_cache/ — deferred

No changes to app code (app.py, helper.py, tab1.py-tab8.py), requirements.txt,
runtime.txt, .streamlit/, .devcontainer/, existing workflows, existing
.githooks/, existing .claude/, CLAUDE.md, or .gitignore. HF Spaces deploy
is a no-op for this slice because no runtime file is touched.

Refs decode-ai-standards@81c3f17.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(tab5): carry lowercase sub-block letter into stim labels and reports

Block folders briefed as <NN><lowercase-letter><Category> (e.g. 05cColours)
encode a sub-block. The previous logic stripped every non-digit from the
folder name, dropping the letter, so stims were labelled 01B05whisper... instead
of 01B05cwhisper... A new parse_block() helper extracts the block number and the
optional single lowercase letter (uppercase = start of category name, so 05Colours
has no letter). Applied at every block-ID construction site used by the
'Name stims by block' tool (tab5) and the Asset Overview PDF (tab4).

tab6 (Rerun Matrix): rebuild the brand index from the Excel 'factor' column and
the leading brand number instead of regex-parsing the brand out of the ID, since
the optional sub-block letter makes ID-based brand parsing ambiguous.

tab5 instructions updated to document the lowercase-letter naming convention.

* fix(app): swap Resize / Place on Canvas tab handlers to match labels

The 'Resize' tab (tab7) was calling center_on_canvas_tool() and the
'Place on Canvas' tab (tab8) was calling resize_with_transparent_canvas_tool().
Swap the two calls so each tab runs the tool its label names, matching the
documented tool order (7 = Resize, 8 = Place on Canvas).

* chore: fix ruff lint errors in app/helper/tab5/tab6 (green language-gate)

Resolve the ruff findings the DECODE language-gate flags on these files:
remove unused imports and locals, replace bare 'except:' with 'except Exception:',
drop unused 'as e' bindings, and remove f-prefixes from placeholder-less strings.
No behavior change; verified with py_compile and an end-to-end process_files run.

---------

Co-authored-by: FloWeinert <weinert@decodemarketing.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (3) hide show
  1. helper.py +5 -6
  2. tab5.py +1 -3
  3. tab6.py +3 -9
helper.py CHANGED
@@ -81,7 +81,7 @@ def extract_images_from_xlsx_zip_method(xlsx_path, output_dir, target_sheet=None
81
  content = f.read().decode('utf-8')
82
  sheet_matches = re.findall(r'<sheet name="([^"]+)"', content)
83
  available_sheets = [match for match in sheet_matches]
84
- except:
85
  available_sheets = ["Sheet1"]
86
 
87
  # Find all media files
@@ -116,7 +116,7 @@ def extract_images_from_xlsx_zip_method(xlsx_path, output_dir, target_sheet=None
116
 
117
  warning_msg = None
118
  if target_sheet and target_sheet != "All worksheets":
119
- warning_msg = f"Note: Extracted all images from file. Sheet-specific extraction not fully supported with this method."
120
 
121
  return image_count, extracted_files, warning_msg, available_sheets
122
 
@@ -125,7 +125,6 @@ def extract_images_from_xlsx_zip_method(xlsx_path, output_dir, target_sheet=None
125
 
126
  def process_files(input_folder, marken_index, output_root):
127
  """Process and rename files according to brand numbering with sequential counting per brand/block"""
128
- dateien = []
129
  renamed_files_by_folder_and_marke = defaultdict(lambda: defaultdict(list))
130
  file_to_factorgroup = {}
131
 
@@ -622,7 +621,7 @@ def extract_images_from_xlsx_by_sheet(xlsx_path, output_dir, target_sheet=None):
622
 
623
  return image_count, extracted_files, None, available_sheets
624
 
625
- except Exception as e:
626
  return extract_images_from_xlsx_zip_method(xlsx_path, output_dir, target_sheet)
627
 
628
  def extract_images_from_xlsx(xlsx_file, output_dir):
@@ -757,7 +756,7 @@ def get_asset_cell(file_path, filename, col_count):
757
  return frame
758
  else:
759
  return Paragraph(f"{filename}", styles['Normal'])
760
- except Exception as e:
761
  return Paragraph(f"[Image Error]<br/>{filename}", styles['Normal'])
762
 
763
 
@@ -796,7 +795,7 @@ def build_marken_einzelseiten(alle_dateien_pro_marke, styles, gesamtbreite):
796
 
797
  img = RLImage(file_path, width=new_width, height=new_height)
798
  cell = [img, Spacer(1, 4), Paragraph(filename, styles['Normal'])]
799
- except Exception as e:
800
  cell = Paragraph(f"{filename} (Error loading image)", styles['Normal'])
801
  else:
802
  cell = Paragraph(f"{filename}", styles['Normal'])
 
81
  content = f.read().decode('utf-8')
82
  sheet_matches = re.findall(r'<sheet name="([^"]+)"', content)
83
  available_sheets = [match for match in sheet_matches]
84
+ except Exception:
85
  available_sheets = ["Sheet1"]
86
 
87
  # Find all media files
 
116
 
117
  warning_msg = None
118
  if target_sheet and target_sheet != "All worksheets":
119
+ warning_msg = "Note: Extracted all images from file. Sheet-specific extraction not fully supported with this method."
120
 
121
  return image_count, extracted_files, warning_msg, available_sheets
122
 
 
125
 
126
  def process_files(input_folder, marken_index, output_root):
127
  """Process and rename files according to brand numbering with sequential counting per brand/block"""
 
128
  renamed_files_by_folder_and_marke = defaultdict(lambda: defaultdict(list))
129
  file_to_factorgroup = {}
130
 
 
621
 
622
  return image_count, extracted_files, None, available_sheets
623
 
624
+ except Exception:
625
  return extract_images_from_xlsx_zip_method(xlsx_path, output_dir, target_sheet)
626
 
627
  def extract_images_from_xlsx(xlsx_file, output_dir):
 
756
  return frame
757
  else:
758
  return Paragraph(f"{filename}", styles['Normal'])
759
+ except Exception:
760
  return Paragraph(f"[Image Error]<br/>{filename}", styles['Normal'])
761
 
762
 
 
795
 
796
  img = RLImage(file_path, width=new_width, height=new_height)
797
  cell = [img, Spacer(1, 4), Paragraph(filename, styles['Normal'])]
798
+ except Exception:
799
  cell = Paragraph(f"{filename} (Error loading image)", styles['Normal'])
800
  else:
801
  cell = Paragraph(f"{filename}", styles['Normal'])
tab5.py CHANGED
@@ -4,8 +4,6 @@ import shutil
4
  import zipfile
5
  from pathlib import Path
6
  import streamlit as st
7
- from reportlab.lib.pagesizes import A4
8
- from reportlab.lib.styles import getSampleStyleSheet
9
  from helper import extract_zip_to_temp, analyze_files_by_filename, generate_filename_based_pdf_report_with_extensions, process_files, generate_excel_report
10
 
11
 
@@ -260,7 +258,7 @@ def brand_renamer_tool():
260
  file_name="Brand_Assets_Overview.xlsx",
261
  mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
262
  )
263
- except:
264
  st.info("Excel report not available")
265
 
266
  with col3:
 
4
  import zipfile
5
  from pathlib import Path
6
  import streamlit as st
 
 
7
  from helper import extract_zip_to_temp, analyze_files_by_filename, generate_filename_based_pdf_report_with_extensions, process_files, generate_excel_report
8
 
9
 
 
258
  file_name="Brand_Assets_Overview.xlsx",
259
  mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
260
  )
261
+ except Exception:
262
  st.info("Excel report not available")
263
 
264
  with col3:
tab6.py CHANGED
@@ -1,4 +1,3 @@
1
- import os
2
  import re
3
  import shutil
4
  import zipfile
@@ -15,9 +14,7 @@ from helper import (
15
  ALLOWED_VIDEO_EXTENSIONS,
16
  ALLOWED_AUDIO_EXTENSIONS,
17
  ALLOWED_TEXT_EXTENSIONS,
18
- NON_IMAGE_EXTENSIONS,
19
- get_cleaned_filename_without_brand,
20
- extract_brand
21
  )
22
 
23
 
@@ -183,7 +180,6 @@ def analyze_processed_files(processed_files: List[Path], metadata: Dict, png_to_
183
  Analyze all processed files and organize them using the EXACT same structure as helper.py
184
  Returns: renamed_files_by_folder_and_marke, file_to_factorgroup
185
  """
186
- from helper import extract_brand, get_cleaned_filename_without_brand
187
 
188
  renamed_files_by_folder_and_marke = defaultdict(lambda: defaultdict(list))
189
  file_to_factorgroup = {}
@@ -198,7 +194,6 @@ def analyze_processed_files(processed_files: List[Path], metadata: Dict, png_to_
198
 
199
  filename = file_path.name
200
  name = file_path.stem
201
- file_ext = file_path.suffix.lower()
202
 
203
  # Parse filename to extract metadata: 01B11brandname01description.ext
204
  match = re.match(r"(\d{2})B(\d{2})([a-z0-9]+)", name, re.IGNORECASE)
@@ -248,7 +243,6 @@ def generate_updated_pdf_using_helper(renamed_files_by_folder_and_marke: Dict, m
248
  from reportlab.lib.styles import getSampleStyleSheet
249
  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak
250
  from reportlab.lib import colors
251
- from reportlab.platypus import Image as RLImage
252
  from pathlib import Path
253
 
254
  doc = SimpleDocTemplate(str(output_path), pagesize=A4, leftMargin=20, rightMargin=20,
@@ -631,7 +625,7 @@ def updated_file_processor_tab():
631
  for folder in sorted(metadata['folder_names']):
632
  st.text(f" • {folder}")
633
 
634
- st.write(f"\n**Brand index:**")
635
  for brand, num in sorted(metadata['marken_index'].items()):
636
  st.text(f" • {num}: {brand}")
637
 
@@ -646,7 +640,7 @@ def updated_file_processor_tab():
646
  if 'temp_dir' in st.session_state.tab6_data:
647
  try:
648
  shutil.rmtree(st.session_state.tab6_data['temp_dir'])
649
- except:
650
  pass
651
  st.session_state.tab6_processing_complete = False
652
  st.session_state.tab6_data = {}
 
 
1
  import re
2
  import shutil
3
  import zipfile
 
14
  ALLOWED_VIDEO_EXTENSIONS,
15
  ALLOWED_AUDIO_EXTENSIONS,
16
  ALLOWED_TEXT_EXTENSIONS,
17
+ NON_IMAGE_EXTENSIONS
 
 
18
  )
19
 
20
 
 
180
  Analyze all processed files and organize them using the EXACT same structure as helper.py
181
  Returns: renamed_files_by_folder_and_marke, file_to_factorgroup
182
  """
 
183
 
184
  renamed_files_by_folder_and_marke = defaultdict(lambda: defaultdict(list))
185
  file_to_factorgroup = {}
 
194
 
195
  filename = file_path.name
196
  name = file_path.stem
 
197
 
198
  # Parse filename to extract metadata: 01B11brandname01description.ext
199
  match = re.match(r"(\d{2})B(\d{2})([a-z0-9]+)", name, re.IGNORECASE)
 
243
  from reportlab.lib.styles import getSampleStyleSheet
244
  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak
245
  from reportlab.lib import colors
 
246
  from pathlib import Path
247
 
248
  doc = SimpleDocTemplate(str(output_path), pagesize=A4, leftMargin=20, rightMargin=20,
 
625
  for folder in sorted(metadata['folder_names']):
626
  st.text(f" • {folder}")
627
 
628
+ st.write("\n**Brand index:**")
629
  for brand, num in sorted(metadata['marken_index'].items()):
630
  st.text(f" • {num}: {brand}")
631
 
 
640
  if 'temp_dir' in st.session_state.tab6_data:
641
  try:
642
  shutil.rmtree(st.session_state.tab6_data['temp_dir'])
643
+ except Exception:
644
  pass
645
  st.session_state.tab6_processing_complete = False
646
  st.session_state.tab6_data = {}