jenkins-bot has submitted this change and it was merged.
Change subject: Added global command line arguments support
......................................................................
Added global command line arguments support
Also added main() and removed global variable.
Note: --family/-f is now the global arg -family
T70664
Change-Id: I41bc6b8175f34867cfe50c6b890892045c32b4c4
---
M scripts/replicate_wiki.py
1 file changed, 32 insertions(+), 15 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py
index f417541..7d4da0f 100644
--- a/scripts/replicate_wiki.py
+++ b/scripts/replicate_wiki.py
@@ -19,6 +19,21 @@
to replace all occurences of 'Hoofdpagina' with 'Veurblaad' when writing to
liwiki. Note that this does not take the origin wiki into account.
+
+The following parameters are supported:
+-r actually replace pages (without this option
+--replace you will only get an overview page)
+
+-o original wiki
+--original
+
+destination_wiki destination wiki(s)
+
+-ns specify namespace
+--namespace
+
+-dns destination namespace (if different)
+--dest-namespace
"""
#
# (C) Kasper Souren, 2012-2013
@@ -63,7 +78,7 @@
pywikibot.output("Syncing from " + original_wiki)
- family = options.family or config.family
+ family = config.family
sites = options.destination_wiki
@@ -80,7 +95,7 @@
self.differences = {}
self.user_diff = {}
- pywikibot.output('Syncing to', newline=False)
+ pywikibot.output('Syncing to ', newline=False)
for s in self.sites:
s.login()
self.differences[s] = []
@@ -115,8 +130,8 @@
]
if self.options.namespace:
- pywikibot.output(str(options.namespace))
- namespaces = [int(options.namespace)]
+ pywikibot.output(str(self.options.namespace))
+ namespaces = [int(self.options.namespace)]
pywikibot.output("Checking these namespaces: %s\n" % (namespaces,))
for ns in namespaces:
@@ -175,8 +190,8 @@
txt1 = page1.text
for site in self.sites:
- if options.dest_namespace:
- prefix = namespaces(site)[int(options.dest_namespace)]
+ if self.options.dest_namespace:
+ prefix = namespaces(site)[int(self.options.dest_namespace)]
if prefix:
prefix += ':'
new_pagename = prefix + page1.titleWithoutNamespace()
@@ -212,28 +227,30 @@
sys.stdout.flush()
-if __name__ == '__main__':
+def main(*args):
from argparse import ArgumentParser
- parser = ArgumentParser()
- parser.add_argument("-f", "--family", dest="family",
- help="wiki family")
+ my_args = pywikibot.handle_args(args)
+ parser = ArgumentParser(add_help=False)
parser.add_argument("-r", "--replace", action="store_true",
- help="actually replace pages (without this option you
will only get an overview page)")
+ help="actually replace pages (without this "
+ "option you will only get an overview page)")
parser.add_argument("-o", "--original", dest="original_wiki",
help="original wiki")
- parser.add_argument('destination_wiki', metavar='destination', type=str,
nargs='+',
- help='destination wiki(s)')
+ parser.add_argument('destination_wiki', metavar='destination',
+ type=str, nargs='+', help='destination wiki(s)')
parser.add_argument("-ns", "--namespace", dest="namespace",
help="specify namespace")
parser.add_argument("-dns", "--dest-namespace", dest="dest_namespace",
help="destination namespace (if different)")
- (options, args) = parser.parse_known_args()
+ options = parser.parse_args(my_args)
- # sync is global for convenient IPython debugging
sync = SyncSites(options)
sync.check_sysops()
sync.check_namespaces()
sync.generate_overviews()
+
+if __name__ == '__main__':
+ main()
--
To view, visit https://gerrit.wikimedia.org/r/177216
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I41bc6b8175f34867cfe50c6b890892045c32b4c4
Gerrit-PatchSet: 10
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Murfel <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits