Skip to content

Commit 44bf6f3

Browse files
committed
lint
1 parent e7314a9 commit 44bf6f3

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

sql/util/generate_chart_markup.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import re
22
import os
3-
import sys
43
from googleapiclient.discovery import build
54
import google.auth
65

76
# Configuration
87
SPREADSHEET_ID = '1Svyw40Th7VbigX6lpR1lb1WXwTUVKZWrK7O2YELrml4'
98
PUBCHART_ID = '2PACX-1vRC5wrzy5NEsWNHn9w38RLsMURRScnP4jgjO1mDiVhsfFCY55tujlTUZhUaEWzmPtJza0QA7w8S4uK5'
10-
SQL_DIR = '../2025/privacy' # Relative to this script's location
9+
SQL_DIR = '../2025/privacy' # Relative to this script's location
1110

1211
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
1312

13+
1414
def get_sql_to_sheet_map(sql_dir):
1515
mapping = {}
1616
if not os.path.exists(sql_dir):
@@ -24,6 +24,7 @@ def get_sql_to_sheet_map(sql_dir):
2424
mapping[sheet_name] = filename
2525
return mapping
2626

27+
2728
def generate_figure_markup(spreadsheet_id, sql_dir):
2829
try:
2930
credentials, project = google.auth.default(scopes=SCOPES)
@@ -41,7 +42,7 @@ def generate_figure_markup(spreadsheet_id, sql_dir):
4142
sheet_name = sheet['properties']['title']
4243
sheet_id = sheet['properties']['sheetId']
4344
charts = sheet.get('charts', [])
44-
45+
4546
sql_file = sql_map.get(sheet_name)
4647
if not sql_file:
4748
# Try to match case-insensitively or show warning
@@ -50,10 +51,10 @@ def generate_figure_markup(spreadsheet_id, sql_dir):
5051
for chart in charts:
5152
title = chart['spec'].get('title', 'Untitled Chart')
5253
chart_id = chart['chartId']
53-
54+
5455
# Slugify for image name
5556
image_name = re.sub(r'[^a-z0-9]+', '-', title.lower()).strip('-') + ".png"
56-
57+
5758
# Construct markup
5859
markup = f"""{{{{ figure_markup(
5960
image="{image_name}",
@@ -67,12 +68,13 @@ def generate_figure_markup(spreadsheet_id, sql_dir):
6768
print(markup)
6869
print()
6970

71+
7072
if __name__ == "__main__":
7173
# Resolve relative SQL_DIR based on script location
7274
script_dir = os.path.dirname(os.path.abspath(__file__))
7375
absolute_sql_dir = os.path.normpath(os.path.join(script_dir, SQL_DIR))
74-
76+
7577
print(f"Processing Spreadsheet: {SPREADSHEET_ID}")
7678
print(f"SQL Directory: {absolute_sql_dir}\n")
77-
79+
7880
generate_figure_markup(SPREADSHEET_ID, absolute_sql_dir)

sql/util/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pandas==2.3.3
22
google-cloud-bigquery==3.40.0
33
google-api-python-client==2.188.0
4+
google-auth==2.47.0
45
requests==2.32.5
56
tabulate==0.9.0
67
gspread==6.2.1

0 commit comments

Comments
 (0)