Skip to content

Commit

Permalink
fix: on Windows, make generated files out LF so they're not spuriousl…
Browse files Browse the repository at this point in the history
…y changed

Previously, running `g2p update` on Windows would change
language-network.json by changing its LF to CRLF, so Git would say it
was changed even if there were not content changes.
  • Loading branch information
joanise committed Nov 4, 2022
1 parent b10abee commit 0613906
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion g2p/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def update_docs():
with open(swagger_path) as f:
data = json.load(f)
data["components"]["schemas"]["Langs"]["enum"] = sorted(LANGS_NETWORK.nodes)
with open(swagger_path, "w") as f:
with open(swagger_path, "w", newline="\n") as f:
f.write(json.dumps(data))
LOGGER.info("Updated API documentation")

Expand Down
4 changes: 3 additions & 1 deletion g2p/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def network_to_echart(write_to_file: bool = False, layout: bool = False):
edges.append({"source": edge[0], "target": edge[1]})
if write_to_file:
with open(
os.path.join(os.path.dirname(static_file), "languages-network.json"), "w"
os.path.join(os.path.dirname(static_file), "languages-network.json"),
"w",
newline="\n",
) as f:
f.write(json.dumps({"nodes": nodes, "edges": edges}) + "\n")
LOGGER.info("Wrote network nodes and edges to static file.")
Expand Down
2 changes: 1 addition & 1 deletion g2p/mappings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def mapping_to_file(self, output_path: str = GEN_DIR, file_type: str = "json"):
+ "."
+ file_type,
)
with open(fn, "w", encoding="utf8") as f:
with open(fn, "w", encoding="utf8", newline="\n") as f:
self.mapping_to_stream(f, file_type)

def config_to_file(
Expand Down

0 comments on commit 0613906

Please sign in to comment.