This file is indexed.

/usr/lib/python2.7/dist-packages/fastkml/atom.py is in python-fastkml 0.11-1.

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
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# -*- coding: utf-8 -*-
# Copyright (C) 2012  Christian Ledermann
#
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# This library 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 Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA

"""
KML 2.2 supports new elements for including data about the author and related
website in your KML file. This information is displayed in geo search results,
both in Earth browsers such as Google Earth, and in other applications such as
Google Maps. The ascription elements used in KML are as follows:

atom:author element - parent element for atom:name
atom:name element - the name of the author
atom:link element - contains the href attribute
href attribute - URL of the web page containing the KML/KMZ file

These elements are defined in the Atom Syndication Format. The complete
specification is found at http://atompub.org.

This library only implements a subset of Atom that is useful with KML
"""

import logging
logger = logging.getLogger('fastkml.atom')

from .config import etree
from .config import ATOMNS as NS
from .config import LXML

import re
regex = r"^[a-zA-Z0-9._%-]+@([a-zA-Z0-9-]+\.)*[a-zA-Z]{2,4}$"
check_email = re.compile(regex).match


class Link(object):
    """
    Identifies a related Web page. The type of relation is defined by
    the rel attribute. A feed is limited to one alternate per type and
    hreflang.
    <link> is patterned after html's link element. It has one required
    attribute, href, and five optional attributes: rel, type, hreflang,
    title, and length.
    """
    __name__ = 'Link'
    ns = None

    href = None
    # href is the URI of the referenced resource

    rel = None
    # rel contains a single link relationship type.
    # It can be a full URI, or one of the following predefined values
    # (default=alternate):
    # alternate: an alternate representation
    # enclosure: a related resource which is potentially large in size
    # and might require special handling, for example an audio or video
    # recording.
    # related: an document related to the entry or feed.
    # self: the feed itself.
    # via: the source of the information provided in the entry.

    type = None
    # indicates the media type of the resource

    hreflang = None
    # indicates the language of the referenced resource

    title = None
    # human readable information about the link

    length = None
    # the length of the resource, in bytes

    def __init__(
        self, ns=None, href=None, rel=None, type=None,
        hreflang=None, title=None, length=None
    ):
        if ns is None:
            self.ns = NS
        else:
            self.ns = ns
        self.href = href
        self.rel = rel
        self.type = type
        self.hreflang = hreflang
        self.title = title
        self.length = length

    def from_string(self, xml_string):
        self.from_element(etree.XML(xml_string))

    def from_element(self, element):
        if self.ns + self.__name__.lower() != element.tag:
            raise TypeError
        else:
            if element.get('href'):
                self.href = element.get('href')
            else:
                logger.critical('required attribute href missing')
                raise TypeError
            if element.get('rel'):
                self.rel = element.get('rel')
            if element.get('type'):
                self.type = element.get('type')
            if element.get('hreflang'):
                self.hreflang = element.get('hreflang')
            if element.get('title'):
                self.title = element.get('title')
            if element.get('length'):
                self.length = element.get('length')

    def etree_element(self):
        element = etree.Element(self.ns + self.__name__.lower())
        if self.href:
            element.set('href', self.href)
        else:
            raise ValueError('required attribute href missing')
        if self.rel:
            element.set('rel', self.rel)
        if self.type:
            element.set('type', self.type)
        if self.hreflang:
            element.set('hreflang', self.hreflang)
        if self.title:
            element.set('title', self.title)
        if self.length:
            element.set('length', self.length)
        return element

    def to_string(self, prettyprint=True):
        """ Return the ATOM Object as serialized xml """
        if LXML and prettyprint:
            return etree.tostring(
                self.etree_element(),
                encoding='utf-8',
                pretty_print=True).decode('UTF-8')
        else:
            return etree.tostring(
                self.etree_element(),
                encoding='utf-8').decode('UTF-8')


class _Person(object):
    """
    <author> and <contributor> describe a person, corporation, or similar
    entity. It has one required element, name, and two optional elements:
    uri, email.
    """
    __name__ = None
    ns = None

    name = None
    # conveys a human-readable name for the person.

    uri = None
    # contains a home page for the person.

    email = None
    # contains an email address for the person.

    def __init__(self, ns=None, name=None, uri=None, email=None):
        if ns is None:
            self.ns = NS
        else:
            self.ns = ns
        self.name = name
        self.uri = uri
        self.email = email

    def etree_element(self):
        element = etree.Element(self.ns + self.__name__.lower())
        if self.name:
            name = etree.SubElement(element, "%sname" % self.ns)
            name.text = self.name
        # else:
        #    logger.critical('No Name for person defined')
        #    raise TypeError
        if self.uri:
            # XXX validate uri
            uri = etree.SubElement(element, "%suri" % self.ns)
            uri.text = self.uri
        if self.email:
            if check_email(self.email):
                email = etree.SubElement(element, "%semail" % self.ns)
                email.text = self.email
        return element

    def from_string(self, xml_string):
        self.from_element(etree.XML(xml_string))

    def from_element(self, element):
        if self.ns + self.__name__.lower() != element.tag:
            raise TypeError
        else:
            name = element.find('%sname' % self.ns)
            if name is not None:
                self.name = name.text
            uri = element.find('%suri' % self.ns)
            if uri is not None:
                self.uri = uri.text
            email = element.find('%semail' % self.ns)
            if email is not None:
                if check_email(email.text):
                    self.email = email.text

    def to_string(self, prettyprint=True):
        """ Return the ATOM Object as serialized xml """
        if LXML and prettyprint:
            return etree.tostring(
                self.etree_element(),
                encoding='utf-8',
                pretty_print=True).decode('UTF-8')
        else:
            return etree.tostring(
                self.etree_element(),
                encoding='utf-8').decode('UTF-8')


class Author(_Person):
    """ Names one author of the feed/entry. A feed/entry may have
    multiple authors."""
    __name__ = "Author"


class Contributor(_Person):
    """ Names one contributor to the feed/entry. A feed/entry may have
    multiple contributor elements."""
    __name__ = "Contributor"