This file is indexed.

/usr/lib/python3/dist-packages/prov/identifier.py is in python3-prov 1.5.0-2.

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
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

__author__ = 'Trung Dong Huynh'
__email__ = 'trungdong@donggiang.com'

import six


@six.python_2_unicode_compatible
class Identifier(object):
    """Base class for all identifiers and also represents xsd:anyURI
    """
    # TODO: make Identifier an "abstract" base class and move xsd:anyURI
    # into a subclass

    def __init__(self, uri):
        self._uri = six.text_type(uri)  # Ensure this is a unicode string

    @property
    def uri(self):
        return self._uri

    def __str__(self):
        return self._uri

    def __eq__(self, other):
        return self.uri == other.uri if isinstance(other, Identifier) else False

    def __hash__(self):
        return hash((self.uri, self.__class__))

    def __repr__(self):
        return '<%s: %s>' % (self.__class__.__name__, self._uri)

    def provn_representation(self):
        return '"%s" %%%% xsd:anyURI' % self._uri


@six.python_2_unicode_compatible
class QualifiedName(Identifier):
    def __init__(self, namespace, localpart):
        Identifier.__init__(self, u''.join([namespace.uri, localpart]))
        self._namespace = namespace
        self._localpart = localpart
        self._str = (
            ':'.join([namespace.prefix, localpart])
            if namespace.prefix else localpart
        )

    @property
    def namespace(self):
        return self._namespace

    @property
    def localpart(self):
        return self._localpart

    def __str__(self):
        return self._str

    def __repr__(self):
        return '<%s: %s>' % (self.__class__.__name__, self._str)

    def __hash__(self):
        return hash(self.uri)

    def provn_representation(self):
        return "'%s'" % self._str


class Namespace(object):
    def __init__(self, prefix, uri):
        self._prefix = prefix
        self._uri = uri
        self._cache = dict()

    @property
    def uri(self):
        return self._uri

    @property
    def prefix(self):
        return self._prefix

    def contains(self, identifier):
        uri = identifier if isinstance(identifier, six.string_types) else (
            identifier.uri if isinstance(identifier, Identifier) else None
        )
        return uri.startswith(self._uri) if uri else False

    def qname(self, identifier):
        uri = identifier if isinstance(identifier, six.string_types) else (
            identifier.uri if isinstance(identifier, Identifier) else None
        )
        if uri and uri.startswith(self._uri):
            return QualifiedName(self, uri[len(self._uri):])
        else:
            return None

    def __eq__(self, other):
        return (
            (self._uri == other.uri and self._prefix == other.prefix)
            if isinstance(other, Namespace) else False
        )

    def __ne__(self, other):
        return (
            not isinstance(other, Namespace) or
            self._uri != other.uri or
            self._prefix != other.prefix
        )

    def __hash__(self):
        return hash((self._uri, self._prefix))

    def __repr__(self):
        return '<%s: %s {%s}>' % (
            self.__class__.__name__, self._prefix, self._uri
        )

    def __getitem__(self, localpart):
        if localpart in self._cache:
            return self._cache[localpart]
        else:
            qname = QualifiedName(self, localpart)
            self._cache[localpart] = qname
            return qname