Bugs item #2564757, was opened at 2009-02-04 17:47
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2564757&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: redirect.py edits twice
Initial Comment:
If redirect-bot detects a self loop in method fix_double_redirects, it edits twice if sd_template and sd_tagging_sum is defined for the processed language. One for putting the template and one fixing the redirect which is wrong. Of cause it removes the linefeed behind the template the second edit will be done. This diff-link gives an example for that: [http://en.wikipedia.org/w/index.php?title=Talk:Vitamin_K_reactions&diff=pre…]
A quick and dirty fix would be changing the line
else:
break # TODO Better implement loop redirect
to
break # TODO Better implement loop redirect
(delete else: and reduce 1 indention)
but there are no tests or exception handling. I think this is meant by "# TODO Better implement loop redirect"
[w:de:User:Xqt]
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2009-02-24 13:17
Message:
I think this is solved in patch request 2219082.
[w:de:User:Xqt]
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2564757&group_…
Feature Requests item #2633032, was opened at 2009-02-24 10:28
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2633032&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: interwiki
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Milda (milda)
Assigned to: Nobody/Anonymous (nobody)
Summary: Allow multiple interwiki links to one language
Initial Comment:
On Wikisource no autonomous interwiki bots are running, I'm using interwiki.py -confirm to ease of manual work, but I cannot use it if there are more than one page in one language matching to one or more pages in another language. This is typical for translations of well-known literar works, for example http://en.wikisource.org/wiki/The_Raven_(Poe) or http://da.wikisource.org/wiki/Keiserens_nye_Kl%C3%A6der and others.
Is it possible to allow (with new command-line parameter) and process multiple links to the same language domain? At the same time, if more than one interwiki link on some page to one language exist, then is important to keep order of such links, because some domains use extra techniques for displaying additional information, as you can see on The Raven page ({{Interwiki-info|fr1|some description}} refers to the first [[fr:foo]] interwiki link etc.).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2633032&group_…
Bugs item #2602058, was opened at 2009-02-15 08:48
Message generated for change (Comment added) made by aronsson
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2602058&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: interwiki
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Lars Aronsson (aronsson)
Assigned to: Nobody/Anonymous (nobody)
Summary: Interwiki link sorting for Swedish Wikipedia
Initial Comment:
Please modify families/wikipedia_family.py (near line 910) so that interwiki links on the Swedish Wikipedia (sv.wikipedia.org) are sorted by language name (self.interwiki_putfirst = {... 'sv': self.alphabetic, ...}, as for en.wikipedia.org and no.wikipedia.org) rather than by language code (which is the default).
----------------------------------------------------------------------
>Comment By: Lars Aronsson (aronsson)
Date: 2009-02-24 08:08
Message:
An opinion poll turned out 33 in favor of this change and 6 against. There
is no consensus.
----------------------------------------------------------------------
Comment By: Multichill (multichill)
Date: 2009-02-15 12:17
Message:
Do you have community consensus on this?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2602058&group_…
Feature Requests item #1912001, was opened at 2008-03-11 17:29
Message generated for change (Comment added) made by vargenau
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=1912001&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: interwiki
Group: None
>Status: Open
Priority: 5
Private: No
Submitted By: Marc-Etienne Vargenau (vargenau)
Assigned to: Purodha B Blissenbach (purodha)
Summary: Add a new option to interwiki.py
Initial Comment:
Hello,
When working on years or birth categories for instance, I give a huge number of hints.
And I now these hint are right (when they exist).
If there is a wrong link somewhere (e.g. en:category:2000_deaths linking to fr:category:naissance_en_2000), I get a huge number of questions to which I always answer "1" (because the hint is proposed first).
So I propose to create a new option "-hintisright" (or something).
In that case, if there is a conflict between a hint and other page(s), the hint is selected automatically.
----------------------------------------------------------------------
>Comment By: Marc-Etienne Vargenau (vargenau)
Date: 2009-02-24 06:49
Message:
Hello,
Thank you for your interest in my proposal.
I have done some testing.
Your option does not do what I expected.
Here is a real-world example. I want to update the interwikis for year
15.
So I do something like:
python interwiki.py -lang:pt -noredirect 15 \
-hint:aa,ab,af,an,ang,ar,arc,arz,ast,av,ay,az,ba,bat-smg,bcl,be,be-x-old,bg,br,bs,bug,bxr,ca,cbk-zam,ceb,chr,co,cr,crh,cs,csb,cv,cy
\
-hint:da,de,diq,dsb,dv,ee,el,en,eo,es,et,eu,ext,fi,fiu-vro,fo,fr,frp,fur,fy,ga,gd,gl,glk,gn,got,gu,gv,haw,he,hi,hif,hsb,hu,hy
\
-hint:ia,id,ie,ig,ilo,io,is,it,iu,jv,ka,kab,kg,kk,ks,ku,kw,ky,la,lb,li,lij,lmo,ln,lo,lv,map-bms,mdf,mg,mi,mk,ml,mn,ms,mt,mzn
\
-hint:na,nah,nap,nds,nds-nl,nl,nn,no,nov,nrm,nv,ny,oc,om,os,pa,pag,pam,pap,pdc,pih,pl,pms,pt,qu,rm,rmy,ro,roa-rup
\
-hint:sa,sc,scn,sco,sd,se,sg,sh,si,simple,sk,sl,sm,so,sq,sr,ss,stq,su,sv,sw,szl,ta,te,tet,tg,tk,tl,tpi,tr,tt,ty,uk,uz
\
-hint:vec,vi,vls,vo,wa,war,yi,yo,zea,zu
(plus some other hints I did not include for simplicity).
The page ty:15 contains wrong interwiki rights, they point to year 14.
So I am asked to answer I huge number of questions, e.g. between no:14 and
no:15
With the new option, I expected that the link no:14 is ignored since no:15
was provided as a hint and it exists.
Is that more clear?
Best regards,
Marc-Etienne
----------------------------------------------------------------------
Comment By: Purodha B Blissenbach (purodha)
Date: 2009-02-12 13:50
Message:
I gave it a try with -hintsareright
If used, and a hint to an existing page is given, any interlanguage links
to the site of that hint are ignored, and a note "extra interwiki on hinted
site ignored" with the appropriate names is output to the console.
Hints can be given on the command line, in a file, etc. and interactively.
Before interactive hints are knows, i.e. concerning links in the starting
page, -hintsareright has no effect.
It also does not work on hints to sites where there are no pages found. If
you need that, it is an extra feature which, I believe, is a bit more
complicated to implement.
Not using -hintsareright should not make a difference to what we had
before, so I just submitted the change to svn as r 6341 for you to try it
out. Let me know if it fits your needs.
If so, this bug can be closed.
----------------------------------------------------------------------
Comment By: Marc-Etienne Vargenau (vargenau)
Date: 2009-02-03 14:36
Message:
Hello,
Thank you for your comment.
But I do not think the -localright parameter does what I need.
I do not want to modify the local page because I do not want to add links
that do not exist (yet).
I am 100% sure the hint "fr:category:décès_en_2000" (for
"en:category:2000_deaths") is right if it exists, but it might not exist
yet.
Since the code for -localright exists, maybe the code for -hintisright can
be easily implemented.
Best regards,
----------------------------------------------------------------------
Comment By: Purodha B Blissenbach (purodha)
Date: 2009-01-23 18:34
Message:
Hint: You can also solve the problem by inserting all the hints in the
starting page, and use the -localright parameter. If you are uncertain that
you got all, use -confirm and you will be able to interrupt the bot when it
comes accross a missing link which it tries to delete.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=1912001&group_…
Bugs item #2618858, was opened at 2009-02-20 01:39
Message generated for change (Comment added) made by russblau
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2618858&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: rewrite
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: NicDumZ — Nicolas Dumazet (nicdumz)
Assigned to: Russell Blau (russblau)
Summary: logfiles format
Initial Comment:
output created in pagegenerators log after running "python pywikibot/pagegenerators.py -cat:1918 -debug" contains control characters :
2009-02-20 15:28:59 terminal_interface.py, 126: STDOUT Grippe de 1918
[0m
2009-02-20 15:28:59 terminal_interface.py, 126: STDOUT 1918 en bande dessinée
[0m
2009-02-20 15:28:59 terminal_interface.py, 126: STDOUT Armistice de Moudros
[0m
2009-02-20 15:28:59 terminal_interface.py, 126: STDOUT Déclaration d'indépendance de la Lituanie
[0m
2009-02-20 15:28:59 terminal_interface.py, 126: STDOUT Guerre d'indépendance lettone
[0m
2009-02-20 15:28:59 terminal_interface.py, 126: STDOUT 1918
[0m
and so on...
Also, I find it strange to have terminal_interface logging STDOUT, when in fact pagegenerators is calling output() =)
----------------------------------------------------------------------
>Comment By: Russell Blau (russblau)
Date: 2009-02-23 15:32
Message:
This should be fixed after r6431; please advise if the problem is resolved
on your machine.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2618858&group_…
Revision: 6431
Author: russblau
Date: 2009-02-23 19:19:09 +0000 (Mon, 23 Feb 2009)
Log Message:
-----------
Put colorization code in the logging handler, where it belongs, instead of colorizing records that aren't meant to be displayed on a terminal.
Modified Paths:
--------------
branches/rewrite/pywikibot/bot.py
branches/rewrite/pywikibot/userinterfaces/terminal_interface.py
Modified: branches/rewrite/pywikibot/bot.py
===================================================================
--- branches/rewrite/pywikibot/bot.py 2009-02-23 15:14:27 UTC (rev 6430)
+++ branches/rewrite/pywikibot/bot.py 2009-02-23 19:19:09 UTC (rev 6431)
@@ -48,69 +48,21 @@
return True
-class TerminalHandler(logging.Handler):
- """
- A handler class that writes logging records, appropriately formatted,
- to a stream. Note that this class does not close the stream, as
- sys.stdout or sys.stderr may be used.
-
- Slightly modified version of the StreamHandler class that ships with
- logging module.
-
- """
- def __init__(self, strm=None):
- """
- Initialize the handler.
-
- If strm is not specified, sys.stderr is used.
- """
- logging.Handler.__init__(self)
- if strm is None:
- strm = sys.stderr
- self.stream = strm
- self.formatter = None
-
- def flush(self):
- """
- Flush the stream.
- """
- self.stream.flush()
-
- def emit(self, record):
- """
- Emit a record.
-
- If a formatter is specified, it is used to format the record. The
- record is then written to the stream. If exception information is
- present, it is formatted using traceback.print_exception and
- appended to the stream.
- """
- try:
- msg = self.format(record)
- fs = "%s"
- if isinstance(msg, str):
- self.stream.write(fs % msg)
- else:
- try:
- self.stream.write(fs % msg.encode(config.console_encoding,
- "xmlcharrefreplace"))
- except UnicodeError:
- self.stream.write(fs % msg.encode("ascii",
- "xmlcharrefreplace"))
- self.flush()
- except (KeyboardInterrupt, SystemExit):
- raise
- except:
- self.handleError(record)
-
-
-
# User interface initialization
# search for user interface module in the 'userinterfaces' subdirectory
exec ("import pywikibot.userinterfaces.%s_interface as uiModule"
% config.userinterface)
ui = uiModule.UI()
+TerminalHandler = uiModule.TerminalHandler
+
+class RotatingFileHandler(logging.handlers.RotatingFileHandler):
+ """Strip trailing newlines before outputting text to file"""
+ def emit(self, record):
+ record.msg = record.msg.rstrip("\r\n")
+ logging.handlers.RotatingFileHandler.emit(self, record)
+
+
def output(text, decoder=None, newline=True, toStdout=False, level=INFO):
"""Output a message to the user via the userinterface.
@@ -263,7 +215,7 @@
logfile = config.datafilepath(config.logfilename)
else:
logfile = config.datafilepath("%s-bot.log" % moduleName)
- file_handler = logging.handlers.RotatingFileHandler(
+ file_handler = RotatingFileHandler(
filename=logfile, maxBytes=2 << 20, backupCount=5)
file_handler.setLevel(DEBUG)
Modified: branches/rewrite/pywikibot/userinterfaces/terminal_interface.py
===================================================================
--- branches/rewrite/pywikibot/userinterfaces/terminal_interface.py 2009-02-23 15:14:27 UTC (rev 6430)
+++ branches/rewrite/pywikibot/userinterfaces/terminal_interface.py 2009-02-23 19:19:09 UTC (rev 6431)
@@ -119,68 +119,6 @@
self.writelock = threading.RLock()
pass
- def printColorizedInUnix(self, text, level):
- lastColor = None
- for key, value in unixColors.iteritems():
- text = text.replace('\03{%s}' % key, value)
- # just to be sure, reset the color
- text += unixColors['default']
- logging.log(level, text)
-
- def printColorizedInWindows(self, text, level):
- """
- This only works in Python 2.5 or higher.
- """
- if ctypes_found:
- std_out_handle = ctypes.windll.kernel32.GetStdHandle(-11)
- # Color tags might be cascaded, e.g. because of transliteration.
- # Therefore we need this stack.
- colorStack = []
- tagM = True
- while tagM:
- tagM = colorTagR.search(text)
- if tagM:
- # print the text up to the tag.
- logging.log(level, text[:tagM.start()])
- newColor = tagM.group('name')
- if newColor == 'default':
- if len(colorStack) > 0:
- colorStack.pop()
- if len(colorStack) > 0:
- lastColor = colorStack[-1]
- else:
- lastColor = 'default'
- ctypes.windll.kernel32.SetConsoleTextAttribute(std_out_handle, windowsColors[lastColor])
- else:
- colorStack.append(newColor)
- # set the new color
- ctypes.windll.kernel32.SetConsoleTextAttribute(std_out_handle, windowsColors[newColor])
- text = text[tagM.end():]
- # print the rest of the text
- logging.log(level, text)
- # just to be sure, reset the color
- ctypes.windll.kernel32.SetConsoleTextAttribute(std_out_handle, windowsColors['default'])
- else:
- # ctypes is only available since Python 2.5, and we won't
- # try to colorize without it. Instead we add *** after the text as a whole
- # if anything needed to be colorized.
- lines = text.split('\n')
- for line in lines:
- line, count = colorTagR.subn('', line)
- if count > 0:
- line += '***'
- line += '\n'
- logging.log(level, line)
-
- def printColorized(self, text, level):
- if config.colorized_output:
- if sys.platform == 'win32':
- self.printColorizedInWindows(text, level)
- else:
- self.printColorizedInUnix(text, level)
- else:
- logging.log(level, text)
-
def output(self, text, level=logging.INFO):
"""
If a character can't be displayed in the encoding used by the user's
@@ -229,10 +167,9 @@
prev = transliterated[-1:]
prevchar = char
text = u"".join(transliteratedText)
-
self.writelock.acquire()
try:
- self.printColorized(text, level)
+ logging.log(level, text)
finally:
self.writelock.release()
@@ -302,8 +239,6 @@
finally:
self.writelock.release()
return answer
-
-
def editText(self, text, jumpIndex = None, highlight = None):
"""
@@ -327,7 +262,126 @@
import webbrowser
pywikibot.output(u'Opening CAPTCHA in your web browser...')
webbrowser.open(url)
- return pywikibot.input(u'What is the solution of the CAPTCHA that is shown in your web browser?')
+ return pywikibot.input(
+ u'What is the solution of the CAPTCHA that is shown in your web browser?')
except:
- pywikibot.output(u'Error in opening web browser: %s' % sys.exc_info()[0])
- return pywikibot.input(u'What is the solution of the CAPTCHA at %s ?' % url)
+ pywikibot.output(u'Error in opening web browser: %s'
+ % sys.exc_info()[0])
+ return pywikibot.input(
+ u'What is the solution of the CAPTCHA at %s ?' % url)
+
+
+class TerminalHandler(logging.Handler):
+ """A handler class that writes logging records, appropriately formatted, to
+ a stream connected to a terminal. This class does not close the stream,
+ as sys.stdout or sys.stderr may be (and usually will be) used.
+
+ Slightly modified version of the StreamHandler class that ships with
+ logging module, plus code for colorization of output.
+
+ """
+
+ def __init__(self, strm=None):
+ """Initialize the handler.
+
+ If strm is not specified, sys.stderr is used.
+
+ """
+ logging.Handler.__init__(self)
+ if strm is None:
+ strm = sys.stderr
+ self.stream = strm
+ self.formatter = None
+
+ def flush(self):
+ """Flush the stream. """
+ self.stream.flush()
+
+ def emit_raw(self, record, msg):
+ """Emit a formatted message.
+
+ The message is written to the stream. If exception information is
+ present, it is formatted using traceback.print_exception and
+ appended to the stream.
+
+ """
+ try:
+ fs = "%s"
+ if isinstance(msg, str):
+ self.stream.write(fs % msg)
+ else:
+ try:
+ self.stream.write(fs % msg.encode(config.console_encoding,
+ "xmlcharrefreplace"))
+ except UnicodeError:
+ self.stream.write(fs % msg.encode("ascii",
+ "xmlcharrefreplace"))
+ self.flush()
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except:
+ self.handleError(record)
+
+ def emitColorizedInUnix(self, record, msg):
+ lastColor = None
+ for key, value in unixColors.iteritems():
+ msg = msg.replace('\03{%s}' % key, value)
+ # just to be sure, reset the color
+ msg += unixColors['default']
+ self.emit_raw(record, msg)
+
+ def emitColorizedInWindows(self, record, msg):
+ """This only works in Python 2.5 or higher."""
+ if ctypes_found:
+ std_out_handle = ctypes.windll.kernel32.GetStdHandle(-11)
+ # Color tags might be cascaded, e.g. because of transliteration.
+ # Therefore we need this stack.
+ colorStack = []
+ tagM = True
+ while tagM:
+ tagM = colorTagR.search(msg)
+ if tagM:
+ # print the text up to the tag.
+ self.emit_raw(record, msg[:tagM.start()])
+ newColor = tagM.group('name')
+ if newColor == 'default':
+ if len(colorStack) > 0:
+ colorStack.pop()
+ if len(colorStack) > 0:
+ lastColor = colorStack[-1]
+ else:
+ lastColor = 'default'
+ ctypes.windll.kernel32.SetConsoleTextAttribute(
+ std_out_handle, windowsColors[lastColor])
+ else:
+ colorStack.append(newColor)
+ # set the new color
+ ctypes.windll.kernel32.SetConsoleTextAttribute(
+ std_out_handle, windowsColors[newColor])
+ msg = msg[tagM.end():]
+ # print the rest of the text
+ self.emit_raw(record, msg)
+ # just to be sure, reset the color
+ ctypes.windll.kernel32.SetConsoleTextAttribute(
+ std_out_handle, windowsColors['default'])
+ else:
+ # ctypes is only available since Python 2.5, and we won't
+ # try to colorize without it. Instead we add *** after the text
+ # as a whole if anything needed to be colorized.
+ lines = msg.split('\n')
+ for line in lines:
+ line, count = colorTagR.subn('', line)
+ if count > 0:
+ line += '***'
+ line += '\n'
+ self.emit_raw(record, line)
+
+ def emit(self, record):
+ msg = self.format(record)
+ if config.colorized_output:
+ if sys.platform == 'win32':
+ self.emitColorizedInWindows(record, msg)
+ else:
+ self.emitColorizedInUnix(record, msg)
+ else:
+ self.emit_raw(record, msg)
Feature Requests item #2631168, was opened at 2009-02-23 18:56
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2631168&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: interwiki summary should tell deletion reason
Initial Comment:
If removing a interwiki link, the summary should tell about the reason for this (disambig, namespace, missing page). This would ensure better control of the bot if its removing links which often leads to problems and some trouble. Some abbrev. would be ok; sth. like would help:
deleting: de, en (dg); fi, fr (ns); af, bg (mp)
<w:de:User:Xqt>
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2631168&group_…