Assure powrap is compatible with Windows (#105)
This commit is contained in:
parent
c826541447
commit
b5c70a7654
|
@ -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"]
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -81,7 +86,7 @@ def parse_args():
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue