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
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
Hello all,
*As several people have mentioned they had trouble starting with the rewrite
branch, I decided to do a step-by-step log of installing the rewrite in a
way that is good for developing -- this means you are able to edit the
framework files, while not inflicting any changes on other users (or other
bots you run!) of the system. By using setup.py develop, edits you make to
the framework will immediately be used (no need to setup.py install them),
but only within the virtualenv.*
*This is the windows version of my earlier email*
*
*
I do not run python on windows, so this is a tutorial that starts with
installing python. It's a bit rougher than the unix one, as I did not want
to spend too much time on it.
1. Install python 2.7
http://python.org/ftp/python/2.7.1/python-2.7.1.msi<http://python.org/download/>
(do
*not* use the 64-bit version, due to http://bugs.python.org/issue6792 )
2. Install Setuptools
http://pypi.python.org/pypi/setuptools#files
3. Install Virtualenv
start/run: cmd
c:\Python27\Scripts\easy_install.exe virtualenv
4. create a virtualenv for pwb
C:\Users\valhallasw>c:\Python27\Scripts\virtualenv.exe pywikibot
New python executable in pywikibot\Scripts\python.exe
Installing setuptools.....................done.
5. Go to C:\Users\valhallasw\pywikibot and use tortoisesvn to get the
rewrite
6. create a shortcut to cmd /k
c:\users\valhallasw\pywikibot\scripts\activate.bat
with working path C:\Users\valhallasw\pywikibot\rewrite
7. Use the shortcut. You now have a new cmd.exe window
8. python setup.py develop
Your default user directory is
"C:\Users\valhallasw\AppData\Roaming\pywikibot"
How to proceed? ([K]eep [c]hange)
change, to c:\users\valhallasw\pywikibot\conf\
Answer 'y' to the warning prompt (not 'yes')
Do you want to copy files: y
[note: I copied my unix user-config.py to c:\users\valhallasw\pywikibot]
Path to existing wikipedia.py? C:\Users\valhallasw\pywikibot
NOTE: user-config.py already exists in the directory
Create user-fixes.py file? ([y]es, [N]o) n
(pywikibot) C:\Users\valhallasw\pywikibot\rewrite>echo SET
PYWIKIBOT2_DIR=c:\users\valhallasw\pywikibot\conf>> ..\Scripts\activate.bat
(DON'T put a space between f and >>!)
Close the window, and
9. Use the shortcut from (7) again
You should now have a cmd.exe with a working pywikibot setup!
(pywikibot) C:\Users\valhallasw\pywikibot\rewrite\scripts>python touch.py
Gebruiker:Valhallasw
Retrieving 1 pages from wikipedia:nl.
Page [[Gebruiker:Valhallasw]] saved
NOTE: you *must* use 'python' in front of the script name, or python will
not find the pywikibot directory.
Good luck!
Merlijn
Hi Merlijn,
I've seen it during discussion with Nikerabbit on tw.net (look at the first LQ-threat according pywikipedia) and I am working on a pythonic version of the plural-gettext.txt. I am using lambda function for that like this one (for mk-wiki):
plural = lambda n: 0 if (n == 1 or n%10 == 1) else 1
I think this is the easiest way.
But we have a remaining problem found on table2wiki. Now we have 3 messages. One message is used if we have no warning, and we have two messages either for one or a lot of warnings. I guess we could keep the first "table2wiki-no-warning" message and merge the two messages "table2wiki-one-warning" and "table2wiki-warnings" using {{Plural:}} tag. It is also possible to use the first message every time and append the warning message if needed.
Greetings
----- Original Nachricht ----
Von: Merlijn van Deen <valhallasw(a)arctus.nl>
An: pywikipedia-l(a)lists.wikimedia.org
Datum: 25.08.2011 19:46
Betreff: Re: [Pywikipedia-l] [Pywikipedia-svn] SVN: [9448]
trunk/pywikipedia/pywikibot/i18n.py
> Hello xqt,
>
> On 21 August 2011 15:49, <xqt(a)svn.wikimedia.org> wrote:
>
> > + value. At the moment, we have only one plural_func = x: x!= 1 yet.
> > Multiple
> > + PLURAL tags are not supported (yet).
> >
>
> Good to see you're working on plural support. Have you seen
> http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/Translate/data/pl
> ural-gettext.txt?view=markup
> ,
> which lists the plural possibilities for each language. Unfortunately,
> python does not support the a ? b : c notation, so it's not possible to
> copy the code 1-on-1.
>
> Alternatively, there is
> http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/Translate/data/pl
> ural-cldr.yaml?view=markup
> ,
> but that is fairly unreadable IMO.
>
> Good luck!
>
> Best,
> Merlijn
>
>
> --------------------------------
>
> _______________________________________________
> Pywikipedia-l mailing list
> Pywikipedia-l(a)lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
>
Arcor empfiehlt: Mal über die Karriere nachdenken! Wissenswertes und Nützliches finden Sie hierzu unter http://www.arcor.de/content/finanzen_job/job_karriere/bewerbung_karriere/ra…
Hi DrTrigon,
"wiki" is reserved by Family.known_families. You know you get the related dbName of a site just by Site.dbName() which returns "dewiki_p" for "wikipedia:de". Thereby for historic reasons, the databases are called xxwiki instead of xxwikipedia for Wikipedias.
You are using side effects doing your dbname2wikilink() conversion and I am sure you are able to modificate this stuff with stuff.replace("wiki:", "wikipedia:") if needed. In other words (your wrote me) "There should be one-- and preferably only one --__obvious__ way to do it" and btw "Although that way may not be obvious at first unless you're Dutch" (again: PEP20, The Zen of Python)
Sali ;)
xqt
----- Original Nachricht ----
Von: "Dr. Trigon" <dr.trigon(a)surfeu.ch>
An: pywikipedia-l(a)lists.wikimedia.org
Datum: 30.08.2011 19:02
Betreff: Re: [Pywikipedia-l] 'wiki' as synonym for 'wikipedia' in family?
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> > "wiki" is being use as the interwiki link to the original wiki,
> > WikiWikiWeb at http://c2.com/cgi/wiki, so you shouldn't use that
> > for anything related to Wikipedia. You are getting it returned
> > since Wikipedias can use it as an interwiki link to the
> > WikiWikiWeb, i.e. [[:wiki:WelcomeVisitors]] becomes
> > http://c2.com/cgi/wiki?WelcomeVisitors
>
> So this means essentially 'wiki' in toolserver DB (like e.g. 'dewiki')
> does not refer to the same as 'wiki' in pywikipediabot and interwiki...
> (strange...)
>
> But would also explain this 'inconsistency'... ;)
>
> Thanks and Greetings
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk5dF68ACgkQAXWvBxzBrDCi8ACg0YV5W6uEDDY61xcgxB9qsKq8
> 8KsAn0kHTE6IwqZZxZI8Lb/9Dk6E7ciP
> =dKzI
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Pywikipedia-l mailing list
> Pywikipedia-l(a)lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
>