Revision: 5610
Author: leogregianin
Date: 2008-06-23 02:13:25 +0000 (Mon, 23 Jun 2008)
Log Message:
-----------
This module is deprecated and has been replaced by new funcionality in wikipedia.py. Move module to archive directory.
Added Paths:
-----------
trunk/pywikipedia/archive/mediawiki_messages.py
Removed Paths:
-------------
trunk/pywikipedia/mediawiki_messages.py
Added: trunk/pywikipedia/archive/mediawiki_messages.py
===================================================================
--- trunk/pywikipedia/archive/mediawiki_messages.py (rev 0)
+++ trunk/pywikipedia/archive/mediawiki_messages.py 2008-06-23 02:13:25 UTC (rev 5610)
@@ -0,0 +1,218 @@
+# -*- coding: utf-8 -*-
+"""
+Allows access to the MediaWiki messages, that's the label texts of the MediaWiki
+software in the current language. These can be used in other bots.
+
+The function refresh_messages() downloads all the current messages and saves
+them to disk. It is run automatically when a bot first tries to access one of
+the messages. It can be updated manually by running this script, e.g. when
+somebody changed the current message at the wiki. The texts will also be
+reloaded automatically once a month.
+
+Syntax: python mediawiki_messages [-all]
+
+Command line options:
+ -refresh - Reloads messages for the home wiki or for the one defined via
+ the -lang and -family parameters.
+
+ -all - Reloads messages for all wikis where messages are already present
+
+ If another parameter is given, it will be interpreted as a MediaWiki key.
+ The script will then output the respective value, without refreshing..
+
+"""
+
+# (C) Daniel Herding, 2004
+#
+# Distributed under the terms of the MIT license.
+
+##THIS MODULE IS DEPRECATED AND HAS BEEN REPLACED BY NEW FUNCTIONALITY IN
+##WIKIPEDIA.PY. It is being retained solely for compatibility in case any
+##custom-written bots rely upon it. Bot authors should replace any uses
+##of this module as follows:
+##
+## OLD: mediawiki_messages.get(key, site)
+## NEW: site.mediawiki_message(key)
+##
+## OLD: mediawiki_messages.has(key, site)
+## NEW: site.has_mediawiki_message(key)
+##
+## OLD: mediawiki_messages.makepath(path)
+## NEW: wikipedia.makepath(path)
+##
+##########################################################################
+
+import warnings
+warnings.warn(
+"""The mediawiki_messages module is deprecated and no longer
+maintained; see the source code for new methods to replace
+calls to this module.""",
+ DeprecationWarning, stacklevel=2)
+
+
+import wikipedia
+import re, sys, pickle
+import os.path
+import time
+import codecs
+import urllib
+from BeautifulSoup import *
+
+__version__='$Id: mediawiki_messages.py 3731 2007-06-20 14:42:55Z russblau $'
+
+loaded = {}
+
+def get(key, site = None, allowreload = True):
+ site = site or wikipedia.getSite()
+ if loaded.has_key(site):
+ # Use cached copy if it exists.
+ dictionary = loaded[site]
+ else:
+ fn = 'mediawiki-messages/mediawiki-messages-%s-%s.dat' % (site.family.name, site.lang)
+ try:
+ # find out how old our saved dump is (in seconds)
+ file_age = time.time() - os.path.getmtime(fn)
+ # if it's older than 1 month, reload it
+ if file_age > 30 * 24 * 60 * 60:
+ print 'Current MediaWiki message dump is one month old, reloading'
+ refresh_messages(site)
+ except OSError:
+ # no saved dumped exists yet
+ refresh_messages(site)
+ f = open(fn, 'r')
+ dictionary = pickle.load(f)
+ f.close()
+ loaded[site] = dictionary
+ key = key[0].lower() + key[1:]
+ if dictionary.has_key(key):
+ return dictionary[key]
+ elif allowreload:
+ refresh_messages(site = site)
+ return get(key, site = site, allowreload = False)
+ else:
+ raise KeyError('MediaWiki Key %s not found' % key)
+
+def has(key, site = None, allowreload = True):
+ try:
+ get(key, site, allowreload)
+ return True
+ except KeyError:
+ return False
+
+def makepath(path):
+ """ creates missing directories for the given path and
+ returns a normalized absolute version of the path.
+
+ - if the given path already exists in the filesystem
+ the filesystem is not modified.
+
+ - otherwise makepath creates directories along the given path
+ using the dirname() of the path. You may append
+ a '/' to the path if you want it to be a directory path.
+
+ from holger(a)trillke.net 2002/03/18
+ """
+ from os import makedirs
+ from os.path import normpath,dirname,exists,abspath
+
+ dpath = normpath(dirname(path))
+ if not exists(dpath): makedirs(dpath)
+ return normpath(abspath(path))
+
+def refresh_messages(site = None):
+ site = site or wikipedia.getSite()
+ # get 'all messages' special page's path
+ path = site.allmessages_address()
+ print 'Retrieving MediaWiki messages for %s' % repr(site)
+ wikipedia.put_throttle() # It actually is a get, but a heavy one.
+ allmessages = site.getUrl(path)
+
+ print 'Parsing MediaWiki messages'
+ soup = BeautifulSoup(allmessages,
+ convertEntities=BeautifulSoup.HTML_ENTITIES)
+ # The MediaWiki namespace in URL-encoded format, as it can contain
+ # non-ASCII characters and spaces.
+ quotedMwNs = urllib.quote(site.namespace(8).replace(' ', '_').encode(site.encoding()))
+ mw_url = site.path() + "?title=" + quotedMwNs + ":"
+ altmw_url = site.path() + "/" + quotedMwNs + ":"
+ nicemw_url = site.nice_get_address(quotedMwNs + ":")
+ shortmw_url = "/" + quotedMwNs + ":"
+ ismediawiki = lambda url:url and (url.startswith(mw_url)
+ or url.startswith(altmw_url)
+ or url.startswith(nicemw_url)
+ or url.startswith(shortmw_url))
+ # we will save the found key:value pairs here
+ dictionary = {}
+
+ try:
+ for keytag in soup('a', href=ismediawiki):
+ # Key strings only contain ASCII characters, so we can save them as
+ # strs
+ key = str(keytag.find(text=True))
+ keyrow = keytag.parent.parent
+ if keyrow['class'] == "orig":
+ valrow = keyrow.findNextSibling('tr')
+ assert valrow['class'] == "new"
+ value = unicode(valrow.td.string).strip()
+ elif keyrow['class'] == 'def':
+ value = unicode(keyrow('td')[1].string).strip()
+ else:
+ raise AssertionError("Unknown tr class value: %s" % keyrow['class'])
+ dictionary[key] = value
+ except Exception, e:
+ wikipedia.debugDump( 'MediaWiki_Msg', site, u'%s: %s while processing URL: %s' % (repr(e), str(e), unicode(path)), allmessages)
+ raise
+
+ # Save the dictionary to disk
+ # The file is stored in the mediawiki_messages subdir. Create if necessary.
+ if dictionary == {}:
+ wikipedia.debugDump( 'MediaWiki_Msg', site, u'Error URL: '+unicode(path), allmessages )
+ sys.exit()
+ else:
+ f = open(makepath('mediawiki-messages/mediawiki-messages-%s-%s.dat' % (site.family.name, site.lang)), 'w')
+ pickle.dump(dictionary, f)
+ f.close()
+ print "Loaded %i values from %s" % (len(dictionary.keys()), site)
+ #print dictionary['sitestatstext']
+
+def refresh_all_messages():
+ import dircache, time
+ filenames = dircache.listdir('mediawiki-messages')
+ message_filenameR = re.compile('mediawiki-messages-([a-z:]+)-([a-z:]+).dat')
+ for filename in filenames:
+ match = message_filenameR.match(filename)
+ if match:
+ family = match.group(1)
+ lang = match.group(2)
+ site = wikipedia.getSite(code = lang, fam = family)
+ refresh_messages(site)
+
+def main():
+ refresh_all = False
+ refresh = False
+ key = None
+ for arg in wikipedia.handleArgs():
+ if arg == '-all':
+ refresh_all = True
+ elif arg == '-refresh':
+ refresh = True
+ else:
+ key = arg
+ if key:
+ wikipedia.output(get(key), toStdout = True)
+ elif refresh_all:
+ refresh_all_messages()
+ elif refresh:
+ refresh_messages(wikipedia.getSite())
+ else:
+ wikipedia.showHelp('mediawiki_messages')
+
+if __name__ == "__main__":
+ try:
+ main()
+ except:
+ wikipedia.stopme()
+ raise
+ else:
+ wikipedia.stopme()
+
Deleted: trunk/pywikipedia/mediawiki_messages.py
===================================================================
--- trunk/pywikipedia/mediawiki_messages.py 2008-06-23 01:51:43 UTC (rev 5609)
+++ trunk/pywikipedia/mediawiki_messages.py 2008-06-23 02:13:25 UTC (rev 5610)
@@ -1,218 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Allows access to the MediaWiki messages, that's the label texts of the MediaWiki
-software in the current language. These can be used in other bots.
-
-The function refresh_messages() downloads all the current messages and saves
-them to disk. It is run automatically when a bot first tries to access one of
-the messages. It can be updated manually by running this script, e.g. when
-somebody changed the current message at the wiki. The texts will also be
-reloaded automatically once a month.
-
-Syntax: python mediawiki_messages [-all]
-
-Command line options:
- -refresh - Reloads messages for the home wiki or for the one defined via
- the -lang and -family parameters.
-
- -all - Reloads messages for all wikis where messages are already present
-
- If another parameter is given, it will be interpreted as a MediaWiki key.
- The script will then output the respective value, without refreshing..
-
-"""
-
-# (C) Daniel Herding, 2004
-#
-# Distributed under the terms of the MIT license.
-
-##THIS MODULE IS DEPRECATED AND HAS BEEN REPLACED BY NEW FUNCTIONALITY IN
-##WIKIPEDIA.PY. It is being retained solely for compatibility in case any
-##custom-written bots rely upon it. Bot authors should replace any uses
-##of this module as follows:
-##
-## OLD: mediawiki_messages.get(key, site)
-## NEW: site.mediawiki_message(key)
-##
-## OLD: mediawiki_messages.has(key, site)
-## NEW: site.has_mediawiki_message(key)
-##
-## OLD: mediawiki_messages.makepath(path)
-## NEW: wikipedia.makepath(path)
-##
-##########################################################################
-
-import warnings
-warnings.warn(
-"""The mediawiki_messages module is deprecated and no longer
-maintained; see the source code for new methods to replace
-calls to this module.""",
- DeprecationWarning, stacklevel=2)
-
-
-import wikipedia
-import re, sys, pickle
-import os.path
-import time
-import codecs
-import urllib
-from BeautifulSoup import *
-
-__version__='$Id$'
-
-loaded = {}
-
-def get(key, site = None, allowreload = True):
- site = site or wikipedia.getSite()
- if loaded.has_key(site):
- # Use cached copy if it exists.
- dictionary = loaded[site]
- else:
- fn = 'mediawiki-messages/mediawiki-messages-%s-%s.dat' % (site.family.name, site.lang)
- try:
- # find out how old our saved dump is (in seconds)
- file_age = time.time() - os.path.getmtime(fn)
- # if it's older than 1 month, reload it
- if file_age > 30 * 24 * 60 * 60:
- print 'Current MediaWiki message dump is one month old, reloading'
- refresh_messages(site)
- except OSError:
- # no saved dumped exists yet
- refresh_messages(site)
- f = open(fn, 'r')
- dictionary = pickle.load(f)
- f.close()
- loaded[site] = dictionary
- key = key[0].lower() + key[1:]
- if dictionary.has_key(key):
- return dictionary[key]
- elif allowreload:
- refresh_messages(site = site)
- return get(key, site = site, allowreload = False)
- else:
- raise KeyError('MediaWiki Key %s not found' % key)
-
-def has(key, site = None, allowreload = True):
- try:
- get(key, site, allowreload)
- return True
- except KeyError:
- return False
-
-def makepath(path):
- """ creates missing directories for the given path and
- returns a normalized absolute version of the path.
-
- - if the given path already exists in the filesystem
- the filesystem is not modified.
-
- - otherwise makepath creates directories along the given path
- using the dirname() of the path. You may append
- a '/' to the path if you want it to be a directory path.
-
- from holger(a)trillke.net 2002/03/18
- """
- from os import makedirs
- from os.path import normpath,dirname,exists,abspath
-
- dpath = normpath(dirname(path))
- if not exists(dpath): makedirs(dpath)
- return normpath(abspath(path))
-
-def refresh_messages(site = None):
- site = site or wikipedia.getSite()
- # get 'all messages' special page's path
- path = site.allmessages_address()
- print 'Retrieving MediaWiki messages for %s' % repr(site)
- wikipedia.put_throttle() # It actually is a get, but a heavy one.
- allmessages = site.getUrl(path)
-
- print 'Parsing MediaWiki messages'
- soup = BeautifulSoup(allmessages,
- convertEntities=BeautifulSoup.HTML_ENTITIES)
- # The MediaWiki namespace in URL-encoded format, as it can contain
- # non-ASCII characters and spaces.
- quotedMwNs = urllib.quote(site.namespace(8).replace(' ', '_').encode(site.encoding()))
- mw_url = site.path() + "?title=" + quotedMwNs + ":"
- altmw_url = site.path() + "/" + quotedMwNs + ":"
- nicemw_url = site.nice_get_address(quotedMwNs + ":")
- shortmw_url = "/" + quotedMwNs + ":"
- ismediawiki = lambda url:url and (url.startswith(mw_url)
- or url.startswith(altmw_url)
- or url.startswith(nicemw_url)
- or url.startswith(shortmw_url))
- # we will save the found key:value pairs here
- dictionary = {}
-
- try:
- for keytag in soup('a', href=ismediawiki):
- # Key strings only contain ASCII characters, so we can save them as
- # strs
- key = str(keytag.find(text=True))
- keyrow = keytag.parent.parent
- if keyrow['class'] == "orig":
- valrow = keyrow.findNextSibling('tr')
- assert valrow['class'] == "new"
- value = unicode(valrow.td.string).strip()
- elif keyrow['class'] == 'def':
- value = unicode(keyrow('td')[1].string).strip()
- else:
- raise AssertionError("Unknown tr class value: %s" % keyrow['class'])
- dictionary[key] = value
- except Exception, e:
- wikipedia.debugDump( 'MediaWiki_Msg', site, u'%s: %s while processing URL: %s' % (repr(e), str(e), unicode(path)), allmessages)
- raise
-
- # Save the dictionary to disk
- # The file is stored in the mediawiki_messages subdir. Create if necessary.
- if dictionary == {}:
- wikipedia.debugDump( 'MediaWiki_Msg', site, u'Error URL: '+unicode(path), allmessages )
- sys.exit()
- else:
- f = open(makepath('mediawiki-messages/mediawiki-messages-%s-%s.dat' % (site.family.name, site.lang)), 'w')
- pickle.dump(dictionary, f)
- f.close()
- print "Loaded %i values from %s" % (len(dictionary.keys()), site)
- #print dictionary['sitestatstext']
-
-def refresh_all_messages():
- import dircache, time
- filenames = dircache.listdir('mediawiki-messages')
- message_filenameR = re.compile('mediawiki-messages-([a-z:]+)-([a-z:]+).dat')
- for filename in filenames:
- match = message_filenameR.match(filename)
- if match:
- family = match.group(1)
- lang = match.group(2)
- site = wikipedia.getSite(code = lang, fam = family)
- refresh_messages(site)
-
-def main():
- refresh_all = False
- refresh = False
- key = None
- for arg in wikipedia.handleArgs():
- if arg == '-all':
- refresh_all = True
- elif arg == '-refresh':
- refresh = True
- else:
- key = arg
- if key:
- wikipedia.output(get(key), toStdout = True)
- elif refresh_all:
- refresh_all_messages()
- elif refresh:
- refresh_messages(wikipedia.getSite())
- else:
- wikipedia.showHelp('mediawiki_messages')
-
-if __name__ == "__main__":
- try:
- main()
- except:
- wikipedia.stopme()
- raise
- else:
- wikipedia.stopme()
-
Revision: 5609
Author: leogregianin
Date: 2008-06-23 01:51:43 +0000 (Mon, 23 Jun 2008)
Log Message:
-----------
portuguese message
Modified Paths:
--------------
trunk/pywikipedia/djvutext.py
Modified: trunk/pywikipedia/djvutext.py
===================================================================
--- trunk/pywikipedia/djvutext.py 2008-06-23 01:43:16 UTC (rev 5608)
+++ trunk/pywikipedia/djvutext.py 2008-06-23 01:51:43 UTC (rev 5609)
@@ -32,12 +32,14 @@
msg = {
'en': u'Robot: creating page with text extracted from DjVu',
'fr': u'Bot: creating page with texte extracted from DjVu',
+ 'pt': u'Bot: criando página com texto extraído do DjVu',
}
# On English Wikisource, {{blank page}} is used to track blank pages.
# It may be omitted by adding an empty string like has been done for 'fr'.
blank = {
'en': u'{{blank page}}',
'fr': u'',
+ 'pt': u'',
}
def __init__(self, djvu, index, pages):
> You will have to wait until brion adds the new batch of developers; this
> may take a while as you just missed the last one :)
>
> --valhallasw
Ah, that's the reason; that's a pity...
Nevertheless, can someone explain me how I will can access the SVN server when I got added?
I guess it will work as follows, right?
1. with SSH client
2. Server/Host: "svn.wikimedia.org"
3. Port: "22"
Is that correct?
Note: If the *port*/host should be different (non-standard, because of security reasons), *do not post* it publically towards this mailing list...
Best regards, Melancholie
Bugs item #1867483, was opened at 2008-01-09 03:24
Message generated for change (Settings changed) made by leogregianin
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1867483&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: 5
Private: No
Submitted By: Alex S.H. Lin (lin4h)
Assigned to: Nobody/Anonymous (nobody)
Summary: Two speedy_delete.py bugs in zhwiki
Initial Comment:
The patch file is the CSD information in zhwiki. Please update it first and test the script in chinese wikipedia.
I tried to run this script after I add the template information({{unknown}}), but it cannot detect the template text in source page.
And the another bug...I select input action U, it has error:contains non-ASCII characters.
URL u'http://zh.wikipedia.org/w/index.php?title=Category%3A%E5%BF%AB%E9%80%9F%E5
%88%A0%E9%99%A4%E5%80%99%E9%80%89&redirect=no&from=Image:\u5433\u6c0f\u5b97\u796
05.jpg' contains non-ASCII characters
----------------------------------------------------------------------
Comment By: Rotem Liss (rotemliss)
Date: 2008-01-13 13:42
Message:
Logged In: YES
user_id=1327030
Originator: NO
Should be fixed in r4866.
----------------------------------------------------------------------
Comment By: Alex S.H. Lin (lin4h)
Date: 2008-01-12 15:54
Message:
Logged In: YES
user_id=1902991
Originator: YES
For the first problem:
In enwiki, when the script detect the source wikitext has template
name in deletion_messages (e.g. Db-author),delete reason can switch suggest
reason automatically ( Db-author→Deleting page per [[WP:CSD|CSD]] G7:
Author .......).
But in zhwiki, I patch deletion messages in script and run, The image
page has template name (call "unknown"), it cannot switch (for "unknown" in
zhwiki is "[[WP:CSD#I3]] 沒有版權資訊", it always stay in default
reason:[[WP:CSD]] )
----------------------------------------------------------------------
Comment By: Rotem Liss (rotemliss)
Date: 2008-01-12 14:45
Message:
Logged In: YES
user_id=1327030
Originator: NO
The information was commited as r4859, and the second problem was fixed in
r4860. I didn't understand the first problem, please clarify.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1867483&group_…
Patches item #1972587, was opened at 2008-05-26 05:06
Message generated for change (Settings changed) made by leogregianin
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1972587&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: 5
Private: No
Submitted By: David Crochet (crochet_david)
Assigned to: Nobody/Anonymous (nobody)
Summary: opened project for wikiversities (families)
Initial Comment:
Whith the creation of two new wikiversities (JA and PT)
----------------------------------------------------------------------
Comment By: David Crochet (crochet_david)
Date: 2008-05-31 03:10
Message:
Logged In: YES
user_id=1944800
Originator: YES
fixed in r5440
----------------------------------------------------------------------
Comment By: David Crochet (crochet_david)
Date: 2008-05-26 11:58
Message:
Logged In: YES
user_id=1944800
Originator: YES
adding cs wikiversity
File Added: new_family_wikiversity_v2.txt
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1972587&group_…
Patches item #1986308, was opened at 2008-06-06 07:26
Message generated for change (Comment added) made by leogregianin
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1986308&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: None
Priority: 5
Private: No
Submitted By: Melancholie (melancholie)
Assigned to: Nobody/Anonymous (nobody)
Summary: good.py
Initial Comment:
I have forked featured.py (my updated version, see #1985288).
The script good.py will do the very same like featured.py,
but for "good articles" (not for featured ones)!
Script source:
http://als.wikipedia.org/w/index.php?title=Benutzer:MelancholieBot/good.py&…
----------------------------------------------------------------------
>Comment By: Leonardo Gregianin (leogregianin)
Date: 2008-06-22 20:34
Message:
Logged In: YES
user_id=1136737
Originator: NO
Could you integrate the good.py within featured.py? Because the good.py is
basically the same script, the change is minimal. Regards, leonardo.
----------------------------------------------------------------------
Comment By: John (compwhizii)
Date: 2008-06-15 12:02
Message:
Logged In: YES
user_id=1924813
Originator: NO
Excuse my last comment.....
----------------------------------------------------------------------
Comment By: John (compwhizii)
Date: 2008-06-15 12:01
Message:
Logged In: YES
user_id=1924813
Originator: NO
C:\Documents and Settings\john2\My Documents\fixrd.patch
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1986308&group_…
Patches item #1999637, was opened at 2008-06-22 01:12
Message generated for change (Comment added) made by nicdumz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1999637&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: 5
Private: No
Submitted By: Melancholie (melancholie)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add hsb and sk summary translation for featured.py
Initial Comment:
Add the following line to the summary array:
'sk': u'Bot: [[%s:%s]] je najlep lnok',
See
http://de.wikipedia.org/wiki/Benutzer_Diskussion:Melancholie#sk_wiki
----------------------------------------------------------------------
>Comment By: NicDumZ Nicolas Dumazet (nicdumz)
Date: 2008-06-22 21:26
Message:
Logged In: YES
user_id=1963242
Originator: NO
applied in r5605, thanks.
----------------------------------------------------------------------
Comment By: Melancholie (melancholie)
Date: 2008-06-22 02:13
Message:
Logged In: YES
user_id=2089773
Originator: YES
Also add the summary for hsb:
'hsb': u'Bot: [[%s:%s]] je wubrny nastawk',
See
http://hsb.wikipedia.org/wiki/Diskusija_z_wu%C5%BEiwarjom:MelancholieBot#Te…
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1999637&group_…