Skip to content

Commit

Permalink
remove unnecessary str conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendly-Banana committed Feb 27, 2025
1 parent 32526c3 commit c0bd71c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def jsonify(weeks: Dict[int, Week], directory: str, canteen: Canteen, combine_di
year = week.year

# create dir: <year>/
json_dir = f"{str(directory)}/{str(year)}"
json_dir = f"{directory}/{year}"
if not os.path.exists(json_dir):
os.makedirs(json_dir)

Expand All @@ -52,7 +52,7 @@ def jsonify(weeks: Dict[int, Week], directory: str, canteen: Canteen, combine_di
if week_json is not None:
week_json["version"] = JSON_VERSION
# write JSON to file: <year>/<calendar_week>.json
with open(f"{str(json_dir)}/{str(calendar_week).zfill(2)}.json", "w", encoding="utf-8") as outfile:
with open(f"{json_dir}/{str(calendar_week).zfill(2)}.json", "w", encoding="utf-8") as outfile:
json.dump(week_json, outfile, separators=(",", ":"), ensure_ascii=False)

# check if combine parameter got set
Expand All @@ -62,9 +62,9 @@ def jsonify(weeks: Dict[int, Week], directory: str, canteen: Canteen, combine_di
combined_df_name = "combined"

# create directory for combined output
json_dir = f"{str(directory)}/{combined_df_name}"
json_dir = f"{directory}/{combined_df_name}"
if not os.path.exists(json_dir):
os.makedirs(f"{str(directory)}/{combined_df_name}")
os.makedirs(json_dir)

# convert all weeks to one JSON object
weeks_json_all = json.dumps(
Expand All @@ -78,7 +78,7 @@ def jsonify(weeks: Dict[int, Week], directory: str, canteen: Canteen, combine_di
)

# write JSON object to file
with open(f"{str(json_dir)}/{combined_df_name}.json", "w", encoding="utf-8") as outfile:
with open(f"{json_dir}/{combined_df_name}.json", "w", encoding="utf-8") as outfile:
json.dump(json.loads(weeks_json_all), outfile, separators=(",", ":"), ensure_ascii=False)


Expand Down

0 comments on commit c0bd71c

Please sign in to comment.