/usr/lib/python2.7/dist-packages/isoquery/xmlfile_3166.py is in isoquery 1.7-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | # - encoding: UTF-8 -
#
# Copyright © 2007-2012 Tobias Quathamer
#
# This file is part of isoquery.
#
# isoquery is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# isoquery is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import gettext
translation = gettext.translation('isoquery', fallback=True)
_ = translation.ugettext
from lxml import etree
import xmlfile
from code_not_defined_error import CodeNotDefinedError
class XMLFile_3166(xmlfile.XMLFile):
"""Handle ISO 3166"""
def get_display_codes(self):
"""Return a list of code attributes"""
return ["alpha_2_code", "alpha_3_code", "numeric_code"]
def get_display_names(self, display_name):
"""Return a list of possible name attributes.
If the first attribute is not found, the next one in the list
will be tried. This is to enable official_name and
common_name in ISO 3166, other standards don't need this."""
if display_name != "name":
# Add 'name' as fallback option
return [display_name, "name"]
else:
return ["name"]
def get_xpaths(self, code):
"""Return a list of all xpaths needed to show the requested codes"""
xpaths = []
if (len(code) == 2):
xpath = "//iso_3166_entry[@alpha_2_code='" + code.upper() + "']"
elif (code.isdigit()):
xpath = "//iso_3166_entry[@numeric_code='" + code.upper() + "']"
else:
xpath = "//iso_3166_entry[@alpha_3_code='" + code.upper() + "']"
xpaths.append(xpath)
return xpaths
|