Пример #1
0
def do(config):
    emos = obtain_latest_emos_content(config)
    for key in ('custom', 'recuited'):
        if key in emos:
            del emos[key]

    env = Environment(loader=FileSystemLoader(BASE), extensions=['jinja2.ext.autoescape'])
    template = env.get_template('emos-template.html')
    content = template.render(emos=emos, now=datetime.now().strftime('%Y-%m-%d'))

    htmlfile = expanduser(config.get('emos_html', ''))
    try:
        with codecs.open(htmlfile, 'w', 'UTF-8') as f:
            f.write(content)
    except IOError:
        abort('bad config.emos_html: ' + htmlfile)
Пример #2
0
def do(config):
    log_dir = expanduser(config.get('log_dir', ''))
    if not (isdir(log_dir) and os.access(log_dir, os.W_OK)):
        abort('bad config.log_dir: ' + log_dir)

    content_curr = obtain_latest_emos_content(config)
    content_prev = load_saved_content(log_dir)
    if not content_prev:
        save_content(log_dir, content_curr)
        return

    emos_curr = extract_emo_keys(content_curr)
    emos_prev = extract_emo_keys(content_prev)

    added = emos_curr - emos_prev
    deled = emos_prev - emos_curr
    if added or deled:
        print 'added:', added
        print 'deled:', deled
        do_post(config, added, deled)
        save_content(log_dir, content_curr)
Пример #3
0
def do(config):
    log_dir = expanduser(config.get('log_dir', ''))
    if not (isdir(log_dir) and os.access(log_dir, os.W_OK)):
        abort('bad config.log_dir: ' + log_dir)

    content_curr = obtain_latest_emos_content(config)
    content_prev = load_saved_content(log_dir)
    if not content_prev:
        save_content(log_dir, content_curr)
        return

    emos_curr = extract_emo_keys(content_curr)
    emos_prev = extract_emo_keys(content_prev)

    added = emos_curr - emos_prev
    deled = emos_prev - emos_curr
    if added or deled:
        print 'added:', added
        print 'deled:', deled
        do_post(config, added, deled)
        save_content(log_dir, content_curr)