allow to ignore pages
This commit is contained in:
parent
de270d83ee
commit
bb61d04533
1 changed files with 14 additions and 3 deletions
17
moin2doku.py
17
moin2doku.py
|
@ -237,7 +237,7 @@ 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:', [ "help" ])
|
opts, args = getopt.getopt(sys.argv[1:], 'hfad:F: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)
|
||||||
|
@ -248,6 +248,7 @@ output_dir = None
|
||||||
convert_attic = False
|
convert_attic = False
|
||||||
redirect_conf = False
|
redirect_conf = False
|
||||||
redirect_map = {}
|
redirect_map = {}
|
||||||
|
page_filter = []
|
||||||
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()
|
||||||
|
@ -257,6 +258,10 @@ for o, a in opts:
|
||||||
convert_attic = True
|
convert_attic = True
|
||||||
if o == "-r":
|
if o == "-r":
|
||||||
redirect_conf = a
|
redirect_conf = a
|
||||||
|
if o == "-i":
|
||||||
|
page_filter.append(a)
|
||||||
|
if o == "-I":
|
||||||
|
page_filter.extend(readfile(a).split("\n"))
|
||||||
if o == "-d":
|
if o == "-d":
|
||||||
output_dir = a
|
output_dir = a
|
||||||
if o == "-F":
|
if o == "-F":
|
||||||
|
@ -277,8 +282,14 @@ if input_file != None:
|
||||||
else:
|
else:
|
||||||
converted = 0
|
converted = 0
|
||||||
|
|
||||||
|
filter = None
|
||||||
|
if page_filter:
|
||||||
|
def name_filter(name):
|
||||||
|
return name not in page_filter
|
||||||
|
filter = name_filter
|
||||||
|
|
||||||
# get list of all pages in wiki
|
# get list of all pages in wiki
|
||||||
pages = request.rootpage.getPageDict(user = '', exists = not convert_attic)
|
pages = request.rootpage.getPageDict(user = '', exists = not convert_attic, filter = filter)
|
||||||
|
|
||||||
# insert frontpage,
|
# insert frontpage,
|
||||||
# so that MoinMoin frontpage gets saved as DokuWiki frontpage based on their configs
|
# so that MoinMoin frontpage gets saved as DokuWiki frontpage based on their configs
|
||||||
|
@ -291,7 +302,7 @@ else:
|
||||||
res = convertfile(page.getPagePath(), output = pagename, overwrite = overwrite)
|
res = convertfile(page.getPagePath(), output = pagename, overwrite = overwrite)
|
||||||
if res != None:
|
if res != None:
|
||||||
converted += 1
|
converted += 1
|
||||||
print "Processed %d files, converted %d" % (len(pages) + 1, converted)
|
print "Processed %d files, converted %d" % (len(pages), converted)
|
||||||
|
|
||||||
if redirect_conf:
|
if redirect_conf:
|
||||||
print "Writing %s: %d items" % (redirect_conf, len(redirect_map))
|
print "Writing %s: %d items" % (redirect_conf, len(redirect_map))
|
||||||
|
|
Loading…
Reference in a new issue