7cf9572c26
* Merge #11881: Remove Python2 support 1874058 Make base58 python contrib code work with python3 (Evan Klitzke) bc6fdf2 Change all python files to use Python3 (John Newbery) Pull request description: Following discussion here: https://github.com/bitcoin/bitcoin/pull/11843#issuecomment-351033742 It's easier for maintainers if all python tools/scripts support only a single version of Python. There are only a few scripts that aren't explicitly python3 at this point, so this PR changes those remaining scripts to explicitly require python3. Tree-SHA512: 5d38eef6e0fc7d8515e23a1f4c75e8b4160fd0fe23cba52a1f41689b114e54a9e503e0724829e8b41982ef98f2d113df80d9e238213b74f09ceaed0344a19e24 * Merge #12829: Python3 fixup f50975b [contrib] fixup symbol-check.py Python3 support (John Newbery) 5de2b18 [contrib] fixup security-check.py Python3 support (John Newbery) Pull request description: security-check.py and symbol-check.py were broken by #11881. Fix them. Tree-SHA512: 86de3d6dc3292b1ae4cc04c2d7d7dbbf39c9270551d7b224b8d8b19e3184c30c897dbf823200403706d06bb405c0decad5cfd690cb2c0312992a235a4ffcf6bf
46 lines
1.8 KiB
Python
Executable File
46 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2015 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
'''
|
|
This checks if all command line args are documented.
|
|
Return value is 0 to indicate no error.
|
|
|
|
Author: @MarcoFalke
|
|
'''
|
|
|
|
from subprocess import check_output
|
|
import re
|
|
|
|
FOLDER_GREP = 'src'
|
|
FOLDER_TEST = 'src/test/'
|
|
CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/{}'.format(FOLDER_GREP)
|
|
CMD_GREP_ARGS = r"egrep -r -I '(map(Multi)?Args(\.count\(|\[)|Get(Bool)?Arg\()\"\-[^\"]+?\"' {} | grep -v '{}'".format(CMD_ROOT_DIR, FOLDER_TEST)
|
|
CMD_GREP_DOCS = r"egrep -r -I 'HelpMessageOpt\(\"\-[^\"=]+?(=|\")' {}".format(CMD_ROOT_DIR)
|
|
REGEX_ARG = re.compile(r'(?:map(?:Multi)?Args(?:\.count\(|\[)|Get(?:Bool)?Arg\()\"(\-[^\"]+?)\"')
|
|
REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")')
|
|
# list unsupported, deprecated and duplicate args as they need no documentation
|
|
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-blockminsize'])
|
|
|
|
def main():
|
|
used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True)
|
|
docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True)
|
|
|
|
args_used = set(re.findall(REGEX_ARG,used))
|
|
args_docd = set(re.findall(REGEX_DOC,docd)).union(SET_DOC_OPTIONAL)
|
|
args_need_doc = args_used.difference(args_docd)
|
|
args_unknown = args_docd.difference(args_used)
|
|
|
|
print("Args used : {}".format(len(args_used)))
|
|
print("Args documented : {}".format(len(args_docd)))
|
|
print("Args undocumented: {}".format(len(args_need_doc)))
|
|
print(args_need_doc)
|
|
print("Args unknown : {}".format(len(args_unknown)))
|
|
print(args_unknown)
|
|
|
|
exit(len(args_need_doc))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|