add -a option to convert old revisions

This commit is contained in:
Elan Ruusamäe 2012-09-19 22:07:13 +02:00
parent 709c73c409
commit ac5efb0505

View file

@ -98,6 +98,7 @@ def print_help():
print "Options:" print "Options:"
print "-m DIR - MoinMoin pages dir" print "-m DIR - MoinMoin pages dir"
print "-d DIR - Dokuwiki pages dir" print "-d DIR - Dokuwiki pages dir"
print "-a - Convert Attic pages (history)"
print "-f - overwrite output files" print "-f - overwrite output files"
print "-F FILE - convert single file" print "-F FILE - convert single file"
print "" print ""
@ -179,7 +180,12 @@ def convertfile(pagedir, output = None, overwrite = False):
return return
current_rev = page.current_rev() current_rev = page.current_rev()
for rev in page.getRevList(): if convert_attic:
revs = page.getRevList()
else:
revs = [current_rev]
for rev in revs:
page = Page(request, pagename, rev = rev) page = Page(request, pagename, rev = rev)
pagefile, realrev, exists = page.get_rev(rev = rev); pagefile, realrev, exists = page.get_rev(rev = rev);
@ -215,7 +221,7 @@ def convertfile(pagedir, output = None, overwrite = False):
# "main" starts here # "main" starts here
# #
try: try:
opts, args = getopt.getopt(sys.argv[1:], 'hfm:d:F:', [ "help" ]) opts, args = getopt.getopt(sys.argv[1:], 'hfam:d:F:', [ "help" ])
except getopt.GetoptError, e: except getopt.GetoptError, e:
print >> sys.stderr, 'Incorrect parameters! Use --help switch to learn more.: %s' % e print >> sys.stderr, 'Incorrect parameters! Use --help switch to learn more.: %s' % e
sys.exit(1) sys.exit(1)
@ -224,6 +230,7 @@ overwrite = False
input_file = None input_file = None
moin_pages_dir = None moin_pages_dir = None
output_dir = None output_dir = None
convert_attic = False
for o, a in opts: for o, a in opts:
if o == "--help" or o == "-h": if o == "--help" or o == "-h":
print_help() print_help()
@ -231,6 +238,8 @@ for o, a in opts:
overwrite = True overwrite = True
if o == "-m": if o == "-m":
moin_pages_dir = a moin_pages_dir = a
if o == "-a":
convert_attic = True
if o == "-d": if o == "-d":
output_dir = a output_dir = a
if o == "-F": if o == "-F":