feedwarrior

Slim, portable tooling for creating and distributing decentralized append logs
git clone git://git.defalsify.org/logwarrior.git
Log | Files | Refs | README | LICENSE

commit 6557794f6ee296d4abf6014a98095aa4e0fc0be9
parent fc6b397c57e59bb721fe0d014a6de505353f44d6
Author: nolash <dev@holbrook.no>
Date:   Sun, 28 Jun 2020 19:14:32 +0200

Add per-feed symlink index to entries

Diffstat:
Msrc/feedwarrior/cmd/entry.py | 19++++++++++++++-----
Msrc/feedwarrior/feed.py | 2+-
Msrc/main.py | 11+++++------
3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/feedwarrior/cmd/entry.py b/src/feedwarrior/cmd/entry.py @@ -13,7 +13,6 @@ logg = logging.getLogger() def parse_args(argparser): - argparser.add_argument('-l', required=True, help='log to add entry to') argparser.add_argument('--task', action='append', help='add taskwarrior task uuid relation') argparser.add_argument('path', help='multipart file to use for content') return True @@ -25,13 +24,23 @@ def check_args(args): def execute(config, feed, args): entry = feedentry.from_multipart_file(args.path) - for t in args.task: - uu = feedwarrior.common.parse_uuid(t) - entry.add_extension(feedwarrior.extension.TASKWARRIOR, uu) + if args.task != None: + for t in args.task: + uu = feedwarrior.common.parse_uuid(t) + entry.add_extension(feedwarrior.extension.TASKWARRIOR, uu) entry_serialized = entry.serialize() uu = str(entry.uuid) logg.debug('adding entry {}'.format(uu)) - f = open(os.path.join(config.entries_dir, uu), 'x') + entry_path = os.path.join(config.entries_dir, uu) + f = open(entry_path, 'x') + feeds_entries_dir = os.path.join(config.feeds_dir, str(feed.uuid), 'entries') + try: + os.mkdir(feeds_entries_dir) + except FileExistsError: + pass json.dump(entry_serialized, f) f.close() + + feeds_entry_path = os.path.join(feeds_entries_dir, uu) + os.symlink(entry_path, feeds_entry_path) diff --git a/src/feedwarrior/feed.py b/src/feedwarrior/feed.py @@ -17,7 +17,7 @@ class feed: if parent != None: if type(parent).__name__ != 'feed': raise ValueError('wrong type for parent: {}'.format(type(parent).__name__)) - self.parent = parent + self.parent = copy.copy(parent) if created != None: self.created = created diff --git a/src/main.py b/src/main.py @@ -23,7 +23,7 @@ logg = logging.getLogger() argparser = argparse.ArgumentParser(description='create and manipulate feedwarrior logs') -argparser.add_argument('-p', type=str, help='parent log uuid') +argparser.add_argument('-l', help='feed log to operate on') argparser.add_argument('-c', required=True, type=str, help='configuration file') argparser.add_argument('-v', action='store_true', help='be verbose') sub = argparser.add_subparsers() @@ -41,17 +41,16 @@ config = feedwarrior.load_config(args.c) feed_current = None -feed_parent = None -if args.p != None: +if args.l != None: try: - feed_parent = feedwarrior.feed(args.p) + feed_current = feedwarrior.feed(args.l) except ValueError as e: - logg.error('invalid parent {}: {}'.format(args.p, e)) + logg.error('invalid parent {}: {}'.format(args.l, e)) sys.exit(1) cmd_mod = None if args.command == None: - feed_current = feedwarrior.feed(parent=feed_parent) + feed_current = feedwarrior.feed(parent=feed_current) cmd_mod = cmd_log elif args.command == 'entry': cmd_mod = cmd_entry