diff --git a/.github/CONTRIBUTORS.md b/.github/CONTRIBUTORS.md index e1b1c24..12ca11a 100644 --- a/.github/CONTRIBUTORS.md +++ b/.github/CONTRIBUTORS.md @@ -34,6 +34,7 @@ The following people have voluteered to test the beta release (pre-release). Tha | **surak** | [Alexandre Strube](https://github.com/surak) | for various suggestions, PRs | | **Hubert** | Hubert |for extending the events fetcher, adding support for recurring events, date formattings and other code suggestions| | **Crickus** | [Dimka](https://github.com/Crickus) | For helping with adding support for 9.7" E-Paper display| +| **dealyllama** | [dealyllama] () | Tweaked the todoist module to use the new API ## Financial Contributions | Name | Contribution details | diff --git a/inkycal/modules/inkycal_todoist.py b/inkycal/modules/inkycal_todoist.py index 27d4fe7..1ce0df8 100644 --- a/inkycal/modules/inkycal_todoist.py +++ b/inkycal/modules/inkycal_todoist.py @@ -10,7 +10,7 @@ from inkycal.modules.template import inkycal_module from inkycal.custom import * try: - import todoist + from todoist_api_python.api import TodoistAPI except ImportError: print('todoist is not installed! Please install with:') print('pip3 install todoist-python') @@ -59,9 +59,8 @@ class Todoist(inkycal_module): else: self.project_filter = config['project_filter'] - self._api = todoist.TodoistAPI(config['api_key']) - self._api.sync() - + self._api = TodoistAPI(config['api_key']) + # give an OK message print(f'{filename} loaded') @@ -86,7 +85,6 @@ class Todoist(inkycal_module): # Check if internet is available if internet_available() == True: logger.info('Connection test passed') - self._api.sync() else: raise Exception('Network could not be reached :/') @@ -104,8 +102,12 @@ class Todoist(inkycal_module): (0, spacing_top + _ * line_height ) for _ in range(max_lines)] # Get all projects by name and id - all_projects = {project['id']: project['name'] - for project in self._api.projects.all()} + + #all_projects = {project['id']: project['name'] + # for project in self._api.get_projects()} + all_projects = {} + for project in self._api.get_projects(): + all_projects[project.id] = project.name logger.debug(f"all_projects: {all_projects}") @@ -126,22 +128,22 @@ class Todoist(inkycal_module): 'double check spellings in project_filter or leave' 'empty') - # Create single-use generator to filter undone and non-deleted tasks - tasks = (task.data for task in self._api.state['items'] if - task['checked'] == 0 and task['is_deleted']==0) + tasks = (task for task in self._api.get_tasks() if + task.is_completed == False) # Simplify the tasks for faster processing simplified = [ - { - 'name':task['content'], - 'due':task['due']['string'] if task['due'] != None else "", - 'priority':task['priority'], - 'project':all_projects[ task['project_id' ] ] if task['project_id'] in all_projects else "deleted" - } - for task in tasks] + { + 'name':task.content, + 'due':task.due.string if task.due != None else "", + 'priority':task.priority, + 'project':all_projects[ task.project_id ] if task.project_id in all_projects else "deleted" + } + for task in tasks] - # remove groups that have been deleted - simplified = [task for task in simplified if task['project'] != "deleted"] + # remove groups that have been deleted + # - not sure if this is needed anymore or exactly how to do it --dealyllama + #simplified = [task for task in simplified if task.project != "deleted"] logger.debug(f'simplified: {simplified}') @@ -201,4 +203,4 @@ class Todoist(inkycal_module): return im_black, im_colour if __name__ == '__main__': - print(f'running {filename} in standalone/debug mode') + print(f'running {filename} in standalone/debug mode') \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1e49807..46a0fe6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,6 @@ numpy>=1.18.2 # image pre-processing #pre-installed on Raspbia arrow==0.17.0 # time operations Flask==1.1.2 # webserver Flask-WTF==0.14.3 # webforms -todoist-python==8.1.2 # todoist api +todoist_api_python==2.0.2 # new todoist api yfinance>=0.1.62 # yahoo stocks matplotlib==3.4.2 # plotting