Merge pull request #224 from dealyllama/hotfix/todoist-api-fix-deprecation
Update inkycal_todoist.py
This commit is contained in:
commit
5f99291706
1
.github/CONTRIBUTORS.md
vendored
1
.github/CONTRIBUTORS.md
vendored
@ -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 |
|
| **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|
|
| **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|
|
| **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
|
## Financial Contributions
|
||||||
| Name | Contribution details |
|
| Name | Contribution details |
|
||||||
|
@ -10,7 +10,7 @@ from inkycal.modules.template import inkycal_module
|
|||||||
from inkycal.custom import *
|
from inkycal.custom import *
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import todoist
|
from todoist_api_python.api import TodoistAPI
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print('todoist is not installed! Please install with:')
|
print('todoist is not installed! Please install with:')
|
||||||
print('pip3 install todoist-python')
|
print('pip3 install todoist-python')
|
||||||
@ -59,9 +59,8 @@ class Todoist(inkycal_module):
|
|||||||
else:
|
else:
|
||||||
self.project_filter = config['project_filter']
|
self.project_filter = config['project_filter']
|
||||||
|
|
||||||
self._api = todoist.TodoistAPI(config['api_key'])
|
self._api = TodoistAPI(config['api_key'])
|
||||||
self._api.sync()
|
|
||||||
|
|
||||||
# give an OK message
|
# give an OK message
|
||||||
print(f'{filename} loaded')
|
print(f'{filename} loaded')
|
||||||
|
|
||||||
@ -86,7 +85,6 @@ class Todoist(inkycal_module):
|
|||||||
# Check if internet is available
|
# Check if internet is available
|
||||||
if internet_available() == True:
|
if internet_available() == True:
|
||||||
logger.info('Connection test passed')
|
logger.info('Connection test passed')
|
||||||
self._api.sync()
|
|
||||||
else:
|
else:
|
||||||
raise Exception('Network could not be reached :/')
|
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)]
|
(0, spacing_top + _ * line_height ) for _ in range(max_lines)]
|
||||||
|
|
||||||
# Get all projects by name and id
|
# 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}")
|
logger.debug(f"all_projects: {all_projects}")
|
||||||
|
|
||||||
@ -126,22 +128,22 @@ class Todoist(inkycal_module):
|
|||||||
'double check spellings in project_filter or leave'
|
'double check spellings in project_filter or leave'
|
||||||
'empty')
|
'empty')
|
||||||
|
|
||||||
# Create single-use generator to filter undone and non-deleted tasks
|
tasks = (task for task in self._api.get_tasks() if
|
||||||
tasks = (task.data for task in self._api.state['items'] if
|
task.is_completed == False)
|
||||||
task['checked'] == 0 and task['is_deleted']==0)
|
|
||||||
|
|
||||||
# Simplify the tasks for faster processing
|
# Simplify the tasks for faster processing
|
||||||
simplified = [
|
simplified = [
|
||||||
{
|
{
|
||||||
'name':task['content'],
|
'name':task.content,
|
||||||
'due':task['due']['string'] if task['due'] != None else "",
|
'due':task.due.string if task.due != None else "",
|
||||||
'priority':task['priority'],
|
'priority':task.priority,
|
||||||
'project':all_projects[ task['project_id' ] ] if task['project_id'] in all_projects else "deleted"
|
'project':all_projects[ task.project_id ] if task.project_id in all_projects else "deleted"
|
||||||
}
|
}
|
||||||
for task in tasks]
|
for task in tasks]
|
||||||
|
|
||||||
# remove groups that have been deleted
|
# remove groups that have been deleted
|
||||||
simplified = [task for task in simplified if task['project'] != "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}')
|
logger.debug(f'simplified: {simplified}')
|
||||||
|
|
||||||
@ -201,4 +203,4 @@ class Todoist(inkycal_module):
|
|||||||
return im_black, im_colour
|
return im_black, im_colour
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(f'running {filename} in standalone/debug mode')
|
print(f'running {filename} in standalone/debug mode')
|
@ -7,6 +7,6 @@ numpy>=1.18.2 # image pre-processing #pre-installed on Raspbia
|
|||||||
arrow==0.17.0 # time operations
|
arrow==0.17.0 # time operations
|
||||||
Flask==1.1.2 # webserver
|
Flask==1.1.2 # webserver
|
||||||
Flask-WTF==0.14.3 # webforms
|
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
|
yfinance>=0.1.62 # yahoo stocks
|
||||||
matplotlib==3.4.2 # plotting
|
matplotlib==3.4.2 # plotting
|
||||||
|
Loading…
Reference in New Issue
Block a user