Revision: 4337
Author: wikipedian
Date: 2007-09-21 01:21:51 +0000 (Fri, 21 Sep 2007)
Log Message:
-----------
hack to enable windows users of replace.py to use linebreaks
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2007-09-20 14:51:04 UTC (rev 4336)
+++ trunk/pywikipedia/wikipedia.py 2007-09-21 01:21:51 UTC (rev 4337)
@@ -2656,6 +2656,15 @@
else:
# We found a valid match. Replace it.
+ # This is a hack for Windows users. As they're unable to enter real
+ # linebreaks in the command prompt, this line allows them to enter
+ # backslash-n instead.
+ # This means that it is impossible replace a string with a real
+ # backslash-n sequence (it will always become a linebreak), but
+ # it is unprobable that someone will want to do that.
+ if sys.platform=='win32':
+ new = new.replace('\\n', '\n')
+
# We cannot just insert the new string, as it may contain regex
# group references such as \2 or \g<name>.
# On the other hand, this approach does not work because it can't
Bugs item #1769869, was opened at 2007-08-08 11:11
Message generated for change (Comment added) made by wikipedian
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1769869&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: other
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Filnik (filnik)
Assigned to: Nobody/Anonymous (nobody)
Summary: replace.py has problem with "\n"
Initial Comment:
I have tried with:
replace.py -regex -cat:Dipinti_di_Kandinsky "\[\[[Cc]ategoria:[Dd]ipinti[ _]di[ _][Kk]andinsky\]\]" "[[Categoria:Dipinti di Kandinsky]]\n[[Categoria:Dipinti astratti]]" -summary:"Bot: Aggiungo categoria"
but the "\n" isn't converted into a new line... Bryan and valhallasw has said that it should work but it doesn't... can anyone check if the \n is converted properly? Thanx, Filnik
----------------------------------------------------------------------
>Comment By: Daniel Herding (wikipedian)
Date: 2007-09-20 22:25
Message:
Logged In: YES
user_id=880694
Originator: NO
This should be fixed. You can now use \n inside the replacement when
you're using Windows.
Note that this isn't a fix for a PyWikipediaBot bug, but a workaround for
a Windows problem.
----------------------------------------------------------------------
Comment By: Falk Steinhauer (falk_steinhauer)
Date: 2007-08-08 23:08
Message:
Logged In: YES
user_id=1810075
Originator: NO
As I know, the windows console isn't able to take special characters like
newline or backslash as arguments.
So every time I need one of those characters, I enter them manually in
function doReplacements() of module replace.py.
For instance:
def doReplacements(self, original_text):
"""
Returns the text which is generated by applying all replacements
to the
given text.
"""
new_text = original_text
# dirty trick for special characters:
self.replacements = []
self.replacements.append( ('RegExp','Replacement') )
for old, new in self.replacements:
new_text = wikipedia.replaceExcept(new_text, old, new,
['nowiki', 'comment', 'math', 'pre'], allowoverlap = self.allowoverlap)
return new_text
Because this works, it cannot be a bug in replace.py.
----------------------------------------------------------------------
Comment By: Aurimas Fischer (ebola_rulez)
Date: 2007-08-08 13:10
Message:
Logged In: YES
user_id=959303
Originator: NO
It worked before, I used this several months ago (from my fixes.py):
(u'\{\{Taxobox_pradžia ?\|
?(.*?)}}(\r\n|\n)(\{\{Taxobox_begin_placement)', ur'{{Taxobox_pradžia |
\1}}\n{{Taxobox_paveiksliukas | image = | caption = }}\2\3')
And now it doesn't
----------------------------------------------------------------------
Comment By: Daniel Herding (wikipedian)
Date: 2007-08-08 12:22
Message:
Logged In: YES
user_id=880694
Originator: NO
In Linux, it is possible to just press enter to create a newline, as long
as the string is inside quoataion marks.
-----------------------
daniel@localhost:~/projekte/pywikipedia> python replace.py mp "m
> p" -page:Wikipedia:Spielwiese
Checked for running processes. 1 processes currently running, including
the current process.
Getting 1 pages from wikipedia:de...
>>> Wikipedia:Spielwiese <<<
- Example
+ Exam
+ ple
Do you want to accept these changes? ([y]es, [N]o, [a]ll)
-----------------------
I don't know if that's possible in Windows. At least in the replacement
part, you cannot use the \n even in Linux.
----------------------------------------------------------------------
Comment By: Filnik (filnik)
Date: 2007-08-08 11:24
Message:
Logged In: YES
user_id=1834469
Originator: YES
It doesn't work :'( see:
http://it.wikipedia.org/w/index.php?title=Composizione_%28Kandinsky_1916%29…
----------------------------------------------------------------------
Comment By: Aurimas Fischer (ebola_rulez)
Date: 2007-08-08 11:19
Message:
Logged In: YES
user_id=959303
Originator: NO
Try using \r\n for newline
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1769869&group_…
Patches item #1798753, was opened at 2007-09-20 15:23
Message generated for change (Comment added) made by wikipedian
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1798753&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: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Filnik (filnik)
Assigned to: Nobody/Anonymous (nobody)
Summary: Fixed the \n problem - second patch (working)
Initial Comment:
Some times ago, I've asked to fix the bug in replace.py that doesn't replace \n with a newline. I've add two lines on wikipedia.py to prevent this bug (it works and shouldn't make problems also if it is done in a simple way). The patch for wikipedia.py is attached. Filnik
----------------------------------------------------------------------
>Comment By: Daniel Herding (wikipedian)
Date: 2007-09-20 22:23
Message:
Logged In: YES
user_id=880694
Originator: NO
Applied it, with added comments and a restriction to win32.
----------------------------------------------------------------------
Comment By: Filnik (filnik)
Date: 2007-09-20 17:08
Message:
Logged In: YES
user_id=1834469
Originator: YES
Yeah, you're right. This patch (what I've attached this time) shouldn't
have problems. Bye, Filnik
File Added: wikipedia.patch
----------------------------------------------------------------------
Comment By: Daniel Herding (wikipedian)
Date: 2007-09-20 16:45
Message:
Logged In: YES
user_id=880694
Originator: NO
This is not safe. See:
http://de.wikipedia.org/w/index.php?title=Benutzer:Head/Spielwiese&diff=369…
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1798753&group_…
Bugs item #1588728, was opened at 2006-11-01 17:28
Message generated for change (Comment added) made by malafaya
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1588728&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: Fixed
Priority: 5
Private: No
Submitted By: mandavi (mandavi)
Assigned to: Leonardo Gregianin (leogregianin)
Summary: {{link FA|xx}} are beeing moved away from the interwiki
Initial Comment:
The templates {{link FA|xx}} get moved by the
interwiki.py to the top of the interwikis. that is not
nice - i've provided a patch - find it in patches.
----------------------------------------------------------------------
Comment By: André Malafaya Baptista (malafaya)
Date: 2007-09-20 18:10
Message:
Logged In: YES
user_id=1037345
Originator: NO
I had users from some Wikis complaining about this same issue: {{LinkFA}}
being moved to top of interwikis instead of being placed right next to the
corresponding interwiki.
I would suggest a language/wiki dependent behavior:
1) moving LinkFA to top of interwikis
2) placing LinkFA right next to corresponding interwiki
Of course, an array relating languages and behaviors would be needed.
----------------------------------------------------------------------
Comment By: siebrand (siebrand)
Date: 2007-04-26 20:29
Message:
Logged In: YES
user_id=1107255
Originator: NO
Please let us know if this bug report is still applicable to the current
code. If no response is given, the bug report will be closed one month from
now. This message was added in an effort to reduce the number of open
issues on this project. Siebrand
----------------------------------------------------------------------
Comment By: mandavi (mandavi)
Date: 2006-12-15 15:39
Message:
Logged In: YES
user_id=1105015
Originator: YES
I disagree, instead I am working on a better solution than provided so far
for interwiki.py to sort the templates behind the the interwiki since
otherwise the source of articles becomes unnecessary longer and more
confusing.
----------------------------------------------------------------------
Comment By: Leonardo Gregianin (leogregianin)
Date: 2006-12-15 13:44
Message:
Logged In: YES
user_id=1136737
Originator: NO
featured.py 1.20 put template before the category and interwiki, the same
that interwiki.py makes.
leonardo.
----------------------------------------------------------------------
Comment By: mandavi (mandavi)
Date: 2006-12-14 14:46
Message:
Logged In: YES
user_id=1105015
Originator: YES
Right, and since a name change in an excellent rated article is very
unlikely, the {{Link FA|xx}} should be removed along with the link change.
----------------------------------------------------------------------
Comment By: mandavi (mandavi)
Date: 2006-12-14 10:20
Message:
Logged In: YES
user_id=1105015
Originator: YES
Right, and since a name change in an excellent rated article is very
unlikely, the {{Link FA|xx}} should be removed along with the link change.
----------------------------------------------------------------------
Comment By: ChongDae (cdpark)
Date: 2006-12-14 08:11
Message:
Logged In: YES
user_id=1274526
Originator: NO
When the link is changed, {{link FA}} could not be up-to-date. It had to
be fixed more carefully.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1588728&group_…
Bugs item #1790289, was opened at 2007-09-07 16:54
Message generated for change (Settings changed) made by malafaya
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1790289&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: Deleted
Resolution: None
Priority: 1
Private: No
Submitted By: André Malafaya Baptista (malafaya)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add disambiguation template for Polish
Initial Comment:
When processing Wikipedia article [[en:RSS]], link to [[pl:RSS]] was found. Although, this Polish article is a disambiguation page marked with {{DisambigR}} which is not contemplated in wikipedia_family.py for disambiguation templates. Therefore, I would get a duplicated link to [[pl:]] and processing would abort. By ignoring [[pl:RSS]] I managed to process the article.
Plase add DisambigR to the Polish disambiguation templates:
'pl': [u'Disambig', u'DisambRulers', u'DisambigC', u'Strona ujednoznaczniająca', u'DisambigR'],
in line 433 of wikipedia_family.py.
Thanks.
----------------------------------------------------------------------
Comment By: André Malafaya Baptista (malafaya)
Date: 2007-09-11 18:46
Message:
Logged In: YES
user_id=1037345
Originator: YES
Sorry, I don't have a clue. I'm not a contributor to the Polish Wikipedia
as I'm not even Polish.
----------------------------------------------------------------------
Comment By: Daniel Herding (wikipedian)
Date: 2007-09-07 23:54
Message:
Logged In: YES
user_id=880694
Originator: NO
I also think this is more like {{otheruses}} on en:, not a template for
disambiguation pages.
BTW, Can we remove DisambRulers and DisambigC? They seem to have been
deleted.
----------------------------------------------------------------------
Comment By: André Malafaya Baptista (malafaya)
Date: 2007-09-07 17:06
Message:
Logged In: YES
user_id=1037345
Originator: YES
I'm not so sure about this:
it seems another page exists in Polish [[pl:RSS (ujednoznaczniająca)]]
which is the *real* disambiguation page. The one above [[pl:RSS]] is
another kind of "more specific" disambiguation page, only for informatic
terms...
Maybe it's better not to do anything until further information is
obtained.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1790289&group_…
Bugs item #1773949, was opened at 2007-08-14 11:31
Message generated for change (Comment added) made by leogregianin
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1773949&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: Accepted
Priority: 3
Private: No
Submitted By: Falk Steinhauer (falk_steinhauer)
Assigned to: Leonardo Gregianin (leogregianin)
Summary: wrong argument description of movepages.py
Initial Comment:
I am using snapshot 2007-06-19.
The commandline help of movepages.py shows an option called "-addprefix", but the respective option in the sourcecode is spelled "-prefix".
Users that are not able to understand the sourcecode might not be able to understand how to call the script.
Another thing is, that this script is not using page title highlighting like replace.py when user interaction is desired. The first line in "def treat(self,page)" should be:
colors = [None] * 6 + [13] * len(page.title()) + [None] * 4
----------------------------------------------------------------------
>Comment By: Leonardo Gregianin (leogregianin)
Date: 2007-09-20 12:38
Message:
Logged In: YES
user_id=1136737
Originator: NO
See this snapshot http://tools.wikimedia.de/~valhallasw/pywiki/
----------------------------------------------------------------------
Comment By: Falk Steinhauer (falk_steinhauer)
Date: 2007-09-13 04:06
Message:
Logged In: YES
user_id=1810075
Originator: YES
Bug still exists in snapshot 2007-08-11.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1773949&group_…
Patches item #1798753, was opened at 2007-09-20 13:23
Message generated for change (Comment added) made by filnik
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1798753&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: Rejected
Priority: 5
Private: No
Submitted By: Filnik (filnik)
Assigned to: Nobody/Anonymous (nobody)
>Summary: Fixed the \n problem - second patch (working)
Initial Comment:
Some times ago, I've asked to fix the bug in replace.py that doesn't replace \n with a newline. I've add two lines on wikipedia.py to prevent this bug (it works and shouldn't make problems also if it is done in a simple way). The patch for wikipedia.py is attached. Filnik
----------------------------------------------------------------------
>Comment By: Filnik (filnik)
Date: 2007-09-20 15:08
Message:
Logged In: YES
user_id=1834469
Originator: YES
Yeah, you're right. This patch (what I've attached this time) shouldn't
have problems. Bye, Filnik
File Added: wikipedia.patch
----------------------------------------------------------------------
Comment By: Daniel Herding (wikipedian)
Date: 2007-09-20 14:45
Message:
Logged In: YES
user_id=880694
Originator: NO
This is not safe. See:
http://de.wikipedia.org/w/index.php?title=Benutzer:Head/Spielwiese&diff=369…
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1798753&group_…
Patches item #1794859, was opened at 2007-09-14 19:04
Message generated for change (Comment added) made by pietrodn
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1794859&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: Closed
Resolution: Fixed
Priority: 8
Private: No
Submitted By: Pietrodn (pietrodn)
Assigned to: Nobody/Anonymous (nobody)
Summary: replace.py "exceptions" patch
Initial Comment:
template.py gives this error:
pietro$ python template.py "Corso di inglese" "Inglese"
Checked for running processes. 2 processes currently running, including the current process.
Getting references to [[Template:Corso di inglese]]
Getting 31 pages from wikibooks:it...
Traceback (most recent call last):
File "template.py", line 392, in <module>
main()
File "template.py", line 388, in main
bot.run()
File "template.py", line 310, in run
replaceBot.run()
File "/Users/pietro/Applications/pywikipedia/replace.py", line 295, in run
if self.isTitleExcepted(page.title()):
File "/Users/pietro/Applications/pywikipedia/replace.py", line 246, in isTitleExcepted
if self.exceptions.has_key('title'):
AttributeError: 'list' object has no attribute 'has_key'
This because "exceptions" is treated as a dict by replace.py, but it is a list and it must iterate through it.
Here is a patch to replace.py.
----------------------------------------------------------------------
>Comment By: Pietrodn (pietrodn)
Date: 2007-09-20 17:06
Message:
Logged In: YES
user_id=1887175
Originator: YES
Hello wikipedian! Thank you for your answer.
You're right! In replace.py, in main, there are the following lines:
<pre>
# Don't edit pages which contain certain texts.
exceptions = {
'title': [],
'text-contains': [],
'inside': [],
'inside-tags': [],
}
</pre>
I didn't see them, my solution was incorrect. Thank you for the fix :-)
Pietrodn
----------------------------------------------------------------------
Comment By: Daniel Herding (wikipedian)
Date: 2007-09-20 16:52
Message:
Logged In: YES
user_id=880694
Originator: NO
Thanks for your report. Your observation is correct, however, your
solution doesn't seem to be. Instead, I fixed the problem by setting
exceptions = {} instead of []. Please test the current SVN version.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1794859&group_…
Patches item #1794859, was opened at 2007-09-14 19:04
Message generated for change (Comment added) made by wikipedian
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1794859&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: Closed
>Resolution: Fixed
Priority: 8
Private: No
Submitted By: Pietrodn (pietrodn)
Assigned to: Nobody/Anonymous (nobody)
Summary: replace.py "exceptions" patch
Initial Comment:
template.py gives this error:
pietro$ python template.py "Corso di inglese" "Inglese"
Checked for running processes. 2 processes currently running, including the current process.
Getting references to [[Template:Corso di inglese]]
Getting 31 pages from wikibooks:it...
Traceback (most recent call last):
File "template.py", line 392, in <module>
main()
File "template.py", line 388, in main
bot.run()
File "template.py", line 310, in run
replaceBot.run()
File "/Users/pietro/Applications/pywikipedia/replace.py", line 295, in run
if self.isTitleExcepted(page.title()):
File "/Users/pietro/Applications/pywikipedia/replace.py", line 246, in isTitleExcepted
if self.exceptions.has_key('title'):
AttributeError: 'list' object has no attribute 'has_key'
This because "exceptions" is treated as a dict by replace.py, but it is a list and it must iterate through it.
Here is a patch to replace.py.
----------------------------------------------------------------------
>Comment By: Daniel Herding (wikipedian)
Date: 2007-09-20 16:52
Message:
Logged In: YES
user_id=880694
Originator: NO
Thanks for your report. Your observation is correct, however, your
solution doesn't seem to be. Instead, I fixed the problem by setting
exceptions = {} instead of []. Please test the current SVN version.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1794859&group_…