Revision: 7576
Author: wikipedian
Date: 2009-10-31 00:35:16 +0000 (Sat, 31 Oct 2009)
Log Message:
-----------
used page generators to make the ignore list feature available to other
scripts
Modified Paths:
--------------
trunk/pywikipedia/pagegenerators.py
trunk/pywikipedia/solve_disambiguation.py
Modified: trunk/pywikipedia/pagegenerators.py
===================================================================
--- trunk/pywikipedia/pagegenerators.py 2009-10-30 23:57:42 UTC (rev 7575)
+++ trunk/pywikipedia/pagegenerators.py 2009-10-31 00:35:16 UTC (rev 7576)
@@ -734,6 +734,32 @@
if page.namespace() in namespaces:
yield page
+def PageTitleFilterPageGenerator(generator, ignoreList):
+ """
+ Wraps around another generator. Yields only those pages are not
+ listed in the ignore list.
+
+ The ignoreList is a dictionary. Family names are mapped to
+ dictionaries in which language codes are mapped to lists of
+ page titles.
+ """
+
+ def isIgnored(page):
+ if not (page.site().family.name in ignoreList and page.site().lang in ignoreList[page.site().family.name]):
+ return False
+
+ for ig in ignoreList[page.site().family.name][page.site().lang]:
+ if re.match(ig, page.title()):
+ return True
+ return False
+
+ for page in generator:
+ if isIgnored(page):
+ if wikipedia.verbose:
+ wikipedia.output('Ignoring page %s' % page.title())
+ else:
+ yield page
+
def RedirectFilterPageGenerator(generator):
"""
Wraps around another generator. Yields only those pages that are not redirects.
Modified: trunk/pywikipedia/solve_disambiguation.py
===================================================================
--- trunk/pywikipedia/solve_disambiguation.py 2009-10-30 23:57:42 UTC (rev 7575)
+++ trunk/pywikipedia/solve_disambiguation.py 2009-10-31 00:35:16 UTC (rev 7576)
@@ -412,28 +412,14 @@
class ReferringPageGeneratorWithIgnore:
def __init__(self, disambPage, primary=False, minimum = 0):
self.disambPage = disambPage
- # if run with the -primary argument, enable the ignore manager
- self.primaryIgnoreManager = PrimaryIgnoreManager(disambPage,
- enabled=primary)
self.minimum = minimum
-
+
def __iter__(self):
- # TODO: start yielding before all referring pages have been found
- refs = [page for page in self.disambPage.getReferences(follow_redirects = False, withTemplateInclusion = False)]
- pywikibot.output(u"Found %d references." % len(refs))
- # Remove ignorables
- if self.disambPage.site().family.name in ignore_title and self.disambPage.site().lang in ignore_title[self.disambPage.site().family.name]:
- for ig in ignore_title[self.disambPage.site().family.name][self.disambPage.site().lang]:
- for i in range(len(refs)-1, -1, -1):
- if re.match(ig, refs[i].title()):
- if pywikibot.verbose:
- pywikibot.output('Ignoring page %s'
- % refs[i].title())
- del refs[i]
- for i in range(len(refs)-1, -1, -1):
- if self.primaryIgnoreManager.isIgnored(refs[i]):
- #pywikibot.output('Ignoring page %s because it was skipped before' % refs[i].title())
- del refs[i]
+ generator = pagegenerators.ReferringPageGenerator(self.disambPage, followRedirects = False, withTemplateInclusion = False)
+ generator = pagegenerators.PageTitleFilterPageGenerator(generator, ignore_title)
+
+ refs = [page for page in generator]
+
if len(refs) < self.minimum:
pywikibot.output(u"Found only %d pages to work on; skipping." % len(refs))
return
Revision: 7575
Author: wikipedian
Date: 2009-10-30 23:57:42 +0000 (Fri, 30 Oct 2009)
Log Message:
-----------
separated ignorelist and -primary ignore function
Modified Paths:
--------------
trunk/pywikipedia/solve_disambiguation.py
Modified: trunk/pywikipedia/solve_disambiguation.py
===================================================================
--- trunk/pywikipedia/solve_disambiguation.py 2009-10-30 09:51:24 UTC (rev 7574)
+++ trunk/pywikipedia/solve_disambiguation.py 2009-10-30 23:57:42 UTC (rev 7575)
@@ -430,9 +430,10 @@
pywikibot.output('Ignoring page %s'
% refs[i].title())
del refs[i]
- elif self.primaryIgnoreManager.isIgnored(refs[i]):
- #pywikibot.output('Ignoring page %s because it was skipped before' % refs[i].title())
- del refs[i]
+ for i in range(len(refs)-1, -1, -1):
+ if self.primaryIgnoreManager.isIgnored(refs[i]):
+ #pywikibot.output('Ignoring page %s because it was skipped before' % refs[i].title())
+ del refs[i]
if len(refs) < self.minimum:
pywikibot.output(u"Found only %d pages to work on; skipping." % len(refs))
return
Revision: 7574
Author: xqt
Date: 2009-10-30 09:51:24 +0000 (Fri, 30 Oct 2009)
Log Message:
-----------
refcheck.py merged to templatecount.py and achived
Modified Paths:
--------------
trunk/pywikipedia/templatecount.py
Added Paths:
-----------
trunk/pywikipedia/archive/refcheck.py
Removed Paths:
-------------
trunk/pywikipedia/refcheck.py
Copied: trunk/pywikipedia/archive/refcheck.py (from rev 7572, trunk/pywikipedia/refcheck.py)
===================================================================
--- trunk/pywikipedia/archive/refcheck.py (rev 0)
+++ trunk/pywikipedia/archive/refcheck.py 2009-10-30 09:51:24 UTC (rev 7574)
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+"""
+##################################################
+This script with all its function has been merged
+to templatecount.py. please use:
+
+ templatecount.py -count
+
+xqt 2009-10-30
+##################################################
+This script checks references to see if they are properly formatted. Right now
+it just counts the total number of transclusions of any number of given templates.
+
+NOTE: This script is not capable of handling the <ref></ref> syntax. It just
+handles the {{ref}} syntax, which is still used, but DEPRECATED on the English
+Wikipedia.
+
+Syntax: python refcheck.py command [arguments]
+
+Command line options:
+
+-count Counts the number of times each template (passed in as an argument)
+ is transcluded.
+-namespace: Filters the search to a given namespace. If this is specified
+ multiple times it will search all given namespaces
+
+Examples:
+
+Counts how many time {{ref}} and {{note}} are transcluded in articles.
+
+ python refcheck.py -count ref note -namespace:0
+
+"""
+__version__ = '$Id$'
+
+import wikipedia, config
+import replace, pagegenerators
+import re, sys, string
+
+templates = ['ref', 'note', 'ref label', 'note label', 'reflist']
+
+class ReferencesRobot:
+ #def __init__(self):
+ #Nothing
+ def countRefs(self, templates, namespaces):
+ mysite = wikipedia.getSite()
+ mytpl = mysite.template_namespace()+':'
+ finalText = [u'Number of transclusions per template',u'------------------------------------']
+ for template in templates:
+ gen = pagegenerators.ReferringPageGenerator(wikipedia.Page(mysite, mytpl + template), onlyTemplateInclusion = True)
+ if namespaces:
+ gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces)
+ count = 0
+ for page in gen:
+ count += 1
+ finalText.append(u'%s: %d' % (template, count))
+ for line in finalText:
+ wikipedia.output(line)
+
+def main():
+ doCount = False
+ argsList = []
+ namespaces = []
+ for arg in wikipedia.handleArgs():
+ if arg == '-count':
+ doCount = True
+ elif arg.startswith('-namespace:'):
+ try:
+ namespaces.append(int(arg[len('-namespace:'):]))
+ except ValueError:
+ namespaces.append(arg[len('-namespace:'):])
+ else:
+ argsList.append(arg)
+
+ if doCount:
+ robot = ReferencesRobot()
+ if not argsList:
+ argsList = templates
+ choice = ''
+ if 'reflist' in argsList:
+ wikipedia.output(u'NOTE: it will take a long time to count "reflist".')
+ choice = wikipedia.inputChoice(u'Proceed anyway?', ['yes', 'no', 'skip'], ['y', 'n', 's'], 'y')
+ if choice == 's':
+ argsList.remove('reflist')
+ if choice <> 'n':
+ robot.countRefs(argsList, namespaces)
+ else:
+ wikipedia.showHelp('refcheck')
+
+if __name__ == "__main__":
+ try:
+ main()
+ finally:
+ wikipedia.stopme()
+
Deleted: trunk/pywikipedia/refcheck.py
===================================================================
--- trunk/pywikipedia/refcheck.py 2009-10-30 06:00:55 UTC (rev 7573)
+++ trunk/pywikipedia/refcheck.py 2009-10-30 09:51:24 UTC (rev 7574)
@@ -1,86 +0,0 @@
-"""
-This script checks references to see if they are properly formatted. Right now
-it just counts the total number of transclusions of any number of given templates.
-
-NOTE: This script is not capable of handling the <ref></ref> syntax. It just
-handles the {{ref}} syntax, which is still used, but DEPRECATED on the English
-Wikipedia.
-
-Syntax: python refcheck.py command [arguments]
-
-Command line options:
-
--count Counts the number of times each template (passed in as an argument)
- is transcluded.
--namespace: Filters the search to a given namespace. If this is specified
- multiple times it will search all given namespaces
-
-Examples:
-
-Counts how many time {{ref}} and {{note}} are transcluded in articles.
-
- python refcheck.py -count ref note -namespace:0
-
-"""
-__version__ = '$Id$'
-
-import wikipedia, config
-import replace, pagegenerators
-import re, sys, string
-
-templates = ['ref', 'note', 'ref label', 'note label', 'reflist']
-
-class ReferencesRobot:
- #def __init__(self):
- #Nothing
- def countRefs(self, templates, namespaces):
- mysite = wikipedia.getSite()
- mytpl = mysite.template_namespace()+':'
- finalText = [u'Number of transclusions per template',u'------------------------------------']
- for template in templates:
- gen = pagegenerators.ReferringPageGenerator(wikipedia.Page(mysite, mytpl + template), onlyTemplateInclusion = True)
- if namespaces:
- gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces)
- count = 0
- for page in gen:
- count += 1
- finalText.append(u'%s: %d' % (template, count))
- for line in finalText:
- wikipedia.output(line)
-
-def main():
- doCount = False
- argsList = []
- namespaces = []
- for arg in wikipedia.handleArgs():
- if arg == '-count':
- doCount = True
- elif arg.startswith('-namespace:'):
- try:
- namespaces.append(int(arg[len('-namespace:'):]))
- except ValueError:
- namespaces.append(arg[len('-namespace:'):])
- else:
- argsList.append(arg)
-
- if doCount:
- robot = ReferencesRobot()
- if not argsList:
- argsList = templates
- choice = ''
- if 'reflist' in argsList:
- wikipedia.output(u'NOTE: it will take a long time to count "reflist".')
- choice = wikipedia.inputChoice(u'Proceed anyway?', ['yes', 'no', 'skip'], ['y', 'n', 's'], 'y')
- if choice == 's':
- argsList.remove('reflist')
- if choice <> 'n':
- robot.countRefs(argsList, namespaces)
- else:
- wikipedia.showHelp('refcheck')
-
-if __name__ == "__main__":
- try:
- main()
- finally:
- wikipedia.stopme()
-
Modified: trunk/pywikipedia/templatecount.py
===================================================================
--- trunk/pywikipedia/templatecount.py 2009-10-30 06:00:55 UTC (rev 7573)
+++ trunk/pywikipedia/templatecount.py 2009-10-30 09:51:24 UTC (rev 7574)
@@ -1,3 +1,5 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
"""
This script will display the list of pages transcluding a given list of templates.
It can also be used to simply count the number of pages (rather than listing each
@@ -7,10 +9,12 @@
Command line options:
--count Counts the number of times each template (passed in as an argument)
- is transcluded.
--list Gives the list of all of the pages transcluding the templates (rather
- than just counting them).
+-count Counts the number of times each template (passed in as an
+ argument) is transcluded.
+
+-list Gives the list of all of the pages transcluding the templates
+ (rather than just counting them).
+
-namespace: Filters the search to a given namespace. If this is specified
multiple times it will search all given namespaces
@@ -25,6 +29,9 @@
python templatecount.py -list -namespace:14 cfd cfdu
"""
+#
+# Distributed under the terms of the MIT license.
+#
__version__ = '$Id$'
import wikipedia, config
@@ -32,17 +39,20 @@
import re, sys, string
import datetime
+templates = ['ref', 'note', 'ref label', 'note label', 'reflist']
+
class TemplateCountRobot:
#def __init__(self):
#Nothing
def countTemplates(self, templates, namespaces):
mysite = wikipedia.getSite()
+ mytpl = mysite.template_namespace()+':'
finalText = [u'Number of transclusions per template',u'------------------------------------']
total = 0
# The names of the templates are the keys, and the numbers of transclusions are the values.
templateDict = {}
for template in templates:
- gen = pagegenerators.ReferringPageGenerator(wikipedia.Page(mysite, mysite.template_namespace() + ':' + template), onlyTemplateInclusion = True)
+ gen = pagegenerators.ReferringPageGenerator(wikipedia.Page(mysite, mytpl + template), onlyTemplateInclusion = True)
if namespaces:
gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces)
count = 0
@@ -50,7 +60,7 @@
count += 1
templateDict[template] = count
finalText.append(u'%s: %d' % (template, count))
- total = total + count
+ total += count
for line in finalText:
wikipedia.output(line, toStdout=True)
wikipedia.output(u'TOTAL: %d' % total, toStdout=True)
@@ -105,8 +115,16 @@
else:
robot = TemplateCountRobot()
if not argsList:
- argsList = ['ref', 'note', 'ref label', 'note label']
- if operation == "Count":
+ argsList = templates
+ choice = ''
+ if 'reflist' in argsList:
+ wikipedia.output(u'NOTE: it will take a long time to count "reflist".')
+ choice = wikipedia.inputChoice(u'Proceed anyway?', ['yes', 'no', 'skip'], ['y', 'n', 's'], 'y')
+ if choice == 's':
+ argsList.remove('reflist')
+ if choice == 'n':
+ return
+ elif operation == "Count":
robot.countTemplates(argsList, namespaces)
elif operation == "List":
robot.listTemplates(argsList, namespaces)
Revision: 7572
Author: alexsh
Date: 2009-10-29 21:02:26 +0000 (Thu, 29 Oct 2009)
Log Message:
-----------
Simple handle google search from AJAX Search API
Modified Paths:
--------------
trunk/pywikipedia/config.py
trunk/pywikipedia/pagegenerators.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2009-10-29 20:48:49 UTC (rev 7571)
+++ trunk/pywikipedia/config.py 2009-10-29 21:02:26 UTC (rev 7572)
@@ -324,8 +324,16 @@
# you must install the pyGoogle module from http://pygoogle.sf.net/ and have a
# Google Web API license key. Note that Google doesn't give out license keys
# anymore.
+# --------------------
+# Google web API is obsoleted for long time, now we can use Google AJAX Search API,
+# You can signup an API key from http://code.google.com/apis/ajaxsearch/signup.html.
google_key = ''
+
+# using Google AJAX Search API, it require the refer website, this variable save the refer web address
+# when you sign up the Key.
+google_api_refer = ''
+
# Some scripts allow using the Yahoo! Search Web Services. To use this feature,
# you must install the pYsearch module from http://pysearch.sourceforge.net/
# and get a Yahoo AppID from http://developer.yahoo.com
Modified: trunk/pywikipedia/pagegenerators.py
===================================================================
--- trunk/pywikipedia/pagegenerators.py 2009-10-29 20:48:49 UTC (rev 7571)
+++ trunk/pywikipedia/pagegenerators.py 2009-10-29 21:02:26 UTC (rev 7572)
@@ -551,18 +551,43 @@
def queryGoogle(self, query):
#if config.google_key:
if True:
- #try:
+ try:
for url in self.queryViaSoapApi(query):
yield url
return
- #except ImportError:
- #pass
+ except ImportError:
+ for u in self.queryViaAPI(query):
+ yield u
+ return
# No google license key, or pygoogle not installed. Do it the ugly way.
#for url in self.queryViaWeb(query):
# yield url
+ def queryViaAPI(self, query):
+ import json
+ url = u'http://ajax.googleapis.com/ajax/services/search/web?'
+ params = {
+ 'key': config.google_key,
+ 'v':'1.0',
+ 'q': query,
+ }
+ url += urllib.urlencode(params)
+
+ while True:
+ try:
+ wikipedia.output(u'Querying Google AJAX Search API...') #, offset %i' % offset)
+ result = json.loads(self.site.getUrl(url, refer = config.google_api_refer, no_hostname=True))
+ for res in result['responseData']['results']:
+ yield res['url']
+ except:
+ wikipedia.output(u"An error occured. Retrying in 10 seconds...")
+ time.sleep(10)
+ continue
+
+
def queryViaSoapApi(self, query):
import google
+
google.LICENSE_KEY = config.google_key
offset = 0
estimatedTotalResultsCount = None
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2009-10-29 20:48:49 UTC (rev 7571)
+++ trunk/pywikipedia/wikipedia.py 2009-10-29 21:02:26 UTC (rev 7572)
@@ -5448,8 +5448,8 @@
return response, data
- def getUrl(self, path, retry = None, sysop = False, data = None,
- compress = True, no_hostname = False, cookie_only=False, back_response=False):
+ def getUrl(self, path, retry = None, sysop = False, data = None, compress = True,
+ no_hostname = False, cookie_only=False, refer=None, back_response=False):
"""
Low-level routine to get a URL from the wiki.
@@ -5486,6 +5486,8 @@
url = path # and other useful pages without using some other functions.
else:
url = '%s://%s%s' % (self.protocol(), self.hostname(), path)
+ if refer:
+ uo.addheader('Refer', refer)
data = self.urlEncode(data)
# Try to retrieve the page until it was successfully loaded (just in
Revision: 7571
Author: russblau
Date: 2009-10-29 20:48:49 +0000 (Thu, 29 Oct 2009)
Log Message:
-----------
Upload by URL now working (at least on test:test), it was a server-side problem, adjusting client code accordingly.
Modified Paths:
--------------
branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/site.py
===================================================================
--- branches/rewrite/pywikibot/site.py 2009-10-29 19:06:13 UTC (rev 7570)
+++ branches/rewrite/pywikibot/site.py 2009-10-29 20:48:49 UTC (rev 7571)
@@ -2619,8 +2619,6 @@
raise pywikibot.Error(
"User '%s' is not authorized to upload by URL on site %s."
% (self.user(), self))
- # doesn't work yet
- raise NotImplementedError("Upload by URL not yet implemented")
req = api.Request(site=self, action="upload", token=token,
filename=imagepage.title(withNamespace=False),
url=source_url, comment=comment)
@@ -2635,32 +2633,12 @@
raise
result = result["upload"]
pywikibot.output(result, level=pywikibot.DEBUG)
- if source_url:
- # get session key from result
- key = result["upload_session_key"]
- pywikibot.output(u"Asynchronous upload started.")
- time.sleep(1)
- while True:
- # get upload status
- statusrequest = api.Request(site=self, action="upload",
- token=token, httpstatus="",
- sessionkey=str(key))
- status = statusrequest.submit()
- status = status["upload"]
- if int(status["loaded"]) != int(status["content_length"]):
- pywikibot.output(
- u" %(loaded)s out of %(content_length)s bytes loaded..."
- % status)
- continue
- # notify the user, since I have no idea what else to do at this point
- pywikibot.output(str(status))
- return
if "warnings" in result:
warning = result["warnings"].keys()[0]
message = result["warnings"][warning]
raise pywikibot.UploadWarning(upload_warnings[warning]
% {'msg': message})
- else:
+ elif "result" not in result:
pywikibot.output(u"Upload: unrecognized response: %s"
% result)
if result["result"] == "Success":
@@ -2668,7 +2646,7 @@
imagepage._imageinfo = result["imageinfo"]
return
-
+
#### METHODS NOT IMPLEMENTED YET ####
class NotImplementedYet:
Revision: 7570
Author: russblau
Date: 2009-10-29 19:06:13 +0000 (Thu, 29 Oct 2009)
Log Message:
-----------
further upload-by-url code; this option doesn't seem to be working on the server side
Modified Paths:
--------------
branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/site.py
===================================================================
--- branches/rewrite/pywikibot/site.py 2009-10-29 18:05:43 UTC (rev 7569)
+++ branches/rewrite/pywikibot/site.py 2009-10-29 19:06:13 UTC (rev 7570)
@@ -28,6 +28,7 @@
import re
import sys
import threading
+import time
import urllib
logger = logging.getLogger("pywiki.wiki.site")
@@ -2618,6 +2619,8 @@
raise pywikibot.Error(
"User '%s' is not authorized to upload by URL on site %s."
% (self.user(), self))
+ # doesn't work yet
+ raise NotImplementedError("Upload by URL not yet implemented")
req = api.Request(site=self, action="upload", token=token,
filename=imagepage.title(withNamespace=False),
url=source_url, comment=comment)
@@ -2632,6 +2635,26 @@
raise
result = result["upload"]
pywikibot.output(result, level=pywikibot.DEBUG)
+ if source_url:
+ # get session key from result
+ key = result["upload_session_key"]
+ pywikibot.output(u"Asynchronous upload started.")
+ time.sleep(1)
+ while True:
+ # get upload status
+ statusrequest = api.Request(site=self, action="upload",
+ token=token, httpstatus="",
+ sessionkey=str(key))
+ status = statusrequest.submit()
+ status = status["upload"]
+ if int(status["loaded"]) != int(status["content_length"]):
+ pywikibot.output(
+ u" %(loaded)s out of %(content_length)s bytes loaded..."
+ % status)
+ continue
+ # notify the user, since I have no idea what else to do at this point
+ pywikibot.output(str(status))
+ return
if "warnings" in result:
warning = result["warnings"].keys()[0]
message = result["warnings"][warning]
@@ -2639,7 +2662,7 @@
% {'msg': message})
else:
pywikibot.output(u"Upload: unrecognized response: %s"
- % result["result"])
+ % result)
if result["result"] == "Success":
pywikibot.output(u"Upload successful.")
imagepage._imageinfo = result["imageinfo"]
Revision: 7567
Author: xqt
Date: 2009-10-29 17:33:12 +0000 (Thu, 29 Oct 2009)
Log Message:
-----------
actualizing changes from trunk
Modified Paths:
--------------
branches/rewrite/scripts/cosmetic_changes.py
Modified: branches/rewrite/scripts/cosmetic_changes.py
===================================================================
--- branches/rewrite/scripts/cosmetic_changes.py 2009-10-29 17:32:28 UTC (rev 7566)
+++ branches/rewrite/scripts/cosmetic_changes.py 2009-10-29 17:33:12 UTC (rev 7567)
@@ -165,6 +165,7 @@
self.redirect = redirect
self.namespace = namespace
self.template = (self.namespace == 10)
+ self.talkpage = self.namespace >= 0 and self.namespace % 2 == 1
def change(self, text):
"""
@@ -206,7 +207,7 @@
Makes sure that interwiki links are put to the correct position and
into the right order.
"""
- if pywikibot.calledModuleName() <> 'interwiki':
+ if not self.talkpage and pywikibot.calledModuleName() <> 'interwiki':
interwikiLinks = pywikibot.getLanguageLinks(text, insite = self.site)
text = pywikibot.replaceLanguageLinks(text, interwikiLinks, site = self.site, template = self.template)
return text
@@ -253,6 +254,7 @@
titleWithSection = match.group('titleWithSection')
label = match.group('label')
trailingChars = match.group('linktrail')
+ newline = match.group('newline')
if not self.site.isInterwikiLink(titleWithSection):
# The link looks like this:
@@ -331,7 +333,7 @@
# text[[ title | name ]]text -> text [[title|name]] text
# text[[ title |name]]text -> text[[title|name]]text
# text[[title| name]]text -> text [[title|name]]text
- if hadLeadingSpaces:
+ if hadLeadingSpaces and not newline:
newLink = ' ' + newLink
if hadTrailingSpaces:
newLink = newLink + ' '
@@ -346,7 +348,7 @@
# group label is the alternative link title, that's everything between | and ].
# group linktrail is the link trail, that's letters after ]] which are part of the word.
# note that the definition of 'letter' varies from language to language.
- linkR = re.compile(r'\[\[(?P<titleWithSection>[^\]\|]+)(\|(?P<label>[^\]\|]*))?\]\](?P<linktrail>' + self.site.linktrail() + ')')
+ linkR = re.compile(r'(?P<newline>[\n]*)\[\[(?P<titleWithSection>[^\]\|]+)(\|(?P<label>[^\]\|]*))?\]\](?P<linktrail>' + self.site.linktrail() + ')')
text = pywikibot.replaceExcept(text, linkR, handleOneLink, ['comment', 'math', 'nowiki', 'pre', 'startspace'])
return text
@@ -416,7 +418,7 @@
If there are any complaints, please file a bug report.
"""
if not self.redirect:
- text = pywikibot.replaceExcept(text, r'(?m)^(?P<bullet>(\*+|#+):*)(?P<char>[^\s\*#:].+?)', '\g<bullet> \g<char>', ['comment', 'math', 'nowiki', 'pre'])
+ text = pywikibot.replaceExcept(text, r'(?m)^(?P<bullet>[:;]*(\*+|#+)[:;\*#]*)(?P<char>[^\s\*#:;].+?)', '\g<bullet> \g<char>', ['comment', 'math', 'nowiki', 'pre'])
return text
#from fixes.py