Run autopep8
This commit is contained in:
parent
503b35c12c
commit
900fb9f0c0
@ -283,6 +283,7 @@ def list_facts(ids):
|
|||||||
for r in results:
|
for r in results:
|
||||||
click.secho('@{0[0]}, {0[1]}'.format(r), fg='blue')
|
click.secho('@{0[0]}, {0[1]}'.format(r), fg='blue')
|
||||||
|
|
||||||
|
|
||||||
@activities.command()
|
@activities.command()
|
||||||
@click.argument('from_id')
|
@click.argument('from_id')
|
||||||
@click.argument('to_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.secho('Moved {0} facts'.format(results.rowcount), fg='green')
|
||||||
|
|
||||||
click.confirm(
|
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
|
abort=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -361,7 +363,8 @@ def find_duplicates():
|
|||||||
results = c.execute(sql)
|
results = c.execute(sql)
|
||||||
|
|
||||||
for r in results:
|
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()
|
@cli.group()
|
||||||
@ -431,9 +434,12 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
|
|||||||
'X-AUTH-TOKEN': api_key
|
'X-AUTH-TOKEN': api_key
|
||||||
}
|
}
|
||||||
|
|
||||||
customers = requests.get(f'{kimai_api_url}/customers?visible=3', headers=auth_headers).json()
|
customers = requests.get(
|
||||||
projects = requests.get(f'{kimai_api_url}/projects?visible=3', headers=auth_headers).json()
|
f'{kimai_api_url}/customers?visible=3', headers=auth_headers).json()
|
||||||
activities = requests.get(f'{kimai_api_url}/activities?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_customers = []
|
||||||
found_projects = []
|
found_projects = []
|
||||||
@ -442,18 +448,23 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
|
|||||||
for row in mapping_data:
|
for row in mapping_data:
|
||||||
# Check if each mapping still exists in Kimai
|
# 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:
|
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:
|
else:
|
||||||
if len(matching_customers) > 1:
|
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
|
continue
|
||||||
elif len(matching_customers) < 1:
|
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
|
continue
|
||||||
else:
|
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])
|
found_customers.append(row[0])
|
||||||
|
|
||||||
project_str = ':'.join(row[0:2])
|
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:
|
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:
|
else:
|
||||||
if len(matching_projects) > 1:
|
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
|
continue
|
||||||
elif len(matching_projects) < 1:
|
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
|
continue
|
||||||
else:
|
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)
|
found_projects.append(project_str)
|
||||||
|
|
||||||
if ignore_activities:
|
if ignore_activities:
|
||||||
@ -481,7 +496,8 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
|
|||||||
|
|
||||||
activity_str = ':'.join(row)
|
activity_str = ':'.join(row)
|
||||||
if activity_str in found_activities:
|
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:
|
else:
|
||||||
matching_activities = list(filter(
|
matching_activities = list(filter(
|
||||||
lambda x: x['name'] == row[2]
|
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:
|
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:
|
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:
|
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)
|
found_activities.append(activity_str)
|
||||||
|
|
||||||
|
|
||||||
@ -587,7 +606,8 @@ def _import(username, mapping_path=None, output=None, category_search=None, afte
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
if show_missing:
|
if show_missing:
|
||||||
output_writer.writerow([fact[6], fact[5]])
|
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
|
continue
|
||||||
|
|
||||||
if show_missing:
|
if show_missing:
|
||||||
|
Loading…
Reference in New Issue
Block a user