mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-02 07:25:45 -04:00
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:
parent
6b486b6332
commit
4701d8f351
30 changed files with 2528 additions and 2102 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue