From 3af152b4348ca41a1dfffed542f3d7356ecce2b6 Mon Sep 17 00:00:00 2001 From: Ann Lewis Date: Tue, 7 Jan 2020 20:33:17 -0500 Subject: [PATCH] syntax updates suggested by python 2to3 tool --- ak-event-merge/merge.py | 12 ++++++------ ak-replace-host/entry_points.py | 6 +++--- .../get_results_from_mysql_query_with_params.py | 2 +- gdpr-cleanup/entry_points.py | 6 +++--- kos-imports/correct_columns.py | 2 +- kos-imports/entry_points.py | 4 ++-- propensity-cleanup/cleanup.py | 6 +++--- s3-to-redshift/entry_points.py | 4 ++-- target-tracking/entry_points.py | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ak-event-merge/merge.py b/ak-event-merge/merge.py index 3e30231..fe6ac5a 100644 --- a/ak-event-merge/merge.py +++ b/ak-event-merge/merge.py @@ -40,7 +40,7 @@ def main(args): next = False offset = 0 while next is not None: - print('Loading TO event signups ... %s' % offset) + print(('Loading TO event signups ... %s' % offset)) reponse = ak.list_signups(query_params={ 'event': args.TO_EVENT, '_limit': 100, @@ -59,7 +59,7 @@ def main(args): next = False offset = 0 while next is not None: - print('Loading hosts ... %s' % offset) + print(('Loading hosts ... %s' % offset)) host_reponse = ak.list_signups(query_params={ 'event': args.FROM_EVENT, 'role': 'host', @@ -71,7 +71,7 @@ def main(args): hosts += host_reponse.get('objects') # Save hosts TO event. for index, host in enumerate(hosts): - print('Adding hosts ... %s/%s' % (index + 1, len(hosts))) + print(('Adding hosts ... %s/%s' % (index + 1, len(hosts)))) user_id = re.findall(r'/(\d+)/?$', host.get('user'))[0] if not to_signups.get(user_id, False): ak.create_signup(user_id, args.TO_EVENT, args.SIGNUP_PAGE, role='host', fields={'source': 'ak-event-merge'}) @@ -82,7 +82,7 @@ def main(args): next = False offset = 0 while next is not None: - print('Loading FROM attendees ... %s' % offset) + print(('Loading FROM attendees ... %s' % offset)) attendee_response = ak.list_signups(query_params={ 'event': args.FROM_EVENT, 'role': 'attendee', @@ -94,7 +94,7 @@ def main(args): attendees += attendee_response.get('objects') # Save attendees TO event. for index, attendee in enumerate(attendees): - print('Adding attendees ... %s/%s' % (index + 1, len(attendees))) + print(('Adding attendees ... %s/%s' % (index + 1, len(attendees)))) user_id = re.findall(r'/(\d+)/?$', attendee.get('user'))[0] if not to_signups.get(user_id, False): ak.create_signup(user_id, args.TO_EVENT, args.SIGNUP_PAGE, role='attendee', fields={'source': 'ak-event-merge'}) @@ -119,7 +119,7 @@ def main(args): ) pp = pprint.PrettyPrinter(indent=2) - for argname, helptext in ARG_DEFINITIONS.items(): + for argname, helptext in list(ARG_DEFINITIONS.items()): parser.add_argument( '--%s' % argname, dest=argname, help=helptext, default=getattr(settings, argname, False) diff --git a/ak-replace-host/entry_points.py b/ak-replace-host/entry_points.py index c40d4e6..7c8f9dc 100644 --- a/ak-replace-host/entry_points.py +++ b/ak-replace-host/entry_points.py @@ -6,7 +6,7 @@ def all_required_args_set(args, required, definitions) -> bool: for arg in required: if not getattr(args, arg, False): - print('%s (%s) required, missing.' % (definitions.get(arg), arg)) + print(('%s (%s) required, missing.' % (definitions.get(arg), arg))) set = False return set @@ -28,7 +28,7 @@ def run_from_cli(func, description, definitions, required) -> None: parser = argparse.ArgumentParser(description=description) - for argname, helptext in definitions.items(): + for argname, helptext in list(definitions.items()): parser.add_argument( '--%s' % argname, dest=argname, help=helptext, default=getattr(settings, argname, False) @@ -68,7 +68,7 @@ def run_from_lamba(func, description, definitions, required, event) -> str: for argname in kwargs: event[argname] = kwargs.get(argname) - for argname, helptext in definitions.items(): + for argname, helptext in list(definitions.items()): if not event.get(argname, False): event[argname] = getattr(settings, argname, False) diff --git a/ak-replace-host/get_results_from_mysql_query_with_params.py b/ak-replace-host/get_results_from_mysql_query_with_params.py index 01f7bc7..a3c9fb0 100644 --- a/ak-replace-host/get_results_from_mysql_query_with_params.py +++ b/ak-replace-host/get_results_from_mysql_query_with_params.py @@ -31,7 +31,7 @@ def main(args) -> list: print('QUERY or SQL parameter required, both missing.') return [] params = parse_qs(args.PARAMS) - for key, value in params.items(): + for key, value in list(params.items()): args.QUERY = args.QUERY.replace('{{%s}}' % key, value[0]) connection = pymysql.connect( host=args.MYSQL_DB_HOST, diff --git a/gdpr-cleanup/entry_points.py b/gdpr-cleanup/entry_points.py index c40d4e6..7c8f9dc 100644 --- a/gdpr-cleanup/entry_points.py +++ b/gdpr-cleanup/entry_points.py @@ -6,7 +6,7 @@ def all_required_args_set(args, required, definitions) -> bool: for arg in required: if not getattr(args, arg, False): - print('%s (%s) required, missing.' % (definitions.get(arg), arg)) + print(('%s (%s) required, missing.' % (definitions.get(arg), arg))) set = False return set @@ -28,7 +28,7 @@ def run_from_cli(func, description, definitions, required) -> None: parser = argparse.ArgumentParser(description=description) - for argname, helptext in definitions.items(): + for argname, helptext in list(definitions.items()): parser.add_argument( '--%s' % argname, dest=argname, help=helptext, default=getattr(settings, argname, False) @@ -68,7 +68,7 @@ def run_from_lamba(func, description, definitions, required, event) -> str: for argname in kwargs: event[argname] = kwargs.get(argname) - for argname, helptext in definitions.items(): + for argname, helptext in list(definitions.items()): if not event.get(argname, False): event[argname] = getattr(settings, argname, False) diff --git a/kos-imports/correct_columns.py b/kos-imports/correct_columns.py index d080c21..830c064 100644 --- a/kos-imports/correct_columns.py +++ b/kos-imports/correct_columns.py @@ -21,7 +21,7 @@ def main(args) -> str: reader = csv.reader(input_file) headers = next(reader) - for old, new in parse_qs(args.CORRECTIONS).items(): + for old, new in list(parse_qs(args.CORRECTIONS).items()): if old in headers: headers[headers.index(old)] = new[0] diff --git a/kos-imports/entry_points.py b/kos-imports/entry_points.py index c2a64e3..df83eb6 100644 --- a/kos-imports/entry_points.py +++ b/kos-imports/entry_points.py @@ -6,7 +6,7 @@ def all_required_args_set(args, required, definitions) -> bool: for arg in required: if not getattr(args, arg, False): - print('%s (%s) required, missing.' % (definitions.get(arg), arg)) + print(('%s (%s) required, missing.' % (definitions.get(arg), arg))) set = False return set @@ -28,7 +28,7 @@ def run_from_cli(func, description, definitions, required) -> None: parser = argparse.ArgumentParser(description=description) - for argname, helptext in definitions.items(): + for argname, helptext in list(definitions.items()): parser.add_argument( '--%s' % argname, dest=argname, help=helptext, default=getattr(settings, argname, False) diff --git a/propensity-cleanup/cleanup.py b/propensity-cleanup/cleanup.py index a15e0c7..2ede9e2 100644 --- a/propensity-cleanup/cleanup.py +++ b/propensity-cleanup/cleanup.py @@ -33,7 +33,7 @@ def main(args): for arg in REQUIRED_ARGS: if not getattr(args, arg, False): - print('%s (%s) required, missing.' % (ARG_DEFINITIONS.get(arg), arg)) + print(('%s (%s) required, missing.' % (ARG_DEFINITIONS.get(arg), arg))) all_required_args_set = False if all_required_args_set: @@ -65,7 +65,7 @@ def main(args): table_dates[table] = table_date(table) today = datetime.today() month_ago = today - timedelta(days=30) - old_tables = [table for table in table_dates.keys() if table_dates[table] < month_ago][:100] + old_tables = [table for table in list(table_dates.keys()) if table_dates[table] < month_ago][:100] for table in old_tables: database_cursor.execute(""" DROP TABLE signature_propensity.%s @@ -86,7 +86,7 @@ def main(args): ) pp = pprint.PrettyPrinter(indent=2) - for argname, helptext in ARG_DEFINITIONS.items(): + for argname, helptext in list(ARG_DEFINITIONS.items()): parser.add_argument( '--%s' % argname, dest=argname, help=helptext, default=getattr(settings, argname, False) diff --git a/s3-to-redshift/entry_points.py b/s3-to-redshift/entry_points.py index c2a64e3..df83eb6 100644 --- a/s3-to-redshift/entry_points.py +++ b/s3-to-redshift/entry_points.py @@ -6,7 +6,7 @@ def all_required_args_set(args, required, definitions) -> bool: for arg in required: if not getattr(args, arg, False): - print('%s (%s) required, missing.' % (definitions.get(arg), arg)) + print(('%s (%s) required, missing.' % (definitions.get(arg), arg))) set = False return set @@ -28,7 +28,7 @@ def run_from_cli(func, description, definitions, required) -> None: parser = argparse.ArgumentParser(description=description) - for argname, helptext in definitions.items(): + for argname, helptext in list(definitions.items()): parser.add_argument( '--%s' % argname, dest=argname, help=helptext, default=getattr(settings, argname, False) diff --git a/target-tracking/entry_points.py b/target-tracking/entry_points.py index c40d4e6..7c8f9dc 100644 --- a/target-tracking/entry_points.py +++ b/target-tracking/entry_points.py @@ -6,7 +6,7 @@ def all_required_args_set(args, required, definitions) -> bool: for arg in required: if not getattr(args, arg, False): - print('%s (%s) required, missing.' % (definitions.get(arg), arg)) + print(('%s (%s) required, missing.' % (definitions.get(arg), arg))) set = False return set @@ -28,7 +28,7 @@ def run_from_cli(func, description, definitions, required) -> None: parser = argparse.ArgumentParser(description=description) - for argname, helptext in definitions.items(): + for argname, helptext in list(definitions.items()): parser.add_argument( '--%s' % argname, dest=argname, help=helptext, default=getattr(settings, argname, False) @@ -68,7 +68,7 @@ def run_from_lamba(func, description, definitions, required, event) -> str: for argname in kwargs: event[argname] = kwargs.get(argname) - for argname, helptext in definitions.items(): + for argname, helptext in list(definitions.items()): if not event.get(argname, False): event[argname] = getattr(settings, argname, False)