Merge pull request #7526 from akx/mount-ruffmore

This commit is contained in:
Hugo van Kemenade 2023-11-13 16:15:06 +02:00 committed by GitHub
commit 902055fbfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 13 deletions

View File

@ -45,7 +45,7 @@ def test_direct():
assert caccess[(0, 0)] == access[(0, 0)] assert caccess[(0, 0)] == access[(0, 0)]
print("Size: %sx%s" % im.size) # noqa: UP031 print(f"Size: {im.width}x{im.height}")
timer(iterate_get, "PyAccess - get", im.size, access) timer(iterate_get, "PyAccess - get", im.size, access)
timer(iterate_set, "PyAccess - set", im.size, access) timer(iterate_set, "PyAccess - set", im.size, access)
timer(iterate_get, "C-api - get", im.size, caccess) timer(iterate_get, "C-api - get", im.size, caccess)

View File

@ -77,12 +77,11 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):
# Hack to support hi-res rendering # Hack to support hi-res rendering
scale = int(scale) or 1 scale = int(scale) or 1
size = (size[0] * scale, size[1] * scale) width = size[0] * scale
height = size[1] * scale
# resolution is dependent on bbox and size # resolution is dependent on bbox and size
res = ( res_x = 72.0 * width / (bbox[2] - bbox[0])
72.0 * size[0] / (bbox[2] - bbox[0]), res_y = 72.0 * height / (bbox[3] - bbox[1])
72.0 * size[1] / (bbox[3] - bbox[1]),
)
out_fd, outfile = tempfile.mkstemp() out_fd, outfile = tempfile.mkstemp()
os.close(out_fd) os.close(out_fd)
@ -119,8 +118,8 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):
command = [ command = [
gs_binary, gs_binary,
"-q", # quiet mode "-q", # quiet mode
"-g%dx%d" % size, # set output geometry (pixels) f"-g{width:d}x{height:d}", # set output geometry (pixels)
"-r%fx%f" % res, # set input DPI (dots per inch) # noqa: UP031 f"-r{res_x:f}x{res_y:f}", # set input DPI (dots per inch)
"-dBATCH", # exit after processing "-dBATCH", # exit after processing
"-dNOPAUSE", # don't pause between pages "-dNOPAUSE", # don't pause between pages
"-dSAFER", # safe mode "-dSAFER", # safe mode

View File

@ -391,8 +391,8 @@ if __name__ == "__main__":
with open(sys.argv[1], "rb") as fp: with open(sys.argv[1], "rb") as fp:
imf = IcnsImageFile(fp) imf = IcnsImageFile(fp)
for size in imf.info["sizes"]: for size in imf.info["sizes"]:
imf.size = size width, height, scale = imf.size = size
imf.save("out-%s-%s-%s.png" % size) # noqa: UP031 imf.save(f"out-{width}-{height}-{scale}.png")
with Image.open(sys.argv[1]) as im: with Image.open(sys.argv[1]) as im:
im.save("out.png") im.save("out.png")
if sys.platform == "windows": if sys.platform == "windows":

View File

@ -3100,7 +3100,8 @@ def fromarray(obj, mode=None):
try: try:
mode, rawmode = _fromarray_typemap[typekey] mode, rawmode = _fromarray_typemap[typekey]
except KeyError as e: except KeyError as e:
msg = "Cannot handle this data type: %s, %s" % typekey # noqa: UP031 typekey_shape, typestr = typekey
msg = f"Cannot handle this data type: {typekey_shape}, {typestr}"
raise TypeError(msg) from e raise TypeError(msg) from e
else: else:
rawmode = mode rawmode = mode

View File

@ -82,7 +82,7 @@ class IndirectReference(
collections.namedtuple("IndirectReferenceTuple", ["object_id", "generation"]) collections.namedtuple("IndirectReferenceTuple", ["object_id", "generation"])
): ):
def __str__(self): def __str__(self):
return "%s %s R" % self # noqa: UP031 return f"{self.object_id} {self.generation} R"
def __bytes__(self): def __bytes__(self):
return self.__str__().encode("us-ascii") return self.__str__().encode("us-ascii")
@ -103,7 +103,7 @@ class IndirectReference(
class IndirectObjectDef(IndirectReference): class IndirectObjectDef(IndirectReference):
def __str__(self): def __str__(self):
return "%s %s obj" % self # noqa: UP031 return f"{self.object_id} {self.generation} obj"
class XrefTable: class XrefTable: