Run autopep8

This commit is contained in:
3wc 2022-11-11 16:43:30 -08:00
parent 503b35c12c
commit 900fb9f0c0

View File

@ -283,6 +283,7 @@ def list_facts(ids):
for r in results:
click.secho('@{0[0]}, {0[1]}'.format(r), fg='blue')
@activities.command()
@click.argument('from_id')
@click.argument('to_id')
@ -328,7 +329,8 @@ def move_facts(from_id, to_id):
click.secho('Moved {0} facts'.format(results.rowcount), fg='green')
click.confirm(
'Would you like to delete @{0[2]} » @{0[0]}: {0[1]}?'.format(from_activity),
'Would you like to delete @{0[2]} » @{0[0]}: {0[1]}?'.format(
from_activity),
abort=True
)
@ -361,7 +363,8 @@ def find_duplicates():
results = c.execute(sql)
for r in results:
click.secho('@{0[0]}: {0[1]} » @{0[2]}: {0[3]} ({0[4]})'.format(r), fg='blue')
click.secho(
'@{0[0]}: {0[1]} » @{0[2]}: {0[3]} ({0[4]})'.format(r), fg='blue')
@cli.group()
@ -431,9 +434,12 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
'X-AUTH-TOKEN': api_key
}
customers = requests.get(f'{kimai_api_url}/customers?visible=3', headers=auth_headers).json()
projects = requests.get(f'{kimai_api_url}/projects?visible=3', headers=auth_headers).json()
activities = requests.get(f'{kimai_api_url}/activities?visible=3', headers=auth_headers).json()
customers = requests.get(
f'{kimai_api_url}/customers?visible=3', headers=auth_headers).json()
projects = requests.get(
f'{kimai_api_url}/projects?visible=3', headers=auth_headers).json()
activities = requests.get(
f'{kimai_api_url}/activities?visible=3', headers=auth_headers).json()
found_customers = []
found_projects = []
@ -442,18 +448,23 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
for row in mapping_data:
# Check if each mapping still exists in Kimai
matching_customers = list(filter(lambda x: x['name'] == row[0], customers))
matching_customers = list(
filter(lambda x: x['name'] == row[0], customers))
if row[0] in found_customers:
just_errors or click.secho("Skipping existing customer '{0}'".format(row[0]), fg='green')
just_errors or click.secho(
"Skipping existing customer '{0}'".format(row[0]), fg='green')
else:
if len(matching_customers) > 1:
click.secho("More than one match for customer '{0}'".format(row[0]), fg='red')
click.secho(
"More than one match for customer '{0}'".format(row[0]), fg='red')
continue
elif len(matching_customers) < 1:
click.secho("Missing customer '{0}'".format(row[0]), fg='yellow')
click.secho("Missing customer '{0}'".format(
row[0]), fg='yellow')
continue
else:
just_errors or click.secho("Found customer '{0}'".format(row[0]), fg='green')
just_errors or click.secho(
"Found customer '{0}'".format(row[0]), fg='green')
found_customers.append(row[0])
project_str = ':'.join(row[0:2])
@ -464,16 +475,20 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
)
if project_str in found_projects:
just_errors or click.secho("Skipping existing project '{0}'".format(project_str), fg='green')
just_errors or click.secho(
"Skipping existing project '{0}'".format(project_str), fg='green')
else:
if len(matching_projects) > 1:
click.secho("More than one match for project '{0}'".format(project_str), fg='red')
click.secho("More than one match for project '{0}'".format(
project_str), fg='red')
continue
elif len(matching_projects) < 1:
click.secho("Missing project '{0}'".format(project_str), fg='yellow')
click.secho("Missing project '{0}'".format(
project_str), fg='yellow')
continue
else:
just_errors or click.secho("Found project '{0}'".format(project_str), fg='green')
just_errors or click.secho(
"Found project '{0}'".format(project_str), fg='green')
found_projects.append(project_str)
if ignore_activities:
@ -481,7 +496,8 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
activity_str = ':'.join(row)
if activity_str in found_activities:
just_errors or click.secho("Skipping existing activity '{0}'".format(activity_str), fg='green')
just_errors or click.secho(
"Skipping existing activity '{0}'".format(activity_str), fg='green')
else:
matching_activities = list(filter(
lambda x: x['name'] == row[2]
@ -490,11 +506,14 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
))
if len(matching_activities) > 1:
click.secho("More than one match for activity '{0}'".format(activity_str), fg='red')
click.secho("More than one match for activity '{0}'".format(
activity_str), fg='red')
elif len(matching_activities) < 1:
click.secho("Missing activity '{0}'".format(activity_str), fg='yellow')
click.secho("Missing activity '{0}'".format(
activity_str), fg='yellow')
else:
just_errors or click.secho("Found activity '{0}'".format(activity_str), fg='green')
just_errors or click.secho(
"Found activity '{0}'".format(activity_str), fg='green')
found_activities.append(activity_str)
@ -587,7 +606,8 @@ def _import(username, mapping_path=None, output=None, category_search=None, afte
except KeyError:
if show_missing:
output_writer.writerow([fact[6], fact[5]])
click.secho("Can't find mapping for '{0}', skipping".format(k), fg='yellow')
click.secho(
"Can't find mapping for '{0}', skipping".format(k), fg='yellow')
continue
if show_missing: