Skip to content
This repository has been archived by the owner on Feb 25, 2018. It is now read-only.

Commit

Permalink
Merge branch 'release/0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikdoof committed Aug 4, 2016
2 parents 0f29c7c + 64aefd3 commit c60f1ef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
15 changes: 10 additions & 5 deletions nextaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def get_subitems(items, parent_item=None):
"""Search a flat item list for child items"""
"""Search a flat item list for child items."""
result_items = []
found = False
if parent_item:
Expand All @@ -35,7 +35,7 @@ def get_subitems(items, parent_item=None):


def main():

"""Main process function."""
parser = argparse.ArgumentParser()
parser.add_argument('-a', '--api_key', help='Todoist API Key')
parser.add_argument('-l', '--label', help='The next action label to use', default='next_action')
Expand Down Expand Up @@ -78,7 +78,7 @@ def main():
sys.exit(1)

def get_project_type(project_object):
"""Identifies how a project should be handled"""
"""Identifies how a project should be handled."""
name = project_object['name'].strip()
if project['name'] == 'Inbox':
return args.inbox
Expand All @@ -88,7 +88,7 @@ def get_project_type(project_object):
return 'serial'

def get_item_type(item):
"""Identifies how a item with sub items should be handled"""
"""Identifies how a item with sub items should be handled."""
name = item['content'].strip()
if name[-1] == args.parallel_suffix:
return 'parallel'
Expand Down Expand Up @@ -121,6 +121,7 @@ def remove_label(item, label):
if project_type:
logging.debug('Project %s being processed as %s', project['name'], project_type)

# Get all items for the project, sort by the item_order field.
items = sorted(api.items.all(lambda x: x['project_id'] == project['id']), key=lambda x: x['item_order'])

for item in items:
Expand Down Expand Up @@ -165,12 +166,16 @@ def remove_label(item, label):
elif project_type == 'parallel':
add_label(item, label_id)

logging.debug('%d changes queued for sync... commiting if needed', len(api.queue))
if len(api.queue):
logging.debug('%d changes queued for sync... commiting to Todoist.', len(api.queue))
api.commit()
else:
logging.debug('No changes queued, skipping sync.')

# If onetime is set, exit after first execution.
if args.onetime:
break

logging.debug('Sleeping for %d seconds', args.delay)
time.sleep(args.delay)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
todoist-python>=0.2.9
todoist-python==0.2.26
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='NextAction',
version='0.3',
version='0.4',
py_modules=['nextaction'],
url='https://github.com/nikdoof/NextAction',
license='MIT',
Expand All @@ -12,8 +12,8 @@
entry_points={
"console_scripts": [
"nextaction=nextaction:main",
],
},
],
},
install_requires=[
'todoist-python',
]
Expand Down

0 comments on commit c60f1ef

Please sign in to comment.