Commits

Reimar Bauer committed f78e6a0 Draft

upload_content2wiki: moved path setup to __main__

Comments (0)

Files changed (1)

upload_content2wiki.py

     def __getattr__(self, name):
         return lambda *args, **kwargs: True
 
-def write_content(path_wikiconfig, wiki_url, pagename, rawtext, author, mtime, comment):
+def write_content(wiki_url, pagename, rawtext, author, mtime, comment):
     """
     writes content to wiki pages
 
-    :param path_wikiconfig: sets the path to wikiconfig and selects the wiki to write too
+    :param wiki_url: url of the wiki in the farm (None if not a farmsetup)
     :param pagename: name of the page
     :param rawtext: wiki markup content
     :param author: name of the author of the content
     :param mtime: time to set for the upload
     :param comment: the comment
     """
-    if not path_wikiconfig in sys.path:
-        sys.path.insert(0, path_wikiconfig)
     request = ScriptContext(wiki_url)
     request.user.may = IAmRoot()
     page_content = decodeUnknownInput(rawtext).rstrip()
     sorteddates, sortedwikifiles = zip(*dates_and_files)
     return sortedwikifiles
 
-def run(path, path_wikiconfig, wiki_url=None, comment=""):
+def run(path, 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, wiki_url, pagename, rawtext, author, date, comment)
+            write_content(wiki_url, pagename, rawtext, author, date, comment)
 
 
 if __name__ == '__main__':
     parser.add_argument('-c', '--comment', dest="comment", type=str, required=True,
                        help='comment for the commitment')
     args = parser.parse_args()
+    if not args.path_wikiconfig in sys.path:
+        sys.path.insert(0, args.path_wikiconfig)
     url = args.wiki_url or None
-    run(args.path, args.path_wikiconfig, url, args.comment)
+    run(args.path, url, args.comment)