1
0

Compare commits

...

3 Commits

Author SHA1 Message Date
b12f64a0fa 🤖 Bumped version to 0.1.47
Some checks failed
Build Python Container / Package-Container (push) Successful in 1m31s
Package Python / Package (push) Successful in 25s
Test Python / Test (push) Failing after 30s
This commit was automatically generated by a script: https://gitfub.space/Jmaa/repo-manager
2024-10-20 18:41:41 +02:00
e7c2ea6972
Data improvements 2024-10-20 18:27:32 +02:00
9ee3113da2 🤖 Repository layout updated to latest version
This commit was automatically generated by a script: https://gitfub.space/Jmaa/repo-manager
2024-10-20 17:59:22 +02:00
4 changed files with 17 additions and 6 deletions

View File

@ -99,6 +99,10 @@ def import_step_counts_csv(vault: ObsidianVault, rows: Rows) -> int:
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:
verb = 'Watched'
@ -114,6 +118,7 @@ def import_watched_series_csv(vault: ObsidianVault, rows: Rows) -> int:
del rows
def map_to_event(sample: RealizedActivitySample) -> Event:
noun = escape_for_obsidian_link(sample.single_label_with_category('series.name'))
comment = '{} Episode {}: *{}*'.format(
sample.single_label_with_category('season.name'),
sample.single_label_with_category('episode.index'),
@ -123,7 +128,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(),
sample.end_at.astimezone(expected_tz).replace(second=0,microsecond=0).time(),
verb,
sample.single_label_with_category('series.name'),
noun,
comment,
)

View File

@ -20,10 +20,15 @@ StatisticKey = str
class Event:
start_time: datetime.time | None
end_time: datetime.time | None
verb: str
subject: str
verb: str | None
subject: str | None
comment: str
def __post_init__(self):
if self.subject:
assert ':' not in self.subject
assert '/' not in self.subject
@dataclasses.dataclass(frozen=True)
class FileContents:
@ -226,8 +231,8 @@ def format_event_string(event: Event) -> str:
RE_TIME = r'(\d\d:\d\d(?::\d\d(?:\.\d+?))?)'
RE_VERB = r'(\w+(?:ed|te))'
RE_LINK_MD = r'\[([^\]]*)\]\(?:[^)]*\)'
RE_LINK_WIKI = r'\[\[([^\]]*)\]\]'
RE_LINK_MD = r'\[([^\]:/]*)\]\(?:[^)]*\)'
RE_LINK_WIKI = r'\[\[([^\]:/]*)\]\]'
RE_TIME_FORMAT = RE_TIME + r'(?:\s*\-\s*' + RE_TIME + r')?'

View File

@ -1 +1 @@
__version__ = '0.1.46'
__version__ = '0.1.47'

View File

@ -10,6 +10,7 @@ EXAMPLES = [
obsidian.Event(datetime.time(20, 0, 0), datetime.time(22, 0, 0),
"Watched", "Tom and Jerry", "on the *Television*"),
obsidian.Event(None, None, None, None, "Took a walk"),
obsidian.Event(None, None, None, None, "Watched [[Cyberpunk: Edgerunners]]."),
]
@pytest.mark.parametrize("event", EXAMPLES)