mirror of
https://github.com/nikdoof/NextAction.git
synced 2025-12-26 16:59:23 +00:00
Compare commits
5 Commits
support/0.
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
| 73361c7f89 | |||
| fa757f33d1 | |||
| 52ad1ea908 | |||
| 7a24f83827 | |||
| 3bdf35c1f4 |
@@ -48,6 +48,7 @@ def main():
|
||||
parser.add_argument('--hide_future', help='Hide future dated next actions until the specified number of days',
|
||||
default=7, type=int)
|
||||
parser.add_argument('--onetime', help='Update Todoist once and exit', action='store_true')
|
||||
parser.add_argument('--nocache', help='Disables caching data to disk for quicker syncing', action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Set debug
|
||||
@@ -64,9 +65,15 @@ def main():
|
||||
|
||||
# Run the initial sync
|
||||
logging.debug('Connecting to the Todoist API')
|
||||
api = TodoistAPI(token=args.api_key)
|
||||
|
||||
api_arguments = {'token': args.api_key}
|
||||
if args.nocache:
|
||||
logging.debug('Disabling local caching')
|
||||
api_arguments['cache'] = None
|
||||
|
||||
api = TodoistAPI(**api_arguments)
|
||||
logging.debug('Syncing the current state from the API')
|
||||
api.sync(resource_types=['projects', 'labels', 'items'])
|
||||
api.sync()
|
||||
|
||||
# Check the next action label exists
|
||||
labels = api.labels.all(lambda x: x['name'] == args.label)
|
||||
@@ -80,7 +87,7 @@ def main():
|
||||
def get_project_type(project_object):
|
||||
"""Identifies how a project should be handled."""
|
||||
name = project_object['name'].strip()
|
||||
if project['name'] == 'Inbox':
|
||||
if name == 'Inbox':
|
||||
return args.inbox
|
||||
elif name[-1] == args.parallel_suffix:
|
||||
return 'parallel'
|
||||
@@ -112,7 +119,7 @@ def main():
|
||||
# Main loop
|
||||
while True:
|
||||
try:
|
||||
api.sync(resource_types=['projects', 'labels', 'items'])
|
||||
api.sync()
|
||||
except Exception as e:
|
||||
logging.exception('Error trying to sync with Todoist API: %s' % str(e))
|
||||
else:
|
||||
@@ -142,9 +149,11 @@ def main():
|
||||
if item_type or len(child_items) > 0:
|
||||
# Process serial tagged items
|
||||
if item_type == 'serial':
|
||||
for idx, child_item in enumerate(child_items):
|
||||
if idx == 0:
|
||||
for child_item in child_items:
|
||||
first_found = False
|
||||
if child_item['checked'] == 0 and not first_found:
|
||||
add_label(child_item, label_id)
|
||||
first_found = True
|
||||
else:
|
||||
remove_label(child_item, label_id)
|
||||
# Process parallel tagged items or untagged parents
|
||||
|
||||
@@ -1 +1 @@
|
||||
todoist-python==0.2.26
|
||||
todoist-python>=7.0.10,<8.0.0
|
||||
Reference in New Issue
Block a user