http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9962
Revision: 9962
Author: xqt
Date: 2012-03-03 13:05:14 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
Do not create_user_config_file() when version.py is called
Modified Paths:
--------------
trunk/pywikipedia/wikipediatools.py
Modified: trunk/pywikipedia/wikipediatools.py
===================================================================
--- trunk/pywikipedia/wikipediatools.py 2012-03-03 07:13:04 UTC (rev 9961)
+++ trunk/pywikipedia/wikipediatools.py 2012-03-03 13:05:14 UTC (rev 9962)
@@ -47,6 +47,8 @@
raise RuntimeError("Directory '%s' does not exist." % base_dir)
if not os.path.exists(os.path.join(base_dir, "user-config.py")):
print("No user-config.py found in directory '%s'" % base_dir)
- print("Creating...\n")
- create_user_config_file(base_dir)
+ called = os.path.basename(sys.argv[0].strip())
+ if not ('version' in called):
+ print("Creating...\n")
+ create_user_config_file(base_dir)
return base_dir
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9956
Revision: 9956
Author: xqt
Date: 2012-03-02 17:03:15 +0000 (Fri, 02 Mar 2012)
Log Message:
-----------
interwiki comment string for fr
Modified Paths:
--------------
trunk/pywikipedia/cosmetic_changes.py
Modified: trunk/pywikipedia/cosmetic_changes.py
===================================================================
--- trunk/pywikipedia/cosmetic_changes.py 2012-03-02 16:01:08 UTC (rev 9955)
+++ trunk/pywikipedia/cosmetic_changes.py 2012-03-02 17:03:15 UTC (rev 9956)
@@ -75,8 +75,13 @@
'&warning;': warning,
}
-nn_iw_msg = \
-u'<!--interwiki (no, sv, da first; then other languages alphabetically by name)-->'
+# Interwiki message on top of iw links
+# 2nd line is a regex if needed
+msg_interwiki = {
+ 'fr' : u'<!-- Autres langues -->',
+ 'nn' : (u'<!--interwiki (no, sv, da first; then other languages alphabetically by name)-->',
+ u'(<!-- ?interwiki \(no(?:/nb)?, ?sv, ?da first; then other languages alphabetically by name\) ?-->)')
+}
# This is from interwiki.py;
# move it to family file and implement global instances
@@ -270,9 +275,14 @@
# nn got a message between the categories and the iw's
# and they want to keep it there, first remove it
- if self.site.language()=='nn':
- regex = re.compile(
-'(<!-- ?interwiki \(no(?:/nb)?, ?sv, ?da first; then other languages alphabetically by name\) ?-->)')
+ if self.site.lang in msg_interwiki:
+ iw_msg = msg_interwiki[self.site.lang]
+ if isinstance(iw_msg, tuple):
+ iw_reg = iw_msg[1]
+ iw_msg = iw_msg[0]
+ else:
+ iw_reg = u'(%s)' % iw_msg
+ regex = re.compile(iw_reg)
found = regex.findall(text)
if found:
if pywikibot.verbose:
@@ -284,10 +294,13 @@
if categories:
text = pywikibot.replaceCategoryLinks(text, categories,
site=self.site)
- # Put the nn iw message back
- if self.site.language()=='nn' and not self.talkpage and \
- (interwikiLinks or hasCommentLine):
- text = text + '\r\n\r\n' + nn_iw_msg
+ # Put the iw message back
+ if not self.talkpage and \
+ ((interwikiLinks or hasCommentLine) and
+ self.site.language() == 'nn' or
+ (interwikiLinks and hasCommentLine) and
+ self.site.language() == 'fr'):
+ text = text + '\r\n\r\n' + iw_msg
# Adding stars templates
if allstars:
text = text.strip()+self.site.family.interwiki_text_separator