X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/041ec995e5165bc6f7b801a5aa2aba53e6980c1e..bbc09a4f013f2a584f143f3f5e3f76f6082367d4:/black.py diff --git a/black.py b/black.py index 7138d29..46c0907 100644 --- a/black.py +++ b/black.py @@ -1,6 +1,7 @@ import asyncio from asyncio.base_events import BaseEventLoop from concurrent.futures import Executor, ProcessPoolExecutor +from datetime import datetime from enum import Enum, Flag from functools import partial, wraps import io @@ -469,6 +470,7 @@ def format_file_in_place( if src.suffix == ".pyi": mode |= FileMode.PYI + then = datetime.utcfromtimestamp(src.stat().st_mtime) with open(src, "rb") as buf: src_contents, encoding, newline = decode_bytes(buf.read()) try: @@ -482,8 +484,9 @@ def format_file_in_place( with open(src, "w", encoding=encoding, newline=newline) as f: f.write(dst_contents) elif write_back == write_back.DIFF: - src_name = f"{src} (original)" - dst_name = f"{src} (formatted)" + now = datetime.utcnow() + src_name = f"{src}\t{then} +0000" + dst_name = f"{src}\t{now} +0000" diff_contents = diff(src_contents, dst_contents, src_name, dst_name) if lock: lock.acquire() @@ -514,6 +517,7 @@ def format_stdin_to_stdout( `line_length`, `fast`, `is_pyi`, and `force_py36` arguments are passed to :func:`format_file_contents`. """ + then = datetime.utcnow() src, encoding, newline = decode_bytes(sys.stdin.buffer.read()) dst = src try: @@ -530,8 +534,9 @@ def format_stdin_to_stdout( if write_back == WriteBack.YES: f.write(dst) elif write_back == WriteBack.DIFF: - src_name = " (original)" - dst_name = " (formatted)" + now = datetime.utcnow() + src_name = f"STDIN\t{then} +0000" + dst_name = f"STDOUT\t{now} +0000" f.write(diff(src, dst, src_name, dst_name)) f.detach() @@ -763,6 +768,7 @@ UNPACKING_PARENTS = { syms.dictsetmaker, syms.listmaker, syms.testlist_gexp, + syms.testlist_star_expr, } TEST_DESCENDANTS = { syms.test,