Separate errors needing regex from those which don't

This commit is contained in:
Lonami Exo
2018-06-18 19:09:45 +02:00
parent 463847ad50
commit fbf3bf119c
2 changed files with 8 additions and 7 deletions

View File

@@ -45,8 +45,10 @@ def generate_errors(errors, f):
f.write(')\n')
# Create the actual {CODE: ErrorClassName} dict once classes are defined
# TODO Actually make a difference between regex/exact
f.write('\n\nrpc_errors_all = {\n')
for error in itertools.chain(regex_match, exact_match):
f.write('\n\nrpc_errors_dict = {\n')
for error in exact_match:
f.write(' {}: {},\n'.format(repr(error.pattern), error.name))
f.write('}\n')
f.write('}\n\nrpc_errors_re = (\n')
for error in regex_match:
f.write(' ({}, {}),\n'.format(repr(error.pattern), error.name))
f.write(')\n')