fix parser
This commit is contained in:
13
parse.py
13
parse.py
@@ -2,7 +2,6 @@ from pathlib import Path
|
||||
from datetime import datetime
|
||||
import re
|
||||
import json
|
||||
from functools import reduce
|
||||
|
||||
entry_re = re.compile(r'^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})', re.MULTILINE)
|
||||
|
||||
@@ -20,9 +19,21 @@ def parse_habits(habits):
|
||||
result[name] = value[1] == 'x'
|
||||
return result
|
||||
|
||||
def parse_notifications(notifications):
|
||||
result = []
|
||||
for notification in notifications.splitlines():
|
||||
parts = notification.split()
|
||||
result.append({
|
||||
'source': ' '.join(parts[0:2]).strip('[]'),
|
||||
'message': ' '.join(parts[2:]),
|
||||
})
|
||||
return result
|
||||
|
||||
|
||||
header_modules = {
|
||||
'godword': parse_godword,
|
||||
'habits': parse_habits,
|
||||
'notifications': parse_notifications,
|
||||
}
|
||||
|
||||
def parse_header(header):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from datetime import datetime
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
Reference in New Issue
Block a user