Whoo! Great work :-) Tests always are good contributions :-)
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.
Best regards, Merlijn
On 24 April 2011 07:41, jayvdb@svn.wikimedia.org wrote:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9196
Revision: 9196 Author: jayvdb Date: 2011-04-24 05:40:59 +0000 (Sun, 24 Apr 2011) Log Message:
Allow lists of Page and User objects to be interogated
Modified Paths:
trunk/pywikipedia/query.py trunk/pywikipedia/tests/test_query.py
Modified: trunk/pywikipedia/query.py
--- trunk/pywikipedia/query.py 2011-04-24 04:23:12 UTC (rev 9195) +++ trunk/pywikipedia/query.py 2011-04-24 05:40:59 UTC (rev 9196) @@ -263,10 +263,21 @@
encList = '' # items may not have one symbol - '|'
- for l in list:
if type(l) == str and u'|' in l:
raise wikipedia.Error("item '%s' contains '|' symbol" % l )
encList += ToUtf8(l) + u'|'
- for item in list:
if isinstance(item,basestring):
if u'|' in item:
raise wikipedia.Error(u"item '%s' contains '|' symbol" %
item )
encList += ToUtf8(item) + u'|'
elif isinstance(item,wikipedia.Page):
encList += ToUtf8(item.title()) + u'|'
elif item.__class__.__name__ == 'User':
# delay loading this until it is needed
import userlib
encList += ToUtf8(item.name()) + u'|'
else:
raise wikipedia.Error(u'unknown item class %s' %
item.__class__.__name__)
- # strip trailing '|' before returning return encList[:-1]
def ToUtf8(s):
Modified: trunk/pywikipedia/tests/test_query.py
--- trunk/pywikipedia/tests/test_query.py 2011-04-24 04:23:12 UTC (rev 9195) +++ trunk/pywikipedia/tests/test_query.py 2011-04-24 05:40:59 UTC (rev 9196) @@ -7,6 +7,8 @@ import unittest import tests.test_pywiki
+import wikipedia as pywikibot +import catlib, userlib import query
@@ -74,5 +76,72 @@ ]} self.assertEqualQueryResult(params, expectedresult)
- def test_titles_Page(self):
params = {
'action': 'query',
'list': 'users',
'usprop': ['registration'],
'ususers': [pywikibot.Page(self.site, u'Example'),
pywikibot.Page(self.site, u'Example2')],
}
expectedresult = {u'users': [
{
u'userid': 215131,
u'name': u'Example',
u'registration': u'2005-03-19T00:17:19Z'
},
{
u'userid': 5176706,
u'name': u'Example2',
u'registration': u'2007-08-26T02:13:33Z'
},
]}
self.assertEqualQueryResult(params, expectedresult)
- def test_titles_User(self):
params = {
'action': 'query',
'list': 'users',
'usprop': ['registration'],
'ususers': [userlib.User(self.site, u'Example'),
userlib.User(self.site, u'Example2')],
}
expectedresult = {u'users': [
{
u'userid': 215131,
u'name': u'Example',
u'registration': u'2005-03-19T00:17:19Z'
},
{
u'userid': 5176706,
u'name': u'Example2',
u'registration': u'2007-08-26T02:13:33Z'
},
]}
self.assertEqualQueryResult(params, expectedresult)
- def test_titles_Category(self):
params = {
'action': 'query',
'prop': 'revisions',
'rvprop': ['ids', 'timestamp', 'user'],
'rvdir': 'newer',
'rvlimit': 1,
'titles': [catlib.Category(self.site,
u'Category:Categories')],
}
expectedresult = {u'pages': {u'794823':
{
u'ns': 14,
u'pageid': 794823,
u'revisions': [{
u'revid': 4494485,
u'user': u'SEWilco',
u'timestamp': u'2004-07-07T18:45:50Z',
}],
u'title': u'Category:Categories',
},
}}
self.assertEqualQueryResult(params, expectedresult)
if __name__ == "__main__": unittest.main()
Pywikipedia-svn mailing list Pywikipedia-svn@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn
I have tried to use the re-write branch several times on a windows based computer and have been unable to get it to work. The current trunk works good and is fairly stable. I wish more was done with /trunk since the /rewrite is completely unusable for anyone who works on a non *nx OS. One thought would be to merge the two into one good system. Where we move all of the non-API based functions to a _old and check for either use_api or a mediawiki version and only support API access where possible. If/when new features become available via the API we can just move the current screen scrap method to and _old and forget about it. Until /rewrite and /trunk are swapped or they are merged development on /trunk should not stop.
John
On Sun, Apr 24, 2011 at 5:49 PM, Merlijn van Deen valhallasw@arctus.nlwrote:
Whoo! Great work :-) Tests always are good contributions :-)
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.
Best regards, Merlijn
On 24 April 2011 07:41, jayvdb@svn.wikimedia.org wrote:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9196
Revision: 9196 Author: jayvdb Date: 2011-04-24 05:40:59 +0000 (Sun, 24 Apr 2011) Log Message:
Allow lists of Page and User objects to be interogated
Modified Paths:
trunk/pywikipedia/query.py trunk/pywikipedia/tests/test_query.py
Modified: trunk/pywikipedia/query.py
--- trunk/pywikipedia/query.py 2011-04-24 04:23:12 UTC (rev 9195) +++ trunk/pywikipedia/query.py 2011-04-24 05:40:59 UTC (rev 9196) @@ -263,10 +263,21 @@
encList = '' # items may not have one symbol - '|'
- for l in list:
if type(l) == str and u'|' in l:
raise wikipedia.Error("item '%s' contains '|' symbol" % l )
encList += ToUtf8(l) + u'|'
- for item in list:
if isinstance(item,basestring):
if u'|' in item:
raise wikipedia.Error(u"item '%s' contains '|' symbol" %
item )
encList += ToUtf8(item) + u'|'
elif isinstance(item,wikipedia.Page):
encList += ToUtf8(item.title()) + u'|'
elif item.__class__.__name__ == 'User':
# delay loading this until it is needed
import userlib
encList += ToUtf8(item.name()) + u'|'
else:
raise wikipedia.Error(u'unknown item class %s' %
item.__class__.__name__)
- # strip trailing '|' before returning return encList[:-1]
def ToUtf8(s):
Modified: trunk/pywikipedia/tests/test_query.py
--- trunk/pywikipedia/tests/test_query.py 2011-04-24 04:23:12 UTC (rev 9195) +++ trunk/pywikipedia/tests/test_query.py 2011-04-24 05:40:59 UTC (rev 9196) @@ -7,6 +7,8 @@ import unittest import tests.test_pywiki
+import wikipedia as pywikibot +import catlib, userlib import query
@@ -74,5 +76,72 @@ ]} self.assertEqualQueryResult(params, expectedresult)
- def test_titles_Page(self):
params = {
'action': 'query',
'list': 'users',
'usprop': ['registration'],
'ususers': [pywikibot.Page(self.site, u'Example'),
pywikibot.Page(self.site, u'Example2')],
}
expectedresult = {u'users': [
{
u'userid': 215131,
u'name': u'Example',
u'registration': u'2005-03-19T00:17:19Z'
},
{
u'userid': 5176706,
u'name': u'Example2',
u'registration': u'2007-08-26T02:13:33Z'
},
]}
self.assertEqualQueryResult(params, expectedresult)
- def test_titles_User(self):
params = {
'action': 'query',
'list': 'users',
'usprop': ['registration'],
'ususers': [userlib.User(self.site, u'Example'),
userlib.User(self.site, u'Example2')],
}
expectedresult = {u'users': [
{
u'userid': 215131,
u'name': u'Example',
u'registration': u'2005-03-19T00:17:19Z'
},
{
u'userid': 5176706,
u'name': u'Example2',
u'registration': u'2007-08-26T02:13:33Z'
},
]}
self.assertEqualQueryResult(params, expectedresult)
- def test_titles_Category(self):
params = {
'action': 'query',
'prop': 'revisions',
'rvprop': ['ids', 'timestamp', 'user'],
'rvdir': 'newer',
'rvlimit': 1,
'titles': [catlib.Category(self.site,
u'Category:Categories')],
}
expectedresult = {u'pages': {u'794823':
{
u'ns': 14,
u'pageid': 794823,
u'revisions': [{
u'revid': 4494485,
u'user': u'SEWilco',
u'timestamp': u'2004-07-07T18:45:50Z',
}],
u'title': u'Category:Categories',
},
}}
self.assertEqualQueryResult(params, expectedresult)
if __name__ == "__main__": unittest.main()
Pywikipedia-svn mailing list Pywikipedia-svn@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
Does rewrite already handle XML dumps?
John wrote:
I have tried to use the re-write branch several times on a windows based computer and have been unable to get it to work.
I use rewrite on Windows computers all the time. Whatever your problem is, it is not an incompatibility between rewrite branch and Windows OS.
Russ
What version of windows are you using?
On Mon, Apr 25, 2011 at 11:46 AM, Russell Blau russblau@imapmail.orgwrote:
John wrote:
I have tried to use the re-write branch several times on a windows based computer and have been unable to get it to work.
I use rewrite on Windows computers all the time. Whatever your problem is, it is not an incompatibility between rewrite branch and Windows OS.
Russ
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
I use windows 7 x64 and I get issues with it placing stuff in the AppData folder even when I specify a different folder during setup. This particular "feature" was introduced in vista so XP computers are not affected. On Mon, Apr 25, 2011 at 6:01 PM, Russell Blau russblau@imapmail.org wrote:
John wrote:
What version of windows are you using?
XP (one Home and one Professional).
When you tried to use the rewrite branch, what error(s) did you encounter?
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
On 26 April 2011 00:05, John phoenixoverride@gmail.com wrote:
I use windows 7 x64 and I get issues with it placing stuff in the AppData folder even when I specify a different folder during setup. This particular "feature" was introduced in vista so XP computers are not affected.
I have absolutely no idea what the problem is you're encountering. I have
the rewrite running on windows 7 with absolutely no problems. However, any problems you encounter will have to be fixed, as you are probably not the only one to encounter them ;-)
Please see http://lists.wikimedia.org/pipermail/pywikipedia-l/2011-February/006688.html for an elaborate guide on what to do if you want to develop the rewrite on windows -- this should also work for normal users, but takes more effort than I think is necessary.
Anyway -- I would appreciate any information on the exact problem you have encountered!
Best regards, Merlijn van Deen
Since Interwicket stopped on wiktionaries, plwiktionary has not a fix interwiki bot. They want the iwikis added at the top of the page, but without creating new lines after the links. Pywikipedia does exactly the opposite, it creates these "new lines". It would be good if someone make a code to change that.
Lucas.
On 13 May 2011 19:20, Lucas Nunes lucas.nunes@live.com wrote:
Since Interwicket stopped on wiktionaries, plwiktionary has not a fix interwiki bot. They want the iwikis added at the top of the page, but without creating new lines after the links. Pywikipedia does exactly the opposite, it creates these "new lines". It would be good if someone make a code to change that.
I created a tracker item for this at https://sourceforge.net/tracker/?group_id=93107&atid=603138
If you could specify what you mean with 'iwikis added at the top of the page, but without creating new lines after the links', that would be helpful (include an example of the 'wrong' and the 'correct' versions).
Merlijn
2012/1/15 Merlijn van Deen valhallasw@arctus.nl
On 13 May 2011 19:20, Lucas Nunes lucas.nunes@live.com wrote:
Since Interwicket stopped on wiktionaries, plwiktionary has not a fix interwiki bot. They want the iwikis added at the top of the page, but without creating new lines after the links. Pywikipedia does exactly the opposite, it creates these "new lines". It would be good if someone make a code to change that.
I created a tracker item for this at https://sourceforge.net/tracker/?group_id=93107&atid=603138
If you could specify what you mean with 'iwikis added at the top of the page, but without creating new lines after the links', that would be helpful (include an example of the 'wrong' and the 'correct' versions).
Merlijn
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
This *should* already be in place. wiktionary_family.py has this on lines 683-685:
self.interwiki_on_one_line = ['pl']
self.interwiki_attop = ['pl']
Which should fix that. I copied that over to my wikipedia_family.py and did a test on the sandboxhttps://no.wikipedia.org/w/index.php?title=Wikipedia:Sandkasse&diff=9970369&oldid=9966679, and it worked fine.
Have you actually tested it on plwiktionary to see if it works, Lucas?
2012/1/15 Jon Harald Søby jhsoby@gmail.com:
This should already be in place. wiktionary_family.py has this on lines 683-685:
Hm, yes, and according to svn blame [1] this has been the case since 2005.
However, possibly this is not the format they want after all - hopefully Lucas can shed some light on that.
Best, Merlijn
[1] http://svn.wikimedia.org/viewvc/pywikipedia/trunk/pywikipedia/families/wikti...
Merlijn van Deen valhallasw@arctus.nl wrote:
2012/1/15 Jon Harald Søby jhsoby@gmail.com:
This should already be in place. wiktionary_family.py has this on lines 683-685:
Hm, yes, and according to svn blame [1] this has been the case since 2005.
However, possibly this is not the format they want after all - hopefully Lucas can shed some light on that.
Here's an example:
https://pl.wiktionary.org/w/index.php?title=love&action=edit
The rule is stated on their help pages:
https://pl.wiktionary.org/wiki/Pomoc:Tworzenie_link%C3%B3w#Linki_do_innych_W...
What I remember from my conversations with plwiktionary community is that they didn't want that bots add links bot-generated empty stubs on ruwiktionary.
//Saper
On 01/17/2012 01:55 AM, Marcin Cieslak wrote:
Merlijn van Deenvalhallasw@arctus.nl wrote:
2012/1/15 Jon Harald Søbyjhsoby@gmail.com:
This should already be in place. wiktionary_family.py has this on lines 683-685:
Hm, yes, and according to svn blame [1] this has been the case since 2005.
However, possibly this is not the format they want after all - hopefully Lucas can shed some light on that.
Here's an example:
https://pl.wiktionary.org/w/index.php?title=love&action=edit
The rule is stated on their help pages:
https://pl.wiktionary.org/wiki/Pomoc:Tworzenie_link%C3%B3w#Linki_do_innych_W...
What I remember from my conversations with plwiktionary community is that they didn't want that bots add links bot-generated empty stubs on ruwiktionary.
the ban on the ru links is no longer in place. There are already a few interwikibots running on pl.wiktionary
masti