/usr/lib/python2.7/dist-packages/pkginfo/utils.py is in python-pkginfo 1.2.1-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 | import os
from types import ModuleType
from pkginfo.bdist import BDist
from pkginfo.develop import Develop
from pkginfo.installed import Installed
from pkginfo.sdist import SDist
from pkginfo.wheel import Wheel
def get_metadata(path_or_module, metadata_version=None):
""" Try to create a Distribution 'path_or_module'.
o 'path_or_module' may be a module object.
o If a string, 'path_or_module' may point to an sdist file, a bdist
file, an installed package, or a working checkout (if it contains
PKG-INFO).
o Return None if 'path_or_module' can't be parsed.
"""
if isinstance(path_or_module, ModuleType):
try:
return Installed(path_or_module, metadata_version)
except (ValueError, IOError): #pragma NO COVER
pass
try:
__import__(path_or_module)
except ImportError:
pass
else:
try:
return Installed(path_or_module, metadata_version)
except (ValueError, IOError): #pragma NO COVER
pass
if os.path.isfile(path_or_module):
try:
return SDist(path_or_module, metadata_version)
except (ValueError, IOError):
pass
try:
return BDist(path_or_module, metadata_version)
except (ValueError, IOError): #pragma NO COVER
pass
try:
return Wheel(path_or_module, metadata_version)
except (ValueError, IOError): #pragma NO COVER
pass
if os.path.isdir(path_or_module):
try:
return Develop(path_or_module, metadata_version)
except (ValueError, IOError): #pragma NO COVER
pass
|