From e15232abd0e05768914d5233f4e09c2127ad7d1a Mon Sep 17 00:00:00 2001 From: Michael Murtaugh Date: Fri, 19 Jan 2018 12:48:57 +0100 Subject: [PATCH] add --glob option to pull --- etherdump/commands/pull.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/etherdump/commands/pull.py b/etherdump/commands/pull.py index 7eae85c..b506656 100644 --- a/etherdump/commands/pull.py +++ b/etherdump/commands/pull.py @@ -16,7 +16,9 @@ from etherdump.commands.common import * from time import sleep from etherdump.commands.html5tidy import html5tidy import html5lib -from xml.etree import ElementTree as ET +from xml.etree import ElementTree as ET +from fnmatch import fnmatch + # debugging # import ElementTree as ET @@ -41,7 +43,10 @@ def try_deleting (files): def main (args): p = ArgumentParser("Check for pads that have changed since last sync (according to .meta.json)") + p.add_argument("padid", nargs="*", default=[]) + p.add_argument("--glob", default=False, help="download pads matching a glob pattern") + p.add_argument("--padinfo", default=".etherdump/settings.json", help="settings, default: .etherdump/settings.json") p.add_argument("--zerorevs", default=False, action="store_true", help="include pads with zero revisions, default: False (i.e. pads with no revisions are skipped)") p.add_argument("--pub", default="p", help="folder to store files for public pads, default: p") @@ -76,7 +81,10 @@ def main (args): data['apikey'] = info['apikey'] if args.padid: - padids = args.padid + padids = args.padid + elif args.glob: + padids = getjson(info['apiurl']+'listAllPads?'+urlencode(data))['data']['padIDs'] + padids = [x for x in padids if fnmatch(x, args.glob)] else: padids = getjson(info['apiurl']+'listAllPads?'+urlencode(data))['data']['padIDs'] padids.sort()