make files behaviour optional and default false in index
This commit is contained in:
parent
09cd972065
commit
26f3d4af24
@ -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("--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("--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 = 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("--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")
|
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")
|
pg.add_argument("--prev", default=None, help="prev link, default: None")
|
||||||
|
|
||||||
args = p.parse_args(args)
|
args = p.parse_args(args)
|
||||||
|
|
||||||
tmpath = args.templatepath
|
tmpath = args.templatepath
|
||||||
# Default path for template is the built-in data/templates
|
# Default path for template is the built-in data/templates
|
||||||
if tmpath == None:
|
if tmpath == None:
|
||||||
@ -185,25 +187,6 @@ def main (args):
|
|||||||
pads = map(fixdates, pads)
|
pads = map(fixdates, pads)
|
||||||
args.pads = list(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):
|
def could_have_base (x, y):
|
||||||
return x == y or (x.startswith(y) and x[len(y):].startswith("."))
|
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):
|
if could_have_base(x, pb):
|
||||||
return p
|
return p
|
||||||
|
|
||||||
print ("pairing input files with pads", file=sys.stderr)
|
def has_version (padinfo, path):
|
||||||
for x in inputs:
|
return [x for x in padinfo['versions'] if 'path' in x and x['path'] == "./"+path]
|
||||||
# pair input with a pad if possible
|
|
||||||
xbasename = os.path.basename(x)
|
if args.files:
|
||||||
p = get_best_pad(xbasename)
|
inputs = args.input
|
||||||
if p:
|
inputs.sort()
|
||||||
if not has_version(p, x):
|
removelist = []
|
||||||
print ("Grouping file {0} with pad {1}".format(x, p['padid']), file=sys.stderr)
|
|
||||||
p['versions'].append(wrappath(x))
|
pads_by_base = {}
|
||||||
else:
|
for p in args.pads:
|
||||||
print ("Skipping existing version {0} ({1})...".format(x, p['padid']), file=sys.stderr)
|
# print ("Trying padid", p['padid'], file=sys.stderr)
|
||||||
removelist.append(x)
|
padbase = os.path.splitext(p['padid'])[0]
|
||||||
# Removed Matches files
|
pads_by_base[padbase] = p
|
||||||
for x in removelist:
|
padbases = list(pads_by_base.keys())
|
||||||
inputs.remove(x)
|
# SORT THEM LONGEST FIRST TO ensure that LONGEST MATCHES MATCH
|
||||||
print ("Remaining files:", file=sys.stderr)
|
padbases.sort(key=lambda x: len(x), reverse=True)
|
||||||
for x in inputs:
|
# print ("PADBASES", file=sys.stderr)
|
||||||
print (x, file=sys.stderr)
|
# for pb in padbases:
|
||||||
print (file=sys.stderr)
|
# print (" ", pb, file=sys.stderr)
|
||||||
# Add "fake" pads for remaining files
|
print ("pairing input files with pads", file=sys.stderr)
|
||||||
for x in inputs:
|
for x in inputs:
|
||||||
args.pads.append(metaforpaths([x]))
|
# 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:
|
if args.timestamp == None:
|
||||||
args.timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
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:
|
with open(args.output, "w") as f:
|
||||||
print (template.render(vars(args)), file=f)
|
print (template.render(vars(args)), file=f)
|
||||||
else:
|
else:
|
||||||
print (template.render(vars(args)))
|
print (template.render(vars(args)))
|
||||||
|
Loading…
Reference in New Issue
Block a user