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

@ -13,58 +13,64 @@ import a2i_file
# use any OPL3 features. Returns an error message, or 'None' if data
# is valid.
def check_opl2(filename, data):
def opl2_warning(message):
print >> sys.stderr, "%s: %s" % (filename, message)
def opl2_warning(message):
print("%s: %s" % (filename, message), file=sys.stderr)
# CHA,B control stereo, but are ignored on OPL2, so it's no problem:
#if (data["feedback_fm"] & 0xf0) != 0:
# opl2_warning("Cannot use CHA,B,C,D: %02x" % data["feedback_fm"])
# CHA,B control stereo, but are ignored on OPL2, so it's no problem:
# if (data["feedback_fm"] & 0xf0) != 0:
# opl2_warning("Cannot use CHA,B,C,D: %02x" % data["feedback_fm"])
if data["m_waveform"] > 3:
opl2_warning(
"Modulator uses waveform %i: only 0-3 supported"
% data["m_waveform"]
)
if data["c_waveform"] > 3:
opl2_warning(
"Carrier uses waveform %i: only 0-3 supported" % data["c_waveform"]
)
if data["m_waveform"] > 3:
opl2_warning("Modulator uses waveform %i: only 0-3 supported" %
data["m_waveform"])
if data["c_waveform"] > 3:
opl2_warning("Carrier uses waveform %i: only 0-3 supported" %
data["c_waveform"])
def load_instrument(filename):
# As a hack, a literal dictionary of the values can be specified
# in place of a filename.
# As a hack, a literal dictionary of the values can be specified
# in place of a filename.
if isinstance(filename, dict):
return filename
if isinstance(filename, dict):
return filename
filename = os.path.join("instruments", filename)
filename = os.path.join("instruments", filename)
if filename.endswith(".a2i"):
result = a2i_file.read(filename)
elif filename.endswith(".sbi"):
result = sbi_file.read(filename)
else:
raise Exception("Unknown instrument file type: '%s'" % filename)
if filename.endswith(".a2i"):
result = a2i_file.read(filename)
elif filename.endswith(".sbi"):
result = sbi_file.read(filename)
else:
raise Exception("Unknown instrument file type: '%s'" % filename)
check_opl2(filename, result)
check_opl2(filename, result)
return result
return result
class Instrument:
def __init__(self, file1, file2=None, off1=0, off2=0, note=None):
self.voice1 = load_instrument(file1)
def __init__(self, file1, file2=None, off1=0, off2=0, note=None):
self.voice1 = load_instrument(file1)
if file2 is not None:
self.voice2 = load_instrument(file2)
else:
self.voice2 = None
if file2 is not None:
self.voice2 = load_instrument(file2)
else:
self.voice2 = None
self.fixed_note = note
self.offset1 = off1
self.offset2 = off2
self.fixed_note = note
self.offset1 = off1
self.offset2 = off2
NullInstrument = Instrument("dummy.sbi")
if __name__ == "__main__":
for filename in sys.argv[1:]:
Instrument(filename)
for filename in sys.argv[1:]:
Instrument(filename)