Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Kaufmann <humitos@gmail.com>2012-07-02 13:46:47 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-08-07 20:07:09 (GMT)
commit34543ec38176b062732a866045c0d807eced22d6 (patch)
tree719b647b2d77b3fc263885185e9a116e8bdf8f6b
parent835b09d0d23df71fe6991eed4969b472935c5b3c (diff)
Drop libxml2 SL #3419
This module dependency is replaced by ElementTree from the Python's Standard Library Signed-off-by: Manuel Kaufmann <humitos@gmail.com> Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--GetIABooksActivity.py1
-rw-r--r--languagenames.py34
2 files changed, 10 insertions, 25 deletions
diff --git a/GetIABooksActivity.py b/GetIABooksActivity.py
index f7943c9..3fb36b7 100644
--- a/GetIABooksActivity.py
+++ b/GetIABooksActivity.py
@@ -595,7 +595,6 @@ class GetIABooksActivity(activity.Activity):
self.bt_catalogs.set_active(True)
def can_close(self):
- self._lang_code_handler.close()
if self.queryresults is not None:
self.queryresults.cancel()
self.queryresults = None
diff --git a/languagenames.py b/languagenames.py
index 644af8f..88329ce 100644
--- a/languagenames.py
+++ b/languagenames.py
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-import libxml2
+from xml.etree import ElementTree
import logging
_ISO_639_XML_PATH = '/usr/share/xml/iso-codes/iso_639.xml'
@@ -31,37 +31,23 @@ def singleton(object, instantiated=[]):
class LanguageNames(object):
+
def __init__(self):
singleton(self)
- try:
- self._xmldoc = libxml2.parseFile(_ISO_639_XML_PATH)
- self._cache = None
- except libxml2.parserError:
- self._xmldoc = None
- return
-
- self._eroot = self._xmldoc.getRootElement()
-
- def close(self):
- if self._xmldoc is not None:
- self._xmldoc.freeDoc()
+ self._cache = None
def get_full_language_name(self, code):
if self._cache == None:
self._cache = {}
- for child in self._eroot.children:
- if child.properties is not None:
- lang_code = None
- lang_name = None
- for property in child.properties:
- if property.get_name() == 'name':
- lang_name = property.get_content()
- elif property.get_name() == 'iso_639_1_code':
- lang_code = property.get_content()
+ _xmldoc = ElementTree.parse(_ISO_639_XML_PATH)
+ _eroot = _xmldoc.getroot()
+ for child in _eroot.getchildren():
+ if child.attrib is not None:
+ lang_name = child.attrib.get('name', None)
+ lang_code = child.attrib.get('iso_639_1_code', None)
if lang_code is not None and lang_name is not None:
self._cache[lang_code] = lang_name
- self._xmldoc.freeDoc()
- self._xmldoc = None
+ _xmldoc = None
return self._cache[code]