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

@ -12,43 +12,44 @@
import midi
import sys
def get_instr_stats(filename):
"""Get a set of instruments used by the specified MIDI file."""
result = set()
midfile = midi.read_midifile(filename)
"""Get a set of instruments used by the specified MIDI file."""
result = set()
midfile = midi.read_midifile(filename)
for track in midfile:
for event in track:
if isinstance(event, midi.ProgramChangeEvent) \
and event.channel != 9:
instr = event.data[0]
result.add(instr)
# Percussion:
if isinstance(event, midi.NoteOnEvent) \
and event.channel == 9:
instr = event.data[0] + 128
result.add(instr)
for track in midfile:
for event in track:
if (
isinstance(event, midi.ProgramChangeEvent)
and event.channel != 9
):
instr = event.data[0]
result.add(instr)
# Percussion:
if isinstance(event, midi.NoteOnEvent) and event.channel == 9:
instr = event.data[0] + 128
result.add(instr)
return result
return result
total_stats = [0] * 217
for filename in sys.argv[1:]:
print "Processing %s" % filename
stats = get_instr_stats(filename)
print sorted(stats)
for instrument in stats:
total_stats[instrument] += 1
print("Processing %s" % filename)
stats = get_instr_stats(filename)
print(sorted(stats))
for instrument in stats:
total_stats[instrument] += 1
with open("stats.py", "w") as f:
f.write("# Instrument stats, autogenerated by gather_stats.py\n\n")
f.write("INSTRUMENT_STATS = [\n\t")
for index, stat in enumerate(total_stats):
f.write("% 5i," % stat)
if (index % 10) == 9:
f.write("\n\t")
f.write("\n]\n")
f.write("# Instrument stats, autogenerated by gather_stats.py\n\n")
f.write("INSTRUMENT_STATS = [\n\t")
for index, stat in enumerate(total_stats):
f.write("% 5i," % stat)
if (index % 10) == 9:
f.write("\n\t")
f.write("\n]\n")