Ejemplo n.º 1
0
def munge(dct: Dict) -> AttrDict:
    dct = AttrDict(**dct)
    if 'start' in dct:
        dct.start = parse_datetime(dct.start)
    if 'end' in dct:
        dct.end = parse_datetime(dct.end)
    return dct
Ejemplo n.º 2
0
def munge(dct: Dict[str, str]) -> AttrDict:
    dct = AttrDict(**dct)
    if 'text' in dct:
        dct.text = html.escape(dct.text)
        for pat, repl in HTML_FILTERS.items():
            dct.text = pat.sub(repl, dct.text)
        for pat, repl in ABBREVS.items():
            dct.text = pat.sub(repl, dct.text)
        dct.text = dct.text.replace('\N{STX}', '<').replace('\N{ETX}', '>')
    if 'timestamp' in dct:
        dct.timestamp = parse_rfc3339(dct.timestamp)
    if 'self' in dct:
        dct.self = parse_rfc3339(dct.self)
    return dct
Ejemplo n.º 3
0
with open('data/µnotes.json') as f:
    notes = json.load(f, object_hook=AttrDict)

with open('data/config.json') as f:
    config = json.load(f, object_hook=AttrDict)

feed = AttrDict(
    version='https://jsonfeed.org/version/1.1',
    title='James Rowe',
    icon='https://micro.blog/JNRowe/avatar.jpg',
    home_page_url='https://jnrowe.github.com/mnotes/',
    feed_url='https://jnrowe.github.com/mnotes/feed.json',
    description=config.subtitle,
    authors=[
        {
            'name': config.author.name,
            'url': config.author.uri,
            'avatar': 'https://jnrowe.github.com/mnotes/avatar.png',
        },
    ],
    language='en',
    items=[]
)

for note, post in list(zip(reversed(notes),
                           page.getroot().cssselect('.note')))[:15]:
    loc = '%s#TS%s' % (config.url, note.timestamp)
    content = html.tostring(post, True).decode()
    content = content.strip().replace('\n', '')
    item = AttrDict(