From adaaf6a3883ca59a2c61ad1acdfea884dadb538d Mon Sep 17 00:00:00 2001 From: ezavod Date: Tue, 16 Jun 2020 10:30:25 +0200 Subject: [PATCH] refactor(scripts): absolute path and spelling in check funcs --- scripts/check-used-functions.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/check-used-functions.py b/scripts/check-used-functions.py index 9633fc46..ed53de7d 100755 --- a/scripts/check-used-functions.py +++ b/scripts/check-used-functions.py @@ -1,13 +1,20 @@ #!/usr/bin/env python """ -Check that all the functions defined in the C API are effectivelly used +Check that all the functions defined in the C API are +effectively used in the chemfiles binding. """ import os import sys IGNORED = ["chfl_version", "chfl_trajectory_open"] -ROOT = os.path.dirname(os.path.dirname(__file__)) ERROR = False +ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") + + +def error(message): + print(message) + global ERROR + ERROR = True def functions_list(): @@ -23,8 +30,8 @@ def functions_list(): def read_all_source(): source = "" - for (dirpath, _, pathes) in os.walk(os.path.join(ROOT, "chemfiles")): - for path in pathes: + for (dirpath, _, paths) in os.walk(os.path.join(ROOT, "chemfiles")): + for path in paths: if path != "ffi.py" and path.endswith(".py"): with open(os.path.join(ROOT, dirpath, path)) as fd: source += fd.read() @@ -34,14 +41,13 @@ def read_all_source(): def check_functions(functions, source): for function in functions: if function not in source and function not in IGNORED: - print("Missing: " + function) - global ERROR - ERROR = True + error("Missing: " + function) if __name__ == '__main__': functions = functions_list() source = read_all_source() check_functions(functions, source) + if ERROR: sys.exit(1)