|
|
@ -100,6 +100,8 @@ def main (args): |
|
|
|
p.add_argument("--linkbase", default=None, help="base url to use for links, default: try to use the feedurl") |
|
|
|
p.add_argument("--output", default=None, help="output, default: stdout") |
|
|
|
|
|
|
|
p.add_argument("--files", default=False, action="store_true", help="include files (experimental)") |
|
|
|
|
|
|
|
pg = p.add_argument_group('template variables') |
|
|
|
pg.add_argument("--feedurl", default="feed.xml", help="rss: to use as feeds own (self) link, default: feed.xml") |
|
|
|
pg.add_argument("--siteurl", default=None, help="rss: to use as channel's site link, default: the etherpad url") |
|
|
@ -114,7 +116,7 @@ def main (args): |
|
|
|
pg.add_argument("--prev", default=None, help="prev link, default: None") |
|
|
|
|
|
|
|
args = p.parse_args(args) |
|
|
|
|
|
|
|
|
|
|
|
tmpath = args.templatepath |
|
|
|
# Default path for template is the built-in data/templates |
|
|
|
if tmpath == None: |
|
|
@ -185,25 +187,6 @@ def main (args): |
|
|
|
pads = map(fixdates, pads) |
|
|
|
args.pads = list(pads) |
|
|
|
|
|
|
|
inputs = args.input |
|
|
|
inputs.sort() |
|
|
|
removelist = [] |
|
|
|
|
|
|
|
def has_version (padinfo, path): |
|
|
|
return [x for x in padinfo['versions'] if 'path' in x and x['path'] == "./"+path] |
|
|
|
|
|
|
|
pads_by_base = {} |
|
|
|
for p in args.pads: |
|
|
|
# print ("Trying padid", p['padid'], file=sys.stderr) |
|
|
|
padbase = os.path.splitext(p['padid'])[0] |
|
|
|
pads_by_base[padbase] = p |
|
|
|
padbases = list(pads_by_base.keys()) |
|
|
|
# SORT THEM LONGEST FIRST TO ensure that LONGEST MATCHES MATCH |
|
|
|
padbases.sort(key=lambda x: len(x), reverse=True) |
|
|
|
# print ("PADBASES", file=sys.stderr) |
|
|
|
# for pb in padbases: |
|
|
|
# print (" ", pb, file=sys.stderr) |
|
|
|
|
|
|
|
def could_have_base (x, y): |
|
|
|
return x == y or (x.startswith(y) and x[len(y):].startswith(".")) |
|
|
|
|
|
|
@ -213,28 +196,47 @@ def main (args): |
|
|
|
if could_have_base(x, pb): |
|
|
|
return p |
|
|
|
|
|
|
|
print ("pairing input files with pads", file=sys.stderr) |
|
|
|
for x in inputs: |
|
|
|
# pair input with a pad if possible |
|
|
|
xbasename = os.path.basename(x) |
|
|
|
p = get_best_pad(xbasename) |
|
|
|
if p: |
|
|
|
if not has_version(p, x): |
|
|
|
print ("Grouping file {0} with pad {1}".format(x, p['padid']), file=sys.stderr) |
|
|
|
p['versions'].append(wrappath(x)) |
|
|
|
else: |
|
|
|
print ("Skipping existing version {0} ({1})...".format(x, p['padid']), file=sys.stderr) |
|
|
|
removelist.append(x) |
|
|
|
# Removed Matches files |
|
|
|
for x in removelist: |
|
|
|
inputs.remove(x) |
|
|
|
print ("Remaining files:", file=sys.stderr) |
|
|
|
for x in inputs: |
|
|
|
print (x, file=sys.stderr) |
|
|
|
print (file=sys.stderr) |
|
|
|
# Add "fake" pads for remaining files |
|
|
|
for x in inputs: |
|
|
|
args.pads.append(metaforpaths([x])) |
|
|
|
def has_version (padinfo, path): |
|
|
|
return [x for x in padinfo['versions'] if 'path' in x and x['path'] == "./"+path] |
|
|
|
|
|
|
|
if args.files: |
|
|
|
inputs = args.input |
|
|
|
inputs.sort() |
|
|
|
removelist = [] |
|
|
|
|
|
|
|
pads_by_base = {} |
|
|
|
for p in args.pads: |
|
|
|
# print ("Trying padid", p['padid'], file=sys.stderr) |
|
|
|
padbase = os.path.splitext(p['padid'])[0] |
|
|
|
pads_by_base[padbase] = p |
|
|
|
padbases = list(pads_by_base.keys()) |
|
|
|
# SORT THEM LONGEST FIRST TO ensure that LONGEST MATCHES MATCH |
|
|
|
padbases.sort(key=lambda x: len(x), reverse=True) |
|
|
|
# print ("PADBASES", file=sys.stderr) |
|
|
|
# for pb in padbases: |
|
|
|
# print (" ", pb, file=sys.stderr) |
|
|
|
print ("pairing input files with pads", file=sys.stderr) |
|
|
|
for x in inputs: |
|
|
|
# pair input with a pad if possible |
|
|
|
xbasename = os.path.basename(x) |
|
|
|
p = get_best_pad(xbasename) |
|
|
|
if p: |
|
|
|
if not has_version(p, x): |
|
|
|
print ("Grouping file {0} with pad {1}".format(x, p['padid']), file=sys.stderr) |
|
|
|
p['versions'].append(wrappath(x)) |
|
|
|
else: |
|
|
|
print ("Skipping existing version {0} ({1})...".format(x, p['padid']), file=sys.stderr) |
|
|
|
removelist.append(x) |
|
|
|
# Removed Matches files |
|
|
|
for x in removelist: |
|
|
|
inputs.remove(x) |
|
|
|
print ("Remaining files:", file=sys.stderr) |
|
|
|
for x in inputs: |
|
|
|
print (x, file=sys.stderr) |
|
|
|
print (file=sys.stderr) |
|
|
|
# Add "fake" pads for remaining files |
|
|
|
for x in inputs: |
|
|
|
args.pads.append(metaforpaths([x])) |
|
|
|
|
|
|
|
if args.timestamp == None: |
|
|
|
args.timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") |
|
|
@ -296,4 +298,4 @@ def main (args): |
|
|
|
with open(args.output, "w") as f: |
|
|
|
print (template.render(vars(args)), file=f) |
|
|
|
else: |
|
|
|
print (template.render(vars(args))) |
|
|
|
print (template.render(vars(args))) |
|
|
|