test passing!
This commit is contained in:
18
parse.py
18
parse.py
@@ -1,4 +1,3 @@
|
||||
import enum
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
import re
|
||||
@@ -64,7 +63,8 @@ def parse_timestamp(timestamp):
|
||||
return datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S')
|
||||
|
||||
def parse_post(block):
|
||||
block = block.removeprefix('@post ')
|
||||
block = block.removeprefix('@post').strip()
|
||||
|
||||
try:
|
||||
timestamp = int(parse_timestamp(block[:19]).timestamp())
|
||||
block = block[19:]
|
||||
@@ -117,8 +117,18 @@ def parse_exercise(block):
|
||||
'distance': float(distance.removesuffix('km')),
|
||||
'steps': int(steps.removesuffix('steps')),
|
||||
}
|
||||
|
||||
elif parts[0] == 'calisthenics':
|
||||
kind, split, exercise = parts
|
||||
sets, reps = split.split('x')
|
||||
return {
|
||||
'kind': kind,
|
||||
'reps': reps,
|
||||
'sets': sets,
|
||||
'exercise': exercise,
|
||||
}
|
||||
|
||||
return {'kind': 'INVALID'}
|
||||
assert False
|
||||
|
||||
def parse_notify(block):
|
||||
tag, day, *rest = block.split()
|
||||
@@ -261,6 +271,8 @@ def parse_entry(entry):
|
||||
partial(merge_chars, '\n'),
|
||||
# attach escaped tag symbols
|
||||
partial(attach_to_prev_if, lambda p, c: c == '@' and p[-1] == '\\'),
|
||||
# ?????
|
||||
partial(attach_to_prev_if, lambda p, c: p.endswith('\\@')),
|
||||
# attach tag symbols
|
||||
partial(attach_to_next, '@'),
|
||||
# ???
|
||||
|
||||
Reference in New Issue
Block a user