def run(conf, env, options): """Subcommand: info -- a short overview of a blog.""" limit = options.max if options.max > 0 else 5 entrylist = sorted( [ Entry(e, conf) for e in utils.filelist(conf["content_dir"], conf.get("entries_ignore", [])) if utils.istext(e) ], key=lambda k: k.date, reverse=True, ) print print "acrylamid", blue(env["version"]) + ",", print "cache size:", blue("%0.2f" % (cache.size / 1024.0 ** 2)) + " mb" print for entry in entrylist[:limit]: print " ", green(ago(entry.date).ljust(13)), print white(entry.title) if entry.draft else entry.title print print "%s published," % blue(len([e for e in entrylist if not e.draft])), print "%s drafted articles" % blue(len([e for e in entrylist if e.draft])) time = localtime(getmtime(join(conf.get("cache_dir", ".cache/"), "info"))) print "last compilation at %s" % blue(strftime("%d. %B %Y, %H:%M", time))
def do_summary(conf, env, options): limit = options.max if options.max > 0 else 5 entrylist, pages, translations, drafts = readers.load(conf) entrylist = sorted(entrylist + translations + drafts, key=lambda k: k.date, reverse=True) print print 'Acrylamid', blue(env['version']) + ',', print 'cache size:', blue('%0.2f' % (cache.size / 1024.0**2)) + ' mb' print for entry in entrylist[:limit]: print ' ', green(ago(entry.date.replace(tzinfo=None)).ljust(13)), print white(entry.title) if entry.draft else normal(entry.title) print print '%s published,' % blue(len([e for e in entrylist if not e.draft])), print '%s drafted articles' % blue(len([e for e in entrylist if e.draft])) if not isfile(join(conf.get('cache_dir', '.cache/'), 'info')): return time = localtime(getmtime(join(conf.get('cache_dir', '.cache/'), 'info'))) print 'last compilation at %s' % blue(u(strftime(u'%d. %B %Y, %H:%M', time)))
def do_summary(conf, env, options): limit = options.max if options.max > 0 else 5 entrylist, pages, translations, drafts = readers.load(conf) entrylist = sorted(entrylist + translations + drafts, key=lambda k: k.date, reverse=True) print() print('Acrylamid', blue(env['version']) + ',', end=' ') print('cache size:', blue('%0.2f' % (cache.size / 1024.0**2)) + ' mb') print() for entry in entrylist[:limit]: print(' ', green(ago(entry.date.replace(tzinfo=None)).ljust(13)), end=' ') print(white(entry.title) if entry.draft else normal(entry.title)) print() print('%s published,' % blue(len([e for e in entrylist if not e.draft])), end=' ') print('%s drafted articles' % blue(len([e for e in entrylist if e.draft]))) if not isfile(join(conf.get('cache_dir', '.cache/'), 'info')): return time = localtime(getmtime(join(conf.get('cache_dir', '.cache/'), 'info'))) print('last compilation at %s' % blue(u(strftime(u'%d. %B %Y, %H:%M', time))))
def check(url, path): """A HEAD request to URL. If HEAD is not allowed, we try GET.""" try: get(url, timeout=10) except HTTPError as e: if e.code == 405: try: get(url, path, 'GET', True) except URLError as e: print(' ' + yellow(e.reason), url) print(white(' -- ' + path)) else: print(' ' + red(e.code), url) print(white(' -- ' + path)) except URLError as e: print(' ' + yellow(e.reason), url) print(white(' -- ' + path))
def run(conf, env, options): """Subcommand: info -- a short overview of a blog.""" limit = options.max if options.max > 0 else 5 entrylist, pages = readers.load(conf) print print 'acrylamid', blue(env['version']) + ',', print 'cache size:', blue('%0.2f' % (cache.size / 1024.0**2)) + ' mb' print for entry in entrylist[:limit]: print ' ', green(ago(entry.date).ljust(13)), print white(entry.title) if entry.draft else entry.title print print '%s published,' % blue(len([e for e in entrylist if not e.draft])), print '%s drafted articles' % blue(len([e for e in entrylist if e.draft])) time = localtime(getmtime(join(conf.get('cache_dir', '.cache/'), 'info'))) print 'last compilation at %s' % blue(strftime('%d. %B %Y, %H:%M', time))
def run(conf, env, options): """Subcommand: info -- a short overview of a blog.""" limit = options.max if options.max > 0 else 5 commands.initialize(conf, env) entrylist, pages = readers.load(conf) print print "acrylamid", blue(env["version"]) + ",", print "cache size:", blue("%0.2f" % (cache.size / 1024.0 ** 2)) + " mb" print for entry in entrylist[:limit]: print " ", green(ago(entry.date.replace(tzinfo=None)).ljust(13)), print white(entry.title) if entry.draft else normal(entry.title) print print "%s published," % blue(len([e for e in entrylist if not e.draft])), print "%s drafted articles" % blue(len([e for e in entrylist if e.draft])) time = localtime(getmtime(join(conf.get("cache_dir", ".cache/"), "info"))) print "last compilation at %s" % blue(strftime("%d. %B %Y, %H:%M", time))
def run(conf, env, options): """Subcommand: info -- a short overview of a blog.""" limit = options.max if options.max > 0 else 5 commands.initialize(conf, env) entrylist, pages = readers.load(conf) print print 'acrylamid', blue(env['version']) + ',', print 'cache size:', blue('%0.2f' % (cache.size / 1024.0**2)) + ' mb' print for entry in entrylist[:limit]: print ' ', green(ago(entry.date.replace(tzinfo=None)).ljust(13)), print white(entry.title) if entry.draft else entry.title print print '%s published,' % blue(len([e for e in entrylist if not e.draft])), print '%s drafted articles' % blue(len([e for e in entrylist if e.draft])) time = localtime(getmtime(join(conf.get('cache_dir', '.cache/'), 'info'))) print 'last compilation at %s' % blue(strftime('%d. %B %Y, %H:%M', time))