Clean up command hash generation
Rather than COMMANDS and its join to CHRACTERS['commands'] be a messy cluster of \n, do some string parsing to make it look much cleaner and more readable.
This commit is contained in:
parent
cf1d7c0703
commit
48f38d9672
1 changed files with 18 additions and 2 deletions
20
main.py
20
main.py
|
@ -69,9 +69,25 @@ def parse_COMMANDS(data):
|
|||
# it as the name of the command in the next block. Blorf :)
|
||||
next_command_name = None
|
||||
for c_data in data.split('\n-------\n'):
|
||||
c_data_lines = c_data.split('\n')
|
||||
c_data_lines = [c_data_line.strip() for c_data_line in c_data.split('\n')]
|
||||
if '' in c_data_lines:
|
||||
c_data_lines.remove('')
|
||||
if next_command_name:
|
||||
commands[next_command_name] = '\n'.join(c_data_lines[:-1])
|
||||
command_string = '; '.join(c_data_lines[:-1])
|
||||
|
||||
# Clip trailing junk from inconsistent spoiler log generation
|
||||
# as well as the join above
|
||||
if command_string.endswith('; '):
|
||||
command_string = command_string[:-2]
|
||||
if command_string.endswith('.'):
|
||||
command_string = command_string[:-1]
|
||||
|
||||
# Clean up a couple of clumsy string cases from the join above
|
||||
command_string = command_string.replace('.; ', ': ')
|
||||
command_string = command_string.replace(' ', ' ')
|
||||
|
||||
# Commit the command to the dict
|
||||
commands[next_command_name] = command_string
|
||||
|
||||
next_command_name = c_data_lines[-1].lower()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue