Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use utf-8 when printing dd files #207

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions xl2times/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def produce_times_tables(
def write_dd_files(
tables: Dict[str, DataFrame], config: datatypes.Config, output_dir: str
):
encoding = "utf-8"
os.makedirs(output_dir, exist_ok=True)
for item in os.listdir(output_dir):
if item.endswith(".dd"):
Expand Down Expand Up @@ -369,11 +370,13 @@ def convert_parameter(tablename: str, df: DataFrame):
tables_in_file = {
"ts.dd": ["ALL_TS"],
"milestonyr.dd": ["MILESTONYR"],
"output.dd": [t for t in config.dd_table_order if t != "ALL_TS"],
"output.dd": [
t for t in config.dd_table_order if t not in ["ALL_TS", "MILESTONYR"]
],
}

for fname, tablenames in tables_in_file.items():
with open(os.path.join(output_dir, fname), "w") as fout:
with open(os.path.join(output_dir, fname), "w", encoding=encoding) as fout:
for tablename in [t for t in tablenames if t in tables]:
df = tables[tablename]
if tablename in sets:
Expand Down
Loading