Compare commits
No commits in common. "b12f64a0fac9a8263274c68b956c7c401f10eb11" and "c8c142bd1b06588126aa957ad76b42327165f4e7" have entirely different histories.
b12f64a0fa
...
c8c142bd1b
|
@ -99,10 +99,6 @@ def import_step_counts_csv(vault: ObsidianVault, rows: Rows) -> int:
|
||||||
|
|
||||||
return num_updated
|
return num_updated
|
||||||
|
|
||||||
def escape_for_obsidian_link(link: str) -> str:
|
|
||||||
return link.replace(':', ' ').replace('/', ' ').replace(' ', ' ')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def import_watched_series_csv(vault: ObsidianVault, rows: Rows) -> int:
|
def import_watched_series_csv(vault: ObsidianVault, rows: Rows) -> int:
|
||||||
verb = 'Watched'
|
verb = 'Watched'
|
||||||
|
@ -118,7 +114,6 @@ def import_watched_series_csv(vault: ObsidianVault, rows: Rows) -> int:
|
||||||
del rows
|
del rows
|
||||||
|
|
||||||
def map_to_event(sample: RealizedActivitySample) -> Event:
|
def map_to_event(sample: RealizedActivitySample) -> Event:
|
||||||
noun = escape_for_obsidian_link(sample.single_label_with_category('series.name'))
|
|
||||||
comment = '{} Episode {}: *{}*'.format(
|
comment = '{} Episode {}: *{}*'.format(
|
||||||
sample.single_label_with_category('season.name'),
|
sample.single_label_with_category('season.name'),
|
||||||
sample.single_label_with_category('episode.index'),
|
sample.single_label_with_category('episode.index'),
|
||||||
|
@ -128,7 +123,7 @@ def import_watched_series_csv(vault: ObsidianVault, rows: Rows) -> int:
|
||||||
return Event(sample.start_at.astimezone(expected_tz).replace(second=0,microsecond=0).time(),
|
return Event(sample.start_at.astimezone(expected_tz).replace(second=0,microsecond=0).time(),
|
||||||
sample.end_at.astimezone(expected_tz).replace(second=0,microsecond=0).time(),
|
sample.end_at.astimezone(expected_tz).replace(second=0,microsecond=0).time(),
|
||||||
verb,
|
verb,
|
||||||
noun,
|
sample.single_label_with_category('series.name'),
|
||||||
comment,
|
comment,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,10 @@ StatisticKey = str
|
||||||
class Event:
|
class Event:
|
||||||
start_time: datetime.time | None
|
start_time: datetime.time | None
|
||||||
end_time: datetime.time | None
|
end_time: datetime.time | None
|
||||||
verb: str | None
|
verb: str
|
||||||
subject: str | None
|
subject: str
|
||||||
comment: str
|
comment: str
|
||||||
|
|
||||||
def __post_init__(self):
|
|
||||||
if self.subject:
|
|
||||||
assert ':' not in self.subject
|
|
||||||
assert '/' not in self.subject
|
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class FileContents:
|
class FileContents:
|
||||||
|
@ -231,8 +226,8 @@ def format_event_string(event: Event) -> str:
|
||||||
|
|
||||||
RE_TIME = r'(\d\d:\d\d(?::\d\d(?:\.\d+?))?)'
|
RE_TIME = r'(\d\d:\d\d(?::\d\d(?:\.\d+?))?)'
|
||||||
RE_VERB = r'(\w+(?:ed|te))'
|
RE_VERB = r'(\w+(?:ed|te))'
|
||||||
RE_LINK_MD = r'\[([^\]:/]*)\]\(?:[^)]*\)'
|
RE_LINK_MD = r'\[([^\]]*)\]\(?:[^)]*\)'
|
||||||
RE_LINK_WIKI = r'\[\[([^\]:/]*)\]\]'
|
RE_LINK_WIKI = r'\[\[([^\]]*)\]\]'
|
||||||
|
|
||||||
RE_TIME_FORMAT = RE_TIME + r'(?:\s*\-\s*' + RE_TIME + r')?'
|
RE_TIME_FORMAT = RE_TIME + r'(?:\s*\-\s*' + RE_TIME + r')?'
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = '0.1.47'
|
__version__ = '0.1.46'
|
||||||
|
|
|
@ -10,7 +10,6 @@ EXAMPLES = [
|
||||||
obsidian.Event(datetime.time(20, 0, 0), datetime.time(22, 0, 0),
|
obsidian.Event(datetime.time(20, 0, 0), datetime.time(22, 0, 0),
|
||||||
"Watched", "Tom and Jerry", "on the *Television*"),
|
"Watched", "Tom and Jerry", "on the *Television*"),
|
||||||
obsidian.Event(None, None, None, None, "Took a walk"),
|
obsidian.Event(None, None, None, None, "Took a walk"),
|
||||||
obsidian.Event(None, None, None, None, "Watched [[Cyberpunk: Edgerunners]]."),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@pytest.mark.parametrize("event", EXAMPLES)
|
@pytest.mark.parametrize("event", EXAMPLES)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user