Reimar Bauer committed 5e311d6 Draft

upload_content2wiki: updated options for farmconfig setup

Comments (0)

Files changed (1)

     def __getattr__(self, name):
         return lambda *args, **kwargs: True
-def write_content(path_wikiconfig, pagename, rawtext, author, mtime, comment):
+def write_content(path_wikiconfig, wiki_url, pagename, rawtext, author, mtime, comment):
     writes content to wiki pages
     if not path_wikiconfig in sys.path:
         sys.path.insert(0, path_wikiconfig)
-    request = ScriptContext()
+    request = ScriptContext(wiki_url)
     request.user.may = IAmRoot()
     page_content = decodeUnknownInput(rawtext).rstrip()
     comment = clean_input(comment)
     sorteddates, sortedwikifiles = zip(*dates_and_files)
     return sortedwikifiles
-def run(path, path_wikiconfig, comment=""):
+def run(path, path_wikiconfig, wiki_url=None, comment=""):
     loops to all files of path and uploads them
             pagename = pagename.strip()
             if author.startswith('[['):
                 author = author[2:].split('|')[0]
-            write_content(path_wikiconfig, pagename, rawtext, author, date, comment)
+            write_content(path_wikiconfig, wiki_url, pagename, rawtext, author, date, comment)
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description='CLI script for uploading files to a MoinMoin Wiki')
     parser.add_argument('-p', '--path', dest="path", type=str, required=True,
                        help='path to walk through')
-    parser.add_argument('-w', '--wikiconfig_path', dest="path_wikiconfig", type=str, required=True,
+    parser.add_argument('-w', '--config-dir', dest="path_wikiconfig", type=str, required=True,
                        help='path where the is')
+    parser.add_argument('-u', '--wiki-url', dest="wiki_url", type=str, required=False,
+                       help='url of the wiki (match regex of farm)')
     parser.add_argument('-c', '--comment', dest="comment", type=str, required=True,
                        help='comment for the commitment')
     args = parser.parse_args()
-    run(args.path, args.path_wikiconfig, args.comment)
+    url = args.wiki_url or None
+    run(args.path, args.path_wikiconfig, url, args.comment)