bump requirements and adapt todoist module accordingly
This commit is contained in:
		| @@ -111,6 +111,10 @@ class Feeds(inkycal_module): | ||||
|                 if "summary" in posts: | ||||
|                     summary = posts["summary"] | ||||
|                     parsed_feeds.append(f"•{posts.title}: {re.sub('<[^<]+?>', '', posts.summary)}") | ||||
|                 # if "description" in posts: | ||||
|  | ||||
|         parsed_feeds = [i.split("\n") for i in parsed_feeds][0] | ||||
|         parsed_feeds = [i for i in parsed_feeds if i] | ||||
|  | ||||
|         self._parsed_feeds = parsed_feeds | ||||
|  | ||||
|   | ||||
| @@ -1,14 +1,15 @@ | ||||
| #!python3 | ||||
|  | ||||
| """ | ||||
| todoist module for Inky-Calendar Project | ||||
| Inkycal Todoist Module | ||||
| Copyright by aceisace | ||||
| """ | ||||
|  | ||||
| from inkycal.modules.template import inkycal_module | ||||
| from inkycal.custom import * | ||||
|  | ||||
| import todoist | ||||
| from todoist_api_python.api_async import TodoistAPIAsync | ||||
| from todoist_api_python.api import TodoistAPI | ||||
|  | ||||
| filename = os.path.basename(__file__).split('.py')[0] | ||||
| logger = logging.getLogger(filename) | ||||
| @@ -16,7 +17,7 @@ logger = logging.getLogger(filename) | ||||
|  | ||||
| class Todoist(inkycal_module): | ||||
|     """Todoist api class | ||||
|     parses todos from api-key | ||||
|     parses todo's from api-key | ||||
|     """ | ||||
|  | ||||
|     name = "Todoist API - show your todos from todoist" | ||||
| @@ -55,8 +56,7 @@ 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') | ||||
| @@ -82,7 +82,6 @@ class Todoist(inkycal_module): | ||||
|         # Check if internet is available | ||||
|         if internet_available(): | ||||
|             logger.info('Connection test passed') | ||||
|             self._api.sync() | ||||
|         else: | ||||
|             raise NetworkNotReachableError | ||||
|  | ||||
| @@ -100,44 +99,40 @@ 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 = self._api.get_projects() | ||||
|         filtered_project_ids_and_names = {project.id: project.name for project in all_projects} | ||||
|         all_active_tasks = self._api.get_tasks() | ||||
|  | ||||
|         logger.debug(f"all_projects: {all_projects}") | ||||
|  | ||||
|         # Filter entries in all_projects if filter was given | ||||
|         if self.project_filter: | ||||
|             for project_id in list(all_projects): | ||||
|                 if all_projects[project_id] not in self.project_filter: | ||||
|                     del all_projects[project_id] | ||||
|             filtered_projects = [project for project in all_projects if project.name in self.project_filter] | ||||
|             filtered_project_ids_and_names = {project.id: project.name for project in filtered_projects} | ||||
|             filtered_project_ids = [project for project in filtered_project_ids_and_names] | ||||
|             logger.debug(f"filtered projects: {filtered_projects}") | ||||
|  | ||||
|             logger.debug(f"all_project: {all_projects}") | ||||
|  | ||||
|             # If filter was activated and no roject was found with that name, | ||||
|             # If filter was activated and no project was found with that name, | ||||
|             # raise an exception to avoid showing a blank image | ||||
|             if all_projects == {}: | ||||
|             if not filtered_projects: | ||||
|                 logger.error('No project found from project filter!') | ||||
|                 logger.error('Please double check spellings in project_filter') | ||||
|                 raise Exception('No matching project found in filter. Please ' | ||||
|                                 '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) | ||||
|             # filtered version of all active tasks | ||||
|             all_active_tasks = [task for task in all_active_tasks if task.project_id in filtered_project_ids] | ||||
|  | ||||
|         # Simplify the tasks for faster processing | ||||
|         simplified = [ | ||||
|             { | ||||
|                 'name': task['content'], | ||||
|                 'due': task['due']['string'] if task['due'] is not None else "", | ||||
|                 'priority': task['priority'], | ||||
|                 'project': all_projects[task['project_id']] if task['project_id'] in all_projects else "deleted" | ||||
|                 'name': task.content, | ||||
|                 'due': task.due, | ||||
|                 'priority': task.priority, | ||||
|                 'project': filtered_project_ids_and_names[task.project_id] | ||||
|             } | ||||
|             for task in tasks] | ||||
|  | ||||
|         # remove groups that have been deleted | ||||
|         simplified = [task for task in simplified if task['project'] != "deleted"] | ||||
|             for task in all_active_tasks | ||||
|         ] | ||||
|  | ||||
|         logger.debug(f'simplified: {simplified}') | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ feedparser==6.0.8 | ||||
| fonttools==4.32.0 | ||||
| geojson==2.5.0 | ||||
| icalendar==4.0.9 | ||||
| idna==3.3 | ||||
| kiwisolver==1.4.2 | ||||
| lxml==4.8.0 | ||||
| matplotlib==3.5.1 | ||||
| @@ -14,7 +13,7 @@ multitasking==0.0.10 | ||||
| numpy==1.22.3 | ||||
| packaging==21.3 | ||||
| pandas==1.3.5 | ||||
| Pillow==9.1.0 | ||||
| Pillow==9.2.0 | ||||
| pyowm==3.3.0 | ||||
| pyparsing==3.0.7 | ||||
| PySocks==1.7.1 | ||||
| @@ -26,7 +25,7 @@ RPi.GPIO==0.7.1 | ||||
| sgmllib3k==1.0.0 | ||||
| six==1.16.0 | ||||
| spidev==3.5 | ||||
| todoist-python==8.1.3 | ||||
| todoist-api-python==2.0.0 | ||||
| typing_extensions==4.1.1 | ||||
| urllib3==1.26.9 | ||||
| yfinance==0.1.70 | ||||
		Reference in New Issue
	
	Block a user