/usr/lib/python2.7/dist-packages/pex/base.py is in python-pex 1.1.14-2ubuntu2.
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 | # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import absolute_import
from collections import Iterable
from pkg_resources import Requirement
from .compatibility import string as compatibility_string
REQUIRED_ATTRIBUTES = (
'extras',
'key',
'project_name',
'specs',
)
def quacks_like_req(req):
return all(hasattr(req, attr) for attr in REQUIRED_ATTRIBUTES)
def maybe_requirement(req):
if isinstance(req, Requirement) or quacks_like_req(req):
return req
elif isinstance(req, compatibility_string):
return Requirement.parse(req)
raise ValueError('Unknown requirement %r' % (req,))
def maybe_requirement_list(reqs):
if isinstance(reqs, (compatibility_string, Requirement)) or quacks_like_req(reqs):
return [maybe_requirement(reqs)]
elif isinstance(reqs, Iterable):
return [maybe_requirement(req) for req in reqs]
raise ValueError('Unknown requirement list %r' % (reqs,))
def requirement_is_exact(req):
return bool(req.specs and len(req.specs) == 1 and req.specs[0][0] == '==')
|