From 0c3bf972b207009fa373eb0c27e8097aaf04b578 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Mon, 6 Sep 2021 17:49:51 -0500 Subject: [PATCH] Move top-level code into main function --- pull.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pull.py b/pull.py index 2928833..8bf2c29 100755 --- a/pull.py +++ b/pull.py @@ -367,10 +367,12 @@ def save(licenses, base_uri, dir=os.curdir): f.write('\n') -if __name__ == '__main__': +def main(sys_argv=None): + if sys_argv is None: + sys_argv = sys.argv dir = os.curdir - if len(sys.argv) > 1: - dir = sys.argv[1] + if sys_argv and len(sys_argv) > 1: + dir = sys_argv[1] tree = get(uri=URI) root = tree.getroot() licenses = extract(root=root, base_uri=URI) @@ -380,3 +382,7 @@ if __name__ == '__main__': raise ValueError('unused IDENTIFIERS keys: {}'.format( ', '.join(sorted(unused_identifiers)))) save(licenses=licenses, base_uri='https://wking.github.io/fsf-api/', dir=dir) + + +if __name__ == '__main__': + main() -- 2.25.1