1
0
This commit is contained in:
Jon Michael Aanes 2024-10-01 16:15:03 +02:00
parent af65179f2d
commit 4a9f0fba8f
3 changed files with 14 additions and 7 deletions

View File

@ -12,14 +12,14 @@ import requests
from .favro_data_model import ( from .favro_data_model import (
Card, Card,
CardId, CardId,
CustomFieldId,
CustomFieldInfo,
OrganizationId, OrganizationId,
SeqId, SeqId,
TagId, TagId,
TagInfo, TagInfo,
UserId, UserId,
UserInfo, UserInfo,
CustomFieldId,
CustomFieldInfo,
) )
from .favro_markdown import CardContents from .favro_markdown import CardContents
@ -112,7 +112,10 @@ class FavroClient:
while page < num_pages: while page < num_pages:
# Determine params for get_cards # Determine params for get_cards
request = self._get_cards_request( request = self._get_cards_request(
seq_id, todo_list, page=page, request_id=request_id seq_id,
todo_list,
page=page,
request_id=request_id,
) )
# Run query # Run query
@ -171,7 +174,7 @@ class FavroClient:
def get_custom_field(self, tag_id: CustomFieldId) -> CustomFieldInfo: def get_custom_field(self, tag_id: CustomFieldId) -> CustomFieldInfo:
response = self.session.get( response = self.session.get(
URL_GET_CUSTOM_FIELD.format(custom_field_id=custom_field_id.raw_id) URL_GET_CUSTOM_FIELD.format(custom_field_id=custom_field_id.raw_id),
) )
return CustomFieldInfo.from_json(response.json()) return CustomFieldInfo.from_json(response.json())

View File

@ -210,7 +210,8 @@ class Card:
tags=[TagId(tag) for tag in json['tags']], tags=[TagId(tag) for tag in json['tags']],
creator_user_id=UserId(json['createdByUserId']), creator_user_id=UserId(json['createdByUserId']),
creation_date=map_opt( creation_date=map_opt(
datetime.datetime.fromisoformat, json.get('createdAt') datetime.datetime.fromisoformat,
json.get('createdAt'),
), ),
start_date=map_opt(datetime.datetime.fromisoformat, json.get('startDate')), start_date=map_opt(datetime.datetime.fromisoformat, json.get('startDate')),
due_date=map_opt(datetime.datetime.fromisoformat, json.get('dueDate')), due_date=map_opt(datetime.datetime.fromisoformat, json.get('dueDate')),

View File

@ -1,6 +1,6 @@
import dataclasses import dataclasses
import re
import datetime import datetime
import re
import frontmatter import frontmatter
import marko import marko
@ -113,7 +113,10 @@ class CardFileFormatter:
if description := card.description: if description := card.description:
if self.obsidian_mode: if self.obsidian_mode:
description = re.sub( description = re.sub(
r'\-\s*\[\s*\]', '- [ ]', description, flags=re.MULTILINE r'\-\s*\[\s*\]',
'- [ ]',
description,
flags=re.MULTILINE,
) )
ls.append(description) ls.append(description)
del description del description