initial
This commit is contained in:
parent
3b8b69d71e
commit
fd2715ab74
1 changed files with 33 additions and 0 deletions
|
@ -0,0 +1,33 @@
|
|||
from functools import lru_cache
|
||||
from kython import listdir_abs, json_load, JSONType
|
||||
from typing import Dict, List, NamedTuple
|
||||
from pytz import UTC
|
||||
from datetime import datetime
|
||||
import os
|
||||
|
||||
# TODO maybe, it should generate some kind of html snippet?
|
||||
|
||||
|
||||
_PATH = '/L/backups/hypothesis/'
|
||||
|
||||
class Hypothesis(NamedTuple):
|
||||
dt: datetime
|
||||
text: str
|
||||
tag: str
|
||||
|
||||
# TODO guarantee order?
|
||||
def _iter():
|
||||
last = max(listdir_abs(_PATH))
|
||||
j: JSONType
|
||||
with open(last, 'r') as fo:
|
||||
j = json_load(fo)
|
||||
for i in j:
|
||||
dts = i['created']
|
||||
title = ' '.join(i['document']['title'])
|
||||
dt = datetime.strptime(dts[:-3] + dts[-2:], '%Y-%m-%dT%H:%M:%S.%f%z')
|
||||
yield Hypothesis(dt, title, 'hyp')
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def get_entries():
|
||||
return list(_iter())
|
Loading…
Add table
Reference in a new issue