Hi,
I use functions in my fixes.py as written in
https://hu.wikipedia.org/wiki/Szerkeszt%C5%91:Bin%C3%A1ris/Fixes_and_functi…
.
Now, my idea is to use an additional parameter. (In case nobody breaks the
framework. :-))
So my fix has something like this in replacements:
(ur'someregex', MyFunc),
Then MyFunc takes the match object as a parameter and is executed. I have
to write
def MyFunc(match):
etc.
Now I want to write def MyFunc(match, mode), but I can't pass mode to
MyFunc anyway.
I guessed the line in question is #195 in textlib.py:
replacement = new(match)
Here I stopped. How could I pass additional optional parameters?
--
Bináris
Some thoughts:
> It's interesting to say for a 2-days-old and by that time correctly working
> copy to be outdated. I can't see a reason for what properly working
> programs should be broken without prior notice. What was the
> *critical*issue for what anybody was forced to block replace.py?
We have perpetual beta release. Properly working programs my suddenly be broken by new new methods, variants and other stuff as well as API changes and we cannot guarantee a bug free code at all. I always would be glad if I could notice bugs before them came up ;)
Anyway there are circumstances that new commits can cause problems due to other OS, python versions and changes to the working copy which are unpredictable. In this particular case I found that bug when my bot failed while doing his daily tasks and solving it was very trivial for me.
>
> Additionally, to force somebody to download and run an unknown .EXE without
> further eyplanation when using an open source project is very unfriendly
> thing and by no means the proper way of developing the framework.
>
> First, an exe is an alien corpus here and should not be part of an open
> source framework.
As I posted few days ago I am unhappy too with .exe cuting external files. On the other hand runing the framework with its scripts and externals which also includes native codes may also be problematic. I found some explanations to that way of developing by DrTrigon few days ago.
> Second, majority of scripts had run correctly and without any problem by
> that time. Now, for I don't know what kind of development of I don't know
> which part of the project, properly working scripts were broken.
> Users who want to run simple scripts should be left to run them unless
> there is any critical problem.
There are a lot of new issues and task and the framework is evolving. I cannot guarantee that the code works always as expected but I'll do my best. On the other hand I find a lot of problems e.g. while migrating from trunk to rewrite. Some of them are very hard to find and kill, the script hangs and keybord interrupt doesn't work and I have no chance to figure out the point.
>
> Too many breaking changes suddenly! This was not the Pywiki way by this
> time and I don't like this new style!
Ist that really a new style of pwb framework? We also had blocker in past and we still have bugs in the code. Migrating to git will become the next big step and I guess it will not work without problems for bot owners and including be for developers (maybe I am off with git). Anyway there should be good reasons for major changes.
Greetings
xqt
Things go worse and worse in the last days. First SVN errors, then
change of textlib.py killed my script, and the newest, when running
replace.py:
WARNING: Download package "patch.exe" from
http://downloads.sourceforge.net/project/gnuwin32/patch/2.5.9-7/patch-2.5.9…
What is this? Why should I download it? Why did my bot stop, when it
worked normally a few days ago? What did I harm to the world?
--
Bináris
As shown in you version.py your working copy is outdated. You need r11719 or newer which solves the outboundlocalerror.
Greetings
Xqt
----- Ursprüngliche Nachricht -----
Von: Bináris
Gesendet: 09.07.2013 00:09
An: Pywikipedia discussion list
Betreff: Re: [Pywikipedia-l] Patch.exe, what sort of message is this?
I forgot the detailes:
c:\Pywikipedia>replace.py -search
WARNING: Download package "patch.exe" from
http://downloads.sourceforge.net/project/gnuwin32/patch/2.5.9-7/patch-2.5.9…
-bin.zip
WARNING: Size of download: 126248 byte(s)
WARNING: MIME type: ['application', 'x-zip-compressed']
WARNING: Extract package "patch.exe" to C:\Pywikipedia\externals\patch.exe.
Traceback (most recent call last):
File "C:\Pywikipedia\replace.py", line 171, in <module>
import wikipedia as pywikibot
File "C:\Pywikipedia\wikipedia.py", line 149, in <module>
import externals # allow imports from externals
File "C:\Pywikipedia\externals\__init__.py", line 387, in <module>
check_setup('patch.exe')
File "C:\Pywikipedia\externals\__init__.py", line 372, in check_setup
if download_install(modules_needed[m][1], m, path):
File "C:\Pywikipedia\externals\__init__.py", line 315, in download_install
arch.extractall(os.path.join(path, '__setup_tmp/'))
UnboundLocalError: local variable 'arch' referenced before assignment
Output of version.py:
c:\Pywikipedia>version.py
WARNING: Download package "patch.exe" from
http://downloads.sourceforge.net/project/gnuwin32/patch/2.5.9-7/patch-2.5.9…
-bin.zip
WARNING: Size of download: 126248 byte(s)
WARNING: MIME type: ['application', 'x-zip-compressed']
WARNING: Extract package "patch.exe" to C:\Pywikipedia\externals\patch.exe.
local variable 'arch' referenced before assignment
Serious import error; pywikibot not available - was it configured?
Pywikipedia trunk/pywikipedia/ (r11712, 2013/07/05, 01:17:44, OUTDATED)
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)]
config-settings:
use_api = True
use_api_login = True
unicode test: ok
_______________________________________________
Pywikipedia-l mailing list
Pywikipedia-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
Hi,
I've started to work with wikidata few days ago and have found out, that in
rewrite branch ItemPage.fromPage haven't worked properly, so I had started
digging in code and made small patch, which should resolve this issue.
The code is available here:
https://github.com/magul/pywikibot-core/tree/ItemPageFromPage
Could be it merged to rewrite branch? What should I do to make it happen?
Thanks for answer in advance
--
Tomasz Magulski
Hello,
if you use PWB with Wikidata you need often some functions not yet
provided by the framework. Here are some functions which I miss:
* for the Wikidata Family class
o get a Site object for a given code like 'enwiki'
o Site object to code
o add the items used for the 'imported from' statement directly to
the file, because retrieving them always from online (
www.wikidata.org/wiki/Wikidata:List_of_wikis/python ) is very
unusual
* Site creation function: Return a DataSite object if Wikidata is
requested. Sometimes you need a DataSite object directly, you can
use pywikibot.site.DataSite, but this is not really nice.
I would help coding the feautures but I have no access to SVN and I
don't now if it is useful to request it now because PWB will move to Git
soon.
Greetings
Pyfisch
Hi all,
I had mentioned this in the rewrite roadmap, and noticed it came up on IRC
as well, so I'd like to run this by the mailing list:
User:The Earwig has written a pure-python (with optional C-speedups)
MediaWiki text parser named mwparserfromhell[1]. Currently we have the
textlib library and some various regexes that implement this in a
non-perfect way. From my experience using mwparser (over 400k successful
edits with no issues) I believe it is ready to be bundled with the
framework. I think it would still be a good idea to keep textlib in as a
fallback or for users who are currently using it and don't need to migrate.
As for actually adding it, in the rewrite branch we can just add it as a
dependency in setup.py, and then convert various methods over.
In trunk, I'm guessing we would need to add it as an external. (I'm not
sure how that's actually done.)
[1] https://github.com/earwig/mwparserfromhell
-- Legoktm
Hi Binaris,
I was investigating in that issue again and found a wrong order for the re.escape() sequence. This caused some errors in past with blanks and underlines in the section headers. I fixed it in r11755/r11756. Could you please validate it for your script.
Thanks and sorry for trouble
xqt
----- Original Nachricht ----
Von: Bináris <wikiposta(a)gmail.com>
An: Pywikipedia discussion list <pywikipedia-l(a)lists.wikimedia.org>
Datum: 06.07.2013 00:16
Betreff: [Pywikipedia-l] Script halted, textlib.py?
> Hi, this is a message from the server running masvita.py.
> The only change in code since the last successful run is here:
> http://hu.wikipedia.org/w/index.php?title=Szerkeszt%C5%91:BinBot/masvita.py&
> diff=prev&oldid=13723804
> This is also the source of my script.
> The error message is below and it mentions textlib.py at the end. Has
> anything changed? I can't imagine how my above modification in the quoted
> text could cause the crash.
>
>
> ---------- Forwarded message ----------
> From: Cron Daemon <root(a)tron.wmm.hu>
> Date: 2013/7/2
> Subject: Cron <binaris@tron> bash weekofmonth 1 python
> pywikipedia/masvita.py > /dev/null
> To: wikiposta+tron(a)gmail.com
>
>
> No handlers could be found for logger "pywiki"
> NOTE: You have new messages on wikipedia:hu
>
> Getting references to [[Sablon:Másvita]] via API...
>
> Reading section info from [[Wikipédia:Kocsmafal (egyéb)/Archív53]] via
> API...
>
> A pywikipedia/masvita.py 09:02-kor megszakadt.
> A feldolgozás során mentési hiba nem történt.
>
>
> Email sent.
>
> Traceback (most recent call last):
> File "pywikipedia/masvita.py", line 279, in <module>
> main()
> File "pywikipedia/masvita.py", line 273, in main
> bot.run()
> File "pywikipedia/masvita.py", line 208, in run
> comment += self.commenttext(self.found(archtitle), False)
> File "pywikipedia/masvita.py", line 134, in found
> section.get()
> File "/home/binaris/pywikipedia/wikipedia.py", line 741, in get
> expandtemplates = expandtemplates)
> File "/home/binaris/pywikipedia/wikipedia.py", line 881, in _getEditPage
> not does_text_contain_section(pagetext, self.section()):
> File "/home/binaris/pywikipedia/pywikibot/textlib.py", line 1078, in
> does_text_contain_section
> m = re.search("=+[ ']*%s[ ']*=+" % section, pagetext)
> File "/usr/lib/python2.7/re.py", line 142, in search
> return _compile(pattern, flags).search(string)
> File "/usr/lib/python2.7/re.py", line 244, in _compile
> raise error, v # invalid expression
> sre_constants.error: multiple repeat
>
>
>
> --
> Bináris
>
>
> --------------------------------
>
> _______________________________________________
> Pywikipedia-l mailing list
> Pywikipedia-l(a)lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
>
textlib: as I answered last week I found that the method did not properly in past. Unfortunately it did not match some Unicode strings. Now it does but you have to escape regex signs by yourself. On the other hand you are able to use a full regex and could search for wiki links in the section header. Feel free to revert my release and find another solution for unicode signs an we link brackets in the header.
patch.exe: There is a thread at code revision r11711. I am unhappy with running .exe files but maybe it is needed sometimes to patch externals for the framework. I am really unsure and prefer using derived classes and methods.
Best
Xqt
----- Ursprüngliche Nachricht -----
Von: Bináris
Gesendet: 09.07.2013 00:07
An: Pywikipedia discussion list
Betreff: [Pywikipedia-l] Patch.exe, what sort of message is this?
Things go worse and worse in the last days. First SVN errors, then
change of textlib.py killed my script, and the newest, when running
replace.py:
WARNING: Download package "patch.exe" from
http://downloads.sourceforge.net/project/gnuwin32/patch/2.5.9-7/patch-2.5.9…
What is this? Why should I download it? Why did my bot stop, when it
worked normally a few days ago? What did I harm to the world?
--
Bináris
_______________________________________________
Pywikipedia-l mailing list
Pywikipedia-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l