Revision: 8092 Author: xqt Date: 2010-04-15 11:20:07 +0000 (Thu, 15 Apr 2010)
Log Message: ----------- .7z support to the xmlreader (by DC987)
Modified Paths: -------------- trunk/pywikipedia/xmlreader.py
Modified: trunk/pywikipedia/xmlreader.py =================================================================== --- trunk/pywikipedia/xmlreader.py 2010-04-14 14:14:12 UTC (rev 8091) +++ trunk/pywikipedia/xmlreader.py 2010-04-15 11:20:07 UTC (rev 8092) @@ -15,7 +15,13 @@ http://www.effbot.org/ for earlier versions). If not found, it falls back to the older method using regular expressions. """ +# +# (C) Pywikipedia bot team, 2005-2010 +# +# Distributed under the terms of the MIT license. +# __version__='$Id$' +#
import threading import xml.sax @@ -285,6 +291,13 @@ if self.filename.endswith('.bz2'): import bz2 source = bz2.BZ2File(self.filename) + elif self.filename.endswith('.7z'): + import subprocess + source = subprocess.Popen('7za e -bd -so %s 2>/dev/null' + % self.filename, + shell=True, + stdout=subprocess.PIPE, + bufsize=65535).stdout else: # assume it's an uncompressed XML file source = open(self.filename)
pywikipedia-svn@lists.wikimedia.org