Browse Source

add --glob option to pull

add-quote-import
Michael Murtaugh 7 years ago
parent
commit
e15232abd0
  1. 12
      etherdump/commands/pull.py

12
etherdump/commands/pull.py

@ -16,7 +16,9 @@ from etherdump.commands.common import *
from time import sleep from time import sleep
from etherdump.commands.html5tidy import html5tidy from etherdump.commands.html5tidy import html5tidy
import html5lib import html5lib
from xml.etree import ElementTree as ET from xml.etree import ElementTree as ET
from fnmatch import fnmatch
# debugging # debugging
# import ElementTree as ET # import ElementTree as ET
@ -41,7 +43,10 @@ def try_deleting (files):
def main (args): def main (args):
p = ArgumentParser("Check for pads that have changed since last sync (according to .meta.json)") p = ArgumentParser("Check for pads that have changed since last sync (according to .meta.json)")
p.add_argument("padid", nargs="*", default=[]) 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("--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("--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") 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'] data['apikey'] = info['apikey']
if args.padid: 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: else:
padids = getjson(info['apiurl']+'listAllPads?'+urlencode(data))['data']['padIDs'] padids = getjson(info['apiurl']+'listAllPads?'+urlencode(data))['data']['padIDs']
padids.sort() padids.sort()

Loading…
Cancel
Save