added outputpath
This commit is contained in:
parent
8b35430b43
commit
93b9273a40
12
etherdump
12
etherdump
@ -89,7 +89,7 @@ def get_template_env (tpath=None):
|
||||
# template = env.get_template('pad.html')
|
||||
# print template.render(the='variables', go='here').encode("utf-8")
|
||||
|
||||
def dumpPads (padserver, padids, pub_path, group_path, sleeptime=0.01, force=False, templates=None):
|
||||
def dumpPads (padserver, padids, outputpath, pub_path, group_path, sleeptime=0.01, force=False, templates=None):
|
||||
template_env = get_template_env(templates)
|
||||
pad_template = template_env.get_template("pad.html")
|
||||
numpads = len(padids)
|
||||
@ -104,13 +104,13 @@ def dumpPads (padserver, padids, pub_path, group_path, sleeptime=0.01, force=Fal
|
||||
os.mkdir(os.path.join(group_path, group_id))
|
||||
except OSError:
|
||||
pass
|
||||
fp = os.path.join(group_path, group_id, pad_name)
|
||||
fp = os.path.join(outputpath, group_path, group_id, pad_name)
|
||||
else:
|
||||
try:
|
||||
os.mkdir(pub_path)
|
||||
except OSError:
|
||||
pass
|
||||
fp = os.path.join(pub_path, pad_name)
|
||||
fp = os.path.join(outputpath, pub_path, pad_name)
|
||||
|
||||
if verbose:
|
||||
print (u"Saving to {0}".format(fp).encode("utf-8"), file=sys.stderr)
|
||||
@ -147,7 +147,7 @@ def dumpPads (padserver, padids, pub_path, group_path, sleeptime=0.01, force=Fal
|
||||
try:
|
||||
text = padserver.getPadText(padid)
|
||||
f.write(text.encode("utf-8"))
|
||||
meta['text_path'] = textpath
|
||||
meta['text_path'] = os.path.relpath(textpath, outputpath)
|
||||
meta['text_length'] = len(text)
|
||||
meta['text_length_human'] = humanize_bytes(meta['text_length'])
|
||||
|
||||
@ -156,7 +156,7 @@ def dumpPads (padserver, padids, pub_path, group_path, sleeptime=0.01, force=Fal
|
||||
|
||||
with open(htmlpath, "w") as f:
|
||||
html = padserver.getPadHTML(padid)
|
||||
meta['html_path'] = htmlpath
|
||||
meta['html_path'] = os.path.relpath(htmlpath, outputpath)
|
||||
meta['html_length'] = len(html)
|
||||
if pad_template:
|
||||
t = html5lib.parse(html, treebuilder="etree", namespaceHTMLElements=False)
|
||||
@ -253,6 +253,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument('--apiurl', help='URL path to the API')
|
||||
|
||||
parser.add_argument('--verbose', action="store_true", default=False, help='debug mode, verbose output')
|
||||
parser.add_argument('--outputpath', default=os.getcwd(), help='path for output, default is .')
|
||||
parser.add_argument('--pubpath', default="pub", help='path to dump public pads')
|
||||
parser.add_argument('--grouppath', default="priv", help='path to dump group pads')
|
||||
parser.add_argument('--templates', default=os.path.join(os.getcwd(), "templates"), help='(addition) templates path, default: ./templates')
|
||||
@ -342,6 +343,7 @@ if __name__ == "__main__":
|
||||
dumpPads(
|
||||
padserver,
|
||||
padids,
|
||||
args.outputpath,
|
||||
args.pubpath,
|
||||
args.grouppath,
|
||||
force=args.force,
|
||||
|
Loading…
Reference in New Issue
Block a user