home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import os
- import gettext
- from xml.etree.ElementTree import ElementTree
-
- class CountryInformation(object):
-
- def __init__(self):
- self.countries = { }
- fname = '/usr/share/xml/iso-codes/iso_3166.xml'
- if os.path.exists(fname):
- et = ElementTree(file = fname)
- it = et.getiterator('iso_3166_entry')
- for elm in it:
- if elm.attrib.has_key('common_name'):
- descr = elm.attrib['common_name']
- else:
- descr = elm.attrib['name']
- if elm.attrib.has_key('alpha_2_code'):
- code = elm.attrib['alpha_2_code']
- else:
- code = elm.attrib['alpha_3_code']
- self.countries[code] = gettext.dgettext('iso_3166', descr)
-
-
- self.country = None
- self.code = None
- locale = os.getenv('LANG', default = 'en.UK')
- a = locale.find('_')
- z = locale.find('.')
- if z == -1:
- z = len(locale)
-
- self.code = locale[a + 1:z]
- self.country = self.get_country_name(self.code)
-
-
- def get_country_name(self, code):
- if self.countries.has_key(code):
- name = self.countries[code]
- return name
- return code
-
-
-