Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Assure powrap is compatible with Windows (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
egeakman committed Mar 30, 2023
1 parent c826541 commit b5c70a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions powrap/powrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def check_style(po_files: Iterable[str], no_wrap=False, quiet=False, diff=False)
except OSError as open_error:
tqdm.write(f"Error opening '{po_path}': {open_error}")
continue
with NamedTemporaryFile("w+") as tmpfile:

delete = os.name == "posix" and sys.platform != "cygwin"

with NamedTemporaryFile("w+", delete=delete, encoding="utf-8") as tmpfile:
args = ["msgcat", "-", "-o", tmpfile.name]
if no_wrap:
args[1:1] = ["--no-wrap"]
Expand All @@ -49,6 +52,8 @@ def check_style(po_files: Iterable[str], no_wrap=False, quiet=False, diff=False)
new_po_content.splitlines(keepends=True),
):
print(line, end="", file=sys.stderr)
if not delete:
os.remove(tmpfile.name)
return errors


Expand Down Expand Up @@ -81,7 +86,7 @@ def path(path_str):
if not path_obj.is_file():
raise argparse.ArgumentTypeError("{!r} is not a file.".format(path_str))
try:
path_obj.read_text()
path_obj.read_text(encoding="utf-8")
except PermissionError as read_error:
raise argparse.ArgumentTypeError(
"{!r}: Permission denied.".format(path_str)
Expand Down

0 comments on commit b5c70a7

Please sign in to comment.