From cd1088a5a9008487f1887943545401174d84e2be Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Mon, 12 Apr 2021 14:13:34 +0200 Subject: [PATCH] format with black --- setup.py | 4 +++- src/img2pdf.py | 1 + src/img2pdf_test.py | 25 ++++++++++++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 8b2c01f..9ca7e55 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,9 @@ setup( include_package_data=True, zip_safe=True, install_requires=INSTALL_REQUIRES, - extras_require={"gui": ("tkinter"),}, + extras_require={ + "gui": ("tkinter"), + }, entry_points={ "setuptools.installation": ["eggsecutable = img2pdf:main"], "console_scripts": ["img2pdf = img2pdf:main"], diff --git a/src/img2pdf.py b/src/img2pdf.py index f99dd34..a89f984 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -2283,6 +2283,7 @@ def input_images(path_expr): # glob won't return files that don't exist so we only use it for wildcards # paths without wildcards that do not exist will trigger "does not exist" from glob import glob + paths = glob(path_expr) for path in paths: try: diff --git a/src/img2pdf_test.py b/src/img2pdf_test.py index fac47d4..33a7dae 100755 --- a/src/img2pdf_test.py +++ b/src/img2pdf_test.py @@ -603,9 +603,9 @@ def icc_profile(): b"desc\x00\x00\x00\x00" + struct.pack(">I", 5) + b"fake" + 79 * b"\x00", b"XYZ \x00\x00\x00\x00" + struct.pack(">III", *getxyz(white)), # by mixing up red, green and blue, we create a test profile - b"XYZ \x00\x00\x00\x00" + struct.pack(">III", *getxyz(blue)), # red - b"XYZ \x00\x00\x00\x00" + struct.pack(">III", *getxyz(red)), # green - b"XYZ \x00\x00\x00\x00" + struct.pack(">III", *getxyz(green)), # blue + b"XYZ \x00\x00\x00\x00" + struct.pack(">III", *getxyz(blue)), # red + b"XYZ \x00\x00\x00\x00" + struct.pack(">III", *getxyz(red)), # green + b"XYZ \x00\x00\x00\x00" + struct.pack(">III", *getxyz(green)), # blue # by only supplying two values, we create the most trivial "curve", # where the remaining values will be linearly interpolated between them b"curv\x00\x00\x00\x00" + struct.pack(">IHH", 2, 0, 65535), @@ -776,6 +776,7 @@ def tmp_icc_profile(tmp_path_factory): yield tmp_icc_profile tmp_icc_profile.unlink() + @pytest.fixture(scope="session") def tmp_icc_png(tmp_path_factory, alpha, tmp_icc_profile): normal16 = alpha[:, :, 0:3] @@ -6542,9 +6543,13 @@ def test_general(general_input, engine): assert cur_page.Resources.XObject.keys() == {"/Im0"} if engine != img2pdf.Engine.pikepdf: assert cur_page.Contents.Length == len(cur_page.Contents.read_bytes()) - assert cur_page.Contents.read_bytes() == b"q\n%.4f 0 0 %.4f 0.0000 0.0000 cm\n/Im0 Do\nQ" % ( - pagewidth, - pageheight, + assert ( + cur_page.Contents.read_bytes() + == b"q\n%.4f 0 0 %.4f 0.0000 0.0000 cm\n/Im0 Do\nQ" + % ( + pagewidth, + pageheight, + ) ) imgprops = cur_page.Resources.XObject.Im0 @@ -6682,7 +6687,7 @@ def test_general(general_input, engine): def main(): normal16 = alpha_value()[:, :, 0:3] - pathlib.Path('test.icc').write_bytes(icc_profile()) + pathlib.Path("test.icc").write_bytes(icc_profile()) write_png( normal16 / 0xFFFF * 0xFF, "icc.png", @@ -6690,6 +6695,12 @@ def main(): 2, iccp="test.icc", ) + write_png( + normal16 / 0xFFFF * 0xFF, + "normal.png", + 8, + 2, + ) if __name__ == "__main__":