Blacken all Python files

Using the black code reformatter, pass it over all our Python files.
This allows for a consistent style across the code base.

Exception: lumps/dmxgus/stats.py, for readability.
This commit is contained in:
Mike Swanson 2019-09-04 19:36:23 -07:00
parent 6b486b6332
commit 4701d8f351
30 changed files with 2528 additions and 2102 deletions

View file

@ -7,11 +7,12 @@ import glob
import struct
import png
class Graphic(object):
def __init__(self, filepath):
self.filepath = filepath
self.filename = path.split(filepath)[1]
self.name = path.splitext(self.filename)[0].upper().replace('^', '\\')
self.name = path.splitext(self.filename)[0].upper().replace("^", "\\")
self.has_offset = False
self.get_png_offset()
@ -22,15 +23,20 @@ class Graphic(object):
self.xoffset, self.yoffset = struct.unpack(">II", chunk[1])
self.has_offset = True
def main():
dirname = path.split(path.abspath(__file__))[0]
graphics = []
files = []
if len(sys.argv) < 2:
print("This script takes the offsets stored in the \"grAb\" chunk of " +
"the specified PNGs and adjusts the graphics offsets in the build_cfg file.\n")
print(
'This script takes the offsets stored in the "grAb" chunk of '
+ "the specified PNGs and adjusts the graphics offsets in the build_cfg file.\n"
)
print("Usage:\n\t fix-sprite-offsets <names> [names] [...]\n")
print("example: \n\tfix-sprite-offsets sprites/vilea1.png sprites/vileb1.png")
print(
"example: \n\tfix-sprite-offsets sprites/vilea1.png sprites/vileb1.png"
)
print("You can also use wildcards:")
print("\t fix-sprite-offsets sprites/vile*.png")
exit()
@ -40,7 +46,7 @@ def main():
for filepath in files:
if not path.isfile(filepath):
print("Could not find" + filepath +", skipping...")
print("Could not find" + filepath + ", skipping...")
elif path.splitext(filepath)[1] == ".png":
graphics.append(Graphic(filepath))
for graphic in graphics:
@ -56,7 +62,11 @@ def main():
if graphic.has_offset is True:
thing = line.split()
if len(thing) > 0 and thing[0] == graphic.name:
new_string = "%s\t%i\t%i" %(graphic.name, graphic.xoffset, graphic.yoffset)
new_string = "%s\t%i\t%i" % (
graphic.name,
graphic.xoffset,
graphic.yoffset,
)
comments = line.split(";")
if len(comments) > 1:
new_string += "\t;" + "".join(comments[1:])
@ -72,5 +82,6 @@ def main():
f.writelines(newlines)
f.close()
if __name__ == '__main__':
if __name__ == "__main__":
main()