Happy Monday,
There are strange people who make such links (kindof urlencoded?):
[[Második világháború#Partrasz.C3.A1ll.C3.A1s Szic.C3.ADli.C3.A1ban
.28Huskey hadm.C5.B1velet.29|Huskey hadműveletben]]
So the section title must have been copied from the URL.
Do we have a ready tool to fix these?
--
Bináris
Hi!
My old problem is that repalce.py can't write the pages to work on into a
file on my disk. I have used a modificated version for years that does no
changes but writes the title of the involved pages to a subpage on Wikipedia
in automated mode, and then I can make the replacements from that page much
more quickly than directly from dump or living Wikipedia. This is slow and
generates a plenty of dummy edits.
In other words, replace.py has a tool to get the titles from a file (-file)
or from a wikipage (-links), but has no tool to generate this file.
Now I am ready to rewrite it. This way we can start it and the bot will find
all the possible articles to work on and save the titles without editing
Wikipedia (and without artificial delay), meanwhile we can have the lunch or
run a marathon or sleep. Then we make the replacements from this with -file.
My idea is that replace.py should have two new parameters:
-save writes the results into a new file instead of editing articles. It
overwrites existing file without notice.
-saveappend writes into a file or appends to the existing one.
OR:
-save writes and appends (primary mode)
-savenew writes and overwrites
The help is here:
http://docs.python.org/howto/unicode.html#reading-and-writing-unicode-data
So we have to import codecs.
My script is:
articles=codecs.open('cikkek.txt','a',encoding='utf-8')
...
tutuzuzu=u'# %s\n' %page.aslink() <-- needs rewrite to the new syntax
articles.write(unicode(tutuzuzu)) <-- needs further testing, if nicode() is
really needed
articles.flush()
It works fine except '\n' is a unix-styled newline that has to be converted
by lfcr.py in order to make it readable with notepad.exe.
This is with constant filename, that should be developed to get from command
line.
Your opinions before I begin?
--
Bináris
I want to read a special page with Page.get(). The message is:
File "C:\Program Files\Pywikipedia\wikipedia.py", line 601, in get
raise NoPage('%s is in the Special namespace!' % self.aslink())
pywikibot.exceptions.NoPage
What is the solution?
--
Bináris
Hi,
I would like to get an SVN access and some help to start.
I need it mainly for inserting and maintaining TOCbot that is under
preparation (it has worked in huwiki for several months and is now being
internationalized).
Information about TOCbot:
http://hu.wikipedia.org/wiki/Szerkeszt%C5%91:Bin%C3%A1ris/TOCbot
Description, user guide and bot owners' guide and a collection of examples
is ready as well as an auxilary script, while the main script is not yet
public. It will soon be published for test and may need much care in the
first time.
I would also like to take part in maintenance of replace.py for what I
worked a lot already.
At the moment I am interested only in trunk version.
My SF page: http://sourceforge.net/users/binbot/ -- I don't know how to list
all my contributions, here appears a part of them since May 22, but there
are much more. I have also been active on mailing list in the past years.
Please support and give me technical help to use the system.
--
Bináris
Hi,
I try to run upload.py under Windows 7.
Installed: Python 2.7
Pywikipediabot: Latest from SVN
Executing this line from Windows PowerShell:
c:\python27\python.exe D:\F_Programmierung\pywikipedia\upload.py -keep
-log:upload.log -filename:"Kulturpreis der Sparkassen-Kulturstiftung
Rheinland 2011-5606.jpg" -noverify "D:\Eigene Bilder\WP
Bilder\Kulturpreis der Sparkassen-Kulturstiftung Rheinland
2011-5606.jpg" "== {{int:filedesc}} ==......."
results into "No input filename given".
Same error if I simplify the line to
c:\python27\python.exe D:\F_Programmierung\pywikipedia\upload.py
-filename:xxx.jph .\xxx.jpg "...."
Yes, the pathes are correct.
Any ideas? Thanks.
Raimond.
On Mon, Apr 25, 2011 at 7:49 AM, Merlijn van Deen <valhallasw(a)arctus.nl> wrote:
> Whoo! Great work :-) Tests always are good contributions :-)
Thanks ;-)
I agree.
> On a sidenote - is there a reason you're implementing these in 'trunk' and
> not in 'rewrite'? Of course, these contributions are very welcome in the
> trunk, but I still think it would be good to push the rewrite branch.
I'm working off trunk because it is trunk.
I'd assumed that the rewrite branch was a single-purpose branch to
rewrite something, and that it would be merged back when it is stable.
Is it stable?
Is there any documentation on what the plans are for the rewrite branch?
Is there a roadmap to finish it?
Is see now that the rewrite branch has more unit tests, but more are needed.
Is there a need to create a backwards compatibility layer?
Or, is everyone except me using the rewrite branch? ;-)
--
John Vandenberg
Sorry for starting a new thread, I just suscribed.
I ran into the same problem today and I think I know how to fix it.
On userlib.py there are several checks before attempting to raise a block
def block(self, expiry=None, reason=None, anon=True, noCreate=False,
onAutoblock=False, banMail=False, watchUser=False, allowUsertalk=True,
reBlock=False, hidename=False):
if self._isAutoblock:
#This user is probably being queried for purpose of lifting
#an autoblock, so can't be blocked.
raise AutoblockUser
if self.isBlocked() and not reBlock:
raise AlreadyBlocked()
if not self.site().isAllowed('block', sysop=True):
raise UserActionRefuse('You don\'t have permission to block')
if not expiry:
expiry = pywikibot.input(u'Please enter the expiry time
for the block:')
if not reason:
reason = pywikibot.input(u'Please enter a reason for the block:')
if (not self.site().has_api()) or self.site().versionnumber() < 12:
return self._blockOld(expiry, reason, anon, noCreate,
onAutoblock, banMail, watchUser,
allowUsertalk, reBlock)
params = {
'action': 'block',
'user': self.name(),
'token': self.site().getToken(self, sysop = True),
'reason': reason,
}
Notice last check: If the site doesn't have an API or version number
is too old, then use a deprecated function to raise the block.
We could add a check there as in
if self.isAnonymous() or (not self.site().has_api()) or
self.site().versionnumber() < 12:
so if user is an IP, goes to the old method. However the error would
persist. This because the checks above also need a user
(user.isBlocked() fails for IP).
quick hack would be moving this check at the top:
def block(self, expiry=None, reason=None, anon=True, noCreate=False,
onAutoblock=False, banMail=False, watchUser=False, allowUsertalk=True,
reBlock=False, hidename=False):
if self.isAnonymous() or (not self.site().has_api()) or
self.site().versionnumber() < 12:
return self._blockOld(expiry, reason, anon, noCreate,
onAutoblock, banMail, watchUser,
allowUsertalk, reBlock)
if self._isAutoblock:
#This user is probably being queried for purpose of lifting
#an autoblock, so can't be blocked.
raise AutoblockUser
if self.isBlocked() and not reBlock:
raise AlreadyBlocked()
This way, if user = IP, goes directly into the depprecated ol method
and doesn't execute the API-useronly functions.
Now running gives
:!python bloqueador.py
Bloqueando 128.163.142.21
Traceback (most recent call last):
File "bloqueador.py", line 86, in <module>
main()
File "bloqueador.py", line 79, in main
bot.run()
File "bloqueador.py", line 48, in run
self.treat(user)
File "bloqueador.py", line 62, in treat
user.block(expiry="1 year", reason="Proxy", anon=True)
File "/home/drini/pywiki/userlib.py", line 381, in block
allowUsertalk, reBlock)
TypeError: _blockOld() takes exactly 9 arguments (10 given)
It seems code had another bug: _Blockold() doesn't accept a "reBlock"
parameter:
def _blockOld(self, expiry, reason, anonOnly, noSignup,
enableAutoblock, emailBan,
watchUser, allowUsertalk):
So we fix again the call as
if self.isAnonymous() or (not self.site().has_api()) or
self.site().versionnumber() < 12:
return self._blockOld(expiry, reason, anon, noCreate,
onAutoblock, banMail, watchUser,
allowUsertalk)
It SHOULD work now... except I get a cryptic error:
:!python bloqueador.py
Bloqueando 128.163.142.21
Getting a token.
Note: Your sysop account on wikipedia:es does not have a bot flag. Its
edits will be visible in the recent changes.
Blocking [[User:128.163.142.21]]...
Traceback (most recent call last):
File "bloqueador.py", line 86, in <module>
main()
File "bloqueador.py", line 79, in main
bot.run()
File "bloqueador.py", line 48, in run
self.treat(user)
File "bloqueador.py", line 62, in treat
user.block(expiry="1 year", reason="Proxy", anon=True)
File "/home/drini/pywiki/userlib.py", line 381, in block
allowUsertalk)
File "/home/drini/pywiki/userlib.py", line 471, in _blockOld
raise BlockError
userlib.BlockError
shell returned 1
Hope it helps Amir, and if you find a solution, please tell since I'm
stuck with the same problem
Pedro Sánchez
http://drini.mx
@combinatorica