convertfile: take page object as input
This commit is contained in:
parent
0aa455c205
commit
fb47aaa8a0
1 changed files with 11 additions and 10 deletions
21
moin2doku.py
21
moin2doku.py
|
@ -151,13 +151,12 @@ def convert_editlog(pagedir, output = None, overwrite = False):
|
||||||
out_file = os.path.join(output_dir, 'meta', dw.metaFN(output, '.changes'))
|
out_file = os.path.join(output_dir, 'meta', dw.metaFN(output, '.changes'))
|
||||||
writefile(out_file, "\n".join(changes), overwrite = overwrite)
|
writefile(out_file, "\n".join(changes), overwrite = overwrite)
|
||||||
|
|
||||||
def convertfile(pagedir, output = None, overwrite = False):
|
def convertfile(page, output = None, overwrite = False):
|
||||||
pagedir = os.path.abspath(pagedir)
|
pagedir = page.getPagePath()
|
||||||
pagename = wikiname(pagedir)
|
pagename = wikiname(pagedir)
|
||||||
if not output:
|
if not output:
|
||||||
output = pagename
|
output = pagename
|
||||||
|
|
||||||
page = Page(request, pagename)
|
|
||||||
if page.isUnderlayPage():
|
if page.isUnderlayPage():
|
||||||
print "SKIP UNDERLAY: %s" % pagename
|
print "SKIP UNDERLAY: %s" % pagename
|
||||||
return False
|
return False
|
||||||
|
@ -237,13 +236,13 @@ else:
|
||||||
sys.stdout = codecs.getwriter(default_encoding)(sys.stdout);
|
sys.stdout = codecs.getwriter(default_encoding)(sys.stdout);
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'hfad:F:r:i:I:', [ "help" ])
|
opts, args = getopt.getopt(sys.argv[1:], 'hfad:p:r:i:I:', [ "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)
|
||||||
|
|
||||||
overwrite = False
|
overwrite = False
|
||||||
input_file = None
|
convert_page = None
|
||||||
output_dir = None
|
output_dir = None
|
||||||
convert_attic = False
|
convert_attic = False
|
||||||
redirect_conf = False
|
redirect_conf = False
|
||||||
|
@ -264,8 +263,8 @@ for o, a in opts:
|
||||||
page_filter.extend(readfile(a).split("\n"))
|
page_filter.extend(readfile(a).split("\n"))
|
||||||
if o == "-d":
|
if o == "-d":
|
||||||
output_dir = a
|
output_dir = a
|
||||||
if o == "-F":
|
if o == "-p":
|
||||||
input_file = a
|
convert_page = a
|
||||||
|
|
||||||
if not output_dir:
|
if not output_dir:
|
||||||
print_help()
|
print_help()
|
||||||
|
@ -277,8 +276,10 @@ init_dirs(output_dir)
|
||||||
dw = DokuWiki()
|
dw = DokuWiki()
|
||||||
request = RequestCLI()
|
request = RequestCLI()
|
||||||
|
|
||||||
if input_file != None:
|
if convert_page != None:
|
||||||
res = convertfile(input_file, overwrite = overwrite)
|
pagename = wikiname(convert_page)
|
||||||
|
page = Page(request, pagename)
|
||||||
|
res = convertfile(page, overwrite = overwrite)
|
||||||
else:
|
else:
|
||||||
converted = 0
|
converted = 0
|
||||||
|
|
||||||
|
@ -304,7 +305,7 @@ else:
|
||||||
|
|
||||||
for pagename, page in pages.items():
|
for pagename, page in pages.items():
|
||||||
print "%s" % page.getPagePath()
|
print "%s" % page.getPagePath()
|
||||||
res = convertfile(page.getPagePath(), output = pagename, overwrite = overwrite)
|
res = convertfile(page, output = pagename, overwrite = overwrite)
|
||||||
if res != None:
|
if res != None:
|
||||||
print "Converted: %s" % pagename
|
print "Converted: %s" % pagename
|
||||||
converted += 1
|
converted += 1
|
||||||
|
|
Loading…
Reference in a new issue