mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Introduce error_codes.py --next flag
This commit is contained in:
parent
4fcf0b489a
commit
e810d84a07
@ -170,26 +170,29 @@ def examine_id_coverage(top_dir, used_ids):
|
|||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
# pylint: disable=too-many-branches, too-many-locals
|
# pylint: disable=too-many-branches, too-many-locals, too-many-statements
|
||||||
|
|
||||||
check = False
|
check = False
|
||||||
fix = False
|
fix = False
|
||||||
noconfirm = False
|
no_confirm = False
|
||||||
examine_coverage = False
|
examine_coverage = False
|
||||||
opts, args = getopt.getopt(argv, "", ["check", "fix", "noconfirm", "examine-coverage"])
|
next = False
|
||||||
|
opts, args = getopt.getopt(argv, "", ["check", "fix", "no-confirm", "examine-coverage", "next"])
|
||||||
|
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == '--check':
|
if opt == '--check':
|
||||||
check = True
|
check = True
|
||||||
elif opt == "--fix":
|
elif opt == "--fix":
|
||||||
fix = True
|
fix = True
|
||||||
elif opt == '--noconfirm':
|
elif opt == '--no-confirm':
|
||||||
noconfirm = True
|
no_confirm = True
|
||||||
elif opt == '--examine-coverage':
|
elif opt == '--examine-coverage':
|
||||||
examine_coverage = True
|
examine_coverage = True
|
||||||
|
elif opt == '--next':
|
||||||
|
next = True
|
||||||
|
|
||||||
if not check and not fix and not examine_coverage:
|
if [check, fix, examine_coverage, next].count(True) != 1:
|
||||||
print("usage: python error_codes.py --check | --fix [--noconfirm] | --examine-coverage")
|
print("usage: python error_codes.py --check | --fix [--no-confirm] | --examine-coverage | --next")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
@ -215,10 +218,20 @@ def main(argv):
|
|||||||
|
|
||||||
if examine_coverage:
|
if examine_coverage:
|
||||||
if not ok:
|
if not ok:
|
||||||
print("Incorrect IDs has to be fixed before applying --examine-coverage")
|
print("Incorrect IDs have to be fixed before applying --examine-coverage")
|
||||||
res = examine_id_coverage(cwd, used_ids.keys())
|
res = examine_id_coverage(cwd, used_ids.keys())
|
||||||
exit(res)
|
exit(res)
|
||||||
|
|
||||||
|
random.seed()
|
||||||
|
|
||||||
|
if next:
|
||||||
|
if not ok:
|
||||||
|
print("Incorrect IDs have to be fixed before applying --next")
|
||||||
|
available_ids = {str(id) for id in range(1000, 10000)} - used_ids.keys()
|
||||||
|
next_id = get_next_id(available_ids)
|
||||||
|
print(f"Next ID: {next_id}")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
print("No incorrect IDs found")
|
print("No incorrect IDs found")
|
||||||
exit(0)
|
exit(0)
|
||||||
@ -228,7 +241,7 @@ def main(argv):
|
|||||||
|
|
||||||
assert fix, "Unexpected state, should not come here without --fix"
|
assert fix, "Unexpected state, should not come here without --fix"
|
||||||
|
|
||||||
if not noconfirm:
|
if not no_confirm:
|
||||||
answer = input(
|
answer = input(
|
||||||
"\nDo you want to fix incorrect IDs?\n"
|
"\nDo you want to fix incorrect IDs?\n"
|
||||||
"Please commit current changes first, and review the results when the script finishes.\n"
|
"Please commit current changes first, and review the results when the script finishes.\n"
|
||||||
@ -239,7 +252,6 @@ def main(argv):
|
|||||||
if answer not in "yY":
|
if answer not in "yY":
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
random.seed()
|
|
||||||
fix_ids(used_ids, source_file_names)
|
fix_ids(used_ids, source_file_names)
|
||||||
print("Fixing completed")
|
print("Fixing completed")
|
||||||
exit(2)
|
exit(2)
|
||||||
|
Loading…
Reference in New Issue
Block a user