Commit 5909def9 authored by Lysander Trischler's avatar Lysander Trischler

Add cache2txt utility

parent dcfef0fe
# encoding: utf-8
import argparse
import configparser
import shelve
import os.path
import xdg
parser = argparse.ArgumentParser(description="Extract twtxt.txt feed from cache")
parser.add_argument("-c", "--config-file",
default=os.path.join(xdg.xdg_config_home(), "twtxt", "config"),
help="path to the config file to resolve nicks to URLs")
parser.add_argument("-f", "--cache-file",
default=os.path.join(xdg.xdg_config_home(), "twtxt", "cache"),
help="path to the cache file")
help="nick or URL of the feed to extract")
args = parser.parse_args()
if args.cache_file.endswith(".db"):
args.cache_file = args.cache_file[:-3]
cache =
if args.nick_or_url in cache:
feed = cache[args.nick_or_url]
# we need to resolve the nick to an URL first
cfg = configparser.ConfigParser()
url = cfg.get("following", args.nick_or_url, fallback=None)
if url is None:
parser.error("unknown nick/URL '%s'" % args.nick_or_url)
feed = cache[url]
for twt in feed['tweets']:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment