wrap main code path in its own function

This lets us use it as a console_scripts entry point.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2019-11-18 14:58:21 +01:00
parent 1297522e6a
commit 79e44b2953

View file

@ -522,7 +522,7 @@ def notify_users(errors):
@cache.cache_on_arguments()
def _get_override_yaml(project):
def _get_override_yaml(project, session):
pagure_override_url = '{0}/{1}/raw/master/f/{2}/{3}'.format(
PAGUREURL.rstrip('/'), BUGZILLA_OVERRIDE_REPO, project['namespace'],
project['name'])
@ -631,7 +631,7 @@ def _to_legacy_schema(product_and_project, session=None):
owner = 'orphan'
# Check if the Bugzilla ticket assignee has been manually overridden
override_yaml = _get_override_yaml(project)
override_yaml = _get_override_yaml(project, session)
if override_yaml.get(product) \
and isinstance(override_yaml[product], str):
owner = override_yaml[product]
@ -655,7 +655,10 @@ def _to_legacy_schema(product_and_project, session=None):
}
if __name__ == '__main__':
def main():
"""The entrypoint to the script."""
global VERBOSE, DRYRUN, projects_dict
parser = argparse.ArgumentParser(
description='Script syncing information between Pagure and bugzilla'
)
@ -817,3 +820,7 @@ if __name__ == '__main__':
json.dump({}, stream)
sys.exit(0)
if __name__ == '__main__':
main()