code cleanup and reformat (#423)

This commit is contained in:
jnozsc
2020-01-20 02:47:22 -08:00
committed by Inada Naoki
parent 0f1ff4c9c0
commit 18163d7022
25 changed files with 1409 additions and 1067 deletions

View File

@ -9,16 +9,18 @@ if __name__ == "__main__":
"""
Usage: python CR.py [/path/to/mysql/errmsg.h ...] >> CR.py
"""
import fileinput, re
import fileinput
import re
data = {}
error_last = None
for line in fileinput.input():
line = re.sub(r'/\*.*?\*/', '', line)
m = re.match(r'^\s*#define\s+CR_([A-Z0-9_]+)\s+(\d+)(\s.*|$)', line)
line = re.sub(r"/\*.*?\*/", "", line)
m = re.match(r"^\s*#define\s+CR_([A-Z0-9_]+)\s+(\d+)(\s.*|$)", line)
if m:
name = m.group(1)
value = int(m.group(2))
if name == 'ERROR_LAST':
if name == "ERROR_LAST":
if error_last is None or error_last < value:
error_last = value
continue
@ -27,9 +29,9 @@ if __name__ == "__main__":
data[value].add(name)
for value, names in sorted(data.items()):
for name in sorted(names):
print('%s = %s' % (name, value))
print("{} = {}".format(name, value))
if error_last is not None:
print('ERROR_LAST = %s' % error_last)
print("ERROR_LAST = %s" % error_last)
ERROR_FIRST = 2000