Compare commits
No commits in common. "e61e0ef34d70e9c768adde7bbf5e0e4d1fc7b0b1" and "fb7c53b3ae2a7b8bbb7f6fc4d3d5fed31b501af6" have entirely different histories.
e61e0ef34d
...
fb7c53b3ae
|
@ -1 +1 @@
|
|||
__version__ = '0.1.9'
|
||||
__version__ = '0.1.8'
|
||||
|
|
|
@ -125,8 +125,7 @@ class FavroClient:
|
|||
yield from self._get_paginated(request, Collection.from_json)
|
||||
|
||||
def _get_cards_prepared_request(
|
||||
self,
|
||||
**kwargs,
|
||||
self, **kwargs,
|
||||
) -> requests.PreparedRequest:
|
||||
request = self._get_cards_request(**kwargs)
|
||||
return self.session.prepare_request(request)
|
||||
|
@ -229,9 +228,7 @@ class FavroClient:
|
|||
self._invalidate_cache(card_id)
|
||||
return self.update_card_contents_locally(card_id, card_contents)
|
||||
|
||||
def _get_paginated(
|
||||
self, base_request: requests.Request, entity_from_json,
|
||||
) -> Iterator:
|
||||
def _get_paginated(self, base_request: requests.Request, entity_from_json) -> Iterator:
|
||||
page = 0
|
||||
request_id = None
|
||||
num_pages = 1
|
||||
|
|
|
@ -163,9 +163,7 @@ class CustomFieldInfo:
|
|||
enabled: bool
|
||||
custom_field_items: list[CustomFieldItem]
|
||||
|
||||
def get_field_item(
|
||||
self, field_item_id: CustomFieldItemId,
|
||||
) -> CustomFieldItem | None:
|
||||
def get_field_item(self, field_item_id: CustomFieldItemId) -> CustomFieldItem | None:
|
||||
for item in self.custom_field_items:
|
||||
if item.custom_field_item_id == field_item_id:
|
||||
return item
|
||||
|
@ -180,9 +178,7 @@ class CustomFieldInfo:
|
|||
type=json['type'],
|
||||
name=json['name'],
|
||||
enabled=json['enabled'],
|
||||
custom_field_items=[
|
||||
CustomFieldItem.from_json(f) for f in json.get('customFieldItems', [])
|
||||
],
|
||||
custom_field_items=[CustomFieldItem.from_json(f) for f in json.get('customFieldItems', [])],
|
||||
)
|
||||
|
||||
|
||||
|
@ -247,7 +243,6 @@ class Task:
|
|||
position=json['position'],
|
||||
)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Collection:
|
||||
collection_id: CollectionId
|
||||
|
@ -272,7 +267,6 @@ class Collection:
|
|||
widget_common_id=map_opt(WidgetCommonId,json.get('widgetCommonId')),
|
||||
)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Card:
|
||||
card_id: CardId
|
||||
|
|
|
@ -8,13 +8,7 @@ from logging import getLogger
|
|||
import fuse
|
||||
|
||||
from .favro_client import FavroClient
|
||||
from .favro_data_model import (
|
||||
Card,
|
||||
CustomField,
|
||||
CustomFieldInfo,
|
||||
CustomFieldItemId,
|
||||
SeqId,
|
||||
)
|
||||
from .favro_data_model import Card, SeqId, CustomFieldInfo, CustomFieldItemId, CustomField
|
||||
from .favro_markdown import CardContents, CardFileFormatter
|
||||
|
||||
################################################################################
|
||||
|
@ -32,7 +26,6 @@ CARD_FILENAME_REGEX = r'^PAR\-(\d+)\.md$'
|
|||
################################################################################
|
||||
# Formatting
|
||||
|
||||
|
||||
def to_custom_field_value(custom_field: CustomField, field_def: CustomFieldInfo) -> str:
|
||||
value: CustomFieldItemId | list[CustomFieldItemId] = custom_field.value
|
||||
if field_def.type in {'Single select','Multiple select'}:
|
||||
|
@ -43,18 +36,14 @@ def to_custom_field_value(custom_field: CustomField, field_def: CustomFieldInfo)
|
|||
return custom_field.color
|
||||
assert False, 'Unknown type: ' + field_def.type
|
||||
|
||||
|
||||
def to_custom_fields(card: Card, favro_client: FavroClient) -> dict[str,str]:
|
||||
custom_fields = {}
|
||||
for field_assignment in card.custom_fields:
|
||||
field_def = favro_client.get_custom_field(field_assignment.custom_field_id)
|
||||
custom_fields[field_def.name] = to_custom_field_value(
|
||||
field_assignment, field_def,
|
||||
)
|
||||
custom_fields[field_def.name] = to_custom_field_value(field_assignment, field_def)
|
||||
del field_assignment
|
||||
return custom_fields
|
||||
|
||||
|
||||
def to_card_contents(card: Card, favro_client: FavroClient) -> str:
|
||||
tags = [favro_client.get_tag(tag_id).name for tag_id in card.tags]
|
||||
assignments = [
|
||||
|
@ -89,7 +78,6 @@ def to_card_contents(card: Card, favro_client: FavroClient) -> str:
|
|||
################################################################################
|
||||
# FUSE
|
||||
|
||||
|
||||
class FavroStat(fuse.Stat):
|
||||
def __init__(self):
|
||||
self.st_mode = 0
|
||||
|
@ -111,11 +99,11 @@ class FileSystemItem:
|
|||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class RootFileSystemItem(FileSystemItem):
|
||||
|
||||
@staticmethod
|
||||
def from_path_segment(segment: str) -> 'RootFileSystemItem':
|
||||
return RootFileSystemItem()
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class OrganizationFileSystemItem(FileSystemItem):
|
||||
name: str
|
||||
|
@ -136,9 +124,7 @@ class CardFileSystemItem(FileSystemItem):
|
|||
return None
|
||||
|
||||
|
||||
def path_to_file_system_item(
|
||||
path_str: str, path_components: list[type[FileSystemItem]],
|
||||
) -> FileSystemItem | None:
|
||||
def path_to_file_system_item(path_str: str, path_components: list[type[FileSystemItem]]) -> FileSystemItem | None:
|
||||
path = re.findall(r'[^/]+', path_str)
|
||||
component = path_components[len(path)]
|
||||
return component.from_path_segment(path[-1] if path else None)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
import requests_cache
|
||||
|
||||
import requests_cache
|
||||
from favro_sync import secrets
|
||||
from favro_sync.favro_client import FavroClient, OrganizationId, SeqId
|
||||
|
||||
|
@ -50,7 +50,6 @@ def test_get_cards():
|
|||
for card in client.get_cards(todo_list=True):
|
||||
assert_valid_card(card)
|
||||
|
||||
|
||||
@needs_secrets
|
||||
def test_get_collections():
|
||||
client = create_client()
|
||||
|
@ -63,7 +62,6 @@ def test_get_collections():
|
|||
assert collection.is_archived is not None
|
||||
assert collection.widget_common_id is None
|
||||
|
||||
|
||||
def create_client():
|
||||
session = requests_cache.CachedSession('output/test-http-cache.sqlite')
|
||||
return FavroClient(
|
||||
|
|
Loading…
Reference in New Issue
Block a user