Skip to content

Commit 42b3d0d

Browse files
committed
use shared.path_join
1 parent 32f1439 commit 42b3d0d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

dev/create_gcs_query_plan.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def sort_tools(url):
116116

117117
def get_tool_urls():
118118
LOGGER.info("Loading CC Legal Tool paths and adding prefix")
119-
file_path = os.path.join(PATHS["data"], "legal-tool-paths.txt")
119+
file_path = shared.path_join(PATHS["data"], "legal-tool-paths.txt")
120120
prefix = "//creativecommons.org/"
121121
tool_urls = []
122122
with open(file_path, "r") as file_obj:
@@ -128,14 +128,14 @@ def get_tool_urls():
128128

129129

130130
def load_countries():
131-
file_path = os.path.join(PATHS["data"], "gcs_country_collection.yaml")
131+
file_path = shared.path_join(PATHS["data"], "gcs_country_collection.yaml")
132132
with open(file_path, "r") as file_obj:
133133
countries = yaml.safe_load(file_obj)
134134
return countries
135135

136136

137137
def load_languages():
138-
file_path = os.path.join(PATHS["data"], "gcs_language_collection.yaml")
138+
file_path = shared.path_join(PATHS["data"], "gcs_language_collection.yaml")
139139
with open(file_path, "r") as file_obj:
140140
languages = yaml.safe_load(file_obj)
141141
return languages
@@ -202,7 +202,7 @@ def create_query_plan(tool_urls, countries, languages):
202202

203203
def save_plan(plan):
204204
LOGGER.info("Saving Google query plan to CSV")
205-
file_path = os.path.join(PATHS["data"], "gcs_query_plan.csv")
205+
file_path = shared.path_join(PATHS["data"], "gcs_query_plan.csv")
206206
fieldnames = [
207207
"TOOL_URL",
208208
"TOOL_IDENTIFIER",

dev/prioritize_tools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
def get_tool_urls():
4141
LOGGER.info("Loading CC Legal Tool paths and adding prefix")
42-
file_path = os.path.join(PATHS["data"], "legal-tool-paths.txt")
42+
file_path = shared.path_join(PATHS["data"], "legal-tool-paths.txt")
4343
prefix = "//creativecommons.org/"
4444
tool_urls = []
4545
with open(file_path, "r") as file_obj:
@@ -110,7 +110,7 @@ def sort_tools(path):
110110

111111
def save_tools_list(tool_urls):
112112
LOGGER.info("Saving prioritized CC Legal Tool URLs")
113-
file_path = os.path.join(PATHS["data"], "prioritized-tool-urls.txt")
113+
file_path = shared.path_join(PATHS["data"], "prioritized-tool-urls.txt")
114114
tool_urls.append("") # ensure file has end of file newline
115115
with open(file_path, "w") as file_obj:
116116
file_obj.writelines("\n".join(tool_urls))

scripts/1-fetch/gcs_fetch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_last_completed_plan_index():
143143

144144
def load_plan():
145145
plan = []
146-
file_path = os.path.join(PATHS["data"], "gcs_query_plan.csv")
146+
file_path = shared.path_join(PATHS["data"], "gcs_query_plan.csv")
147147
with open(file_path, "r", newline="") as file_obj:
148148
plan = list(csv.DictReader(file_obj, dialect="unix"))
149149
return plan

scripts/shared.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ def setup(current_file):
3232
# Paths
3333
paths = {}
3434
paths["repo"] = os.path.dirname(path_join(__file__, ".."))
35-
paths["dotenv"] = os.path.join(paths["repo"], ".env")
35+
paths["dotenv"] = path_join(paths["repo"], ".env")
3636
paths["data"] = os.path.dirname(
3737
os.path.abspath(os.path.realpath(current_file))
3838
)
3939
current_phase = os.path.basename(
4040
os.path.dirname(os.path.abspath(os.path.realpath(current_file)))
4141
)
42-
paths["data"] = os.path.join(paths["repo"], "data")
43-
data_quarter = os.path.join(paths["data"], f"{quarter}")
42+
paths["data"] = path_join(paths["repo"], "data")
43+
data_quarter = path_join(paths["data"], f"{quarter}")
4444
for phase in ["1-fetch", "2-process", "3-report"]:
45-
paths[f"data_{phase}"] = os.path.join(data_quarter, phase)
46-
paths["data_phase"] = os.path.join(data_quarter, current_phase)
45+
paths[f"data_{phase}"] = path_join(data_quarter, phase)
46+
paths["data_phase"] = path_join(data_quarter, current_phase)
4747

4848
paths["data_quarter"] = data_quarter
4949

@@ -141,7 +141,7 @@ def update_readme(
141141
"""
142142
Update the README.md file with the generated images and descriptions.
143143
"""
144-
readme_path = os.path.join(paths["data"], args.quarter, "README.md")
144+
readme_path = path_join(paths["data"], args.quarter, "README.md")
145145

146146
# Define section markers for each data source
147147
section_marker_start = f"<!-- {data_source} Start -->"

0 commit comments

Comments
 (0)