/usr/lib/python3/dist-packages/pkginfo/develop.py is in python3-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 | import os
import sys
import warnings
from pkginfo.distribution import Distribution
def _gather_py2(top, candidates): #pragma NO COVER Py3k
def _filter(candidates, dirname, fnames):
for fname in fnames:
fqn = os.path.join(dirname, fname)
if os.path.isdir(fqn):
if fname == 'EGG-INFO' or fname.endswith('.egg-info'):
candidates.append(fqn)
os.path.walk(top, _filter, candidates)
def _gather_py3(top, candidates): #pragma NO COVER Python2
for dirpath, dirnames, fnames in os.walk(top):
for dirname in dirnames:
fqn = os.path.join(dirpath, dirname)
if dirname == 'EGG-INFO' or dirname.endswith('.egg-info'):
candidates.append(fqn)
if sys.version_info[0] < 3: #pragma NO COVER Python2
_gather = _gather_py2
else: #pragma NO COVER Py3k
_gather = _gather_py3
class Develop(Distribution):
def __init__(self, path, metadata_version=None):
self.path = os.path.abspath(
os.path.normpath(
os.path.expanduser(path)))
self.metadata_version = metadata_version
self.extractMetadata()
def read(self):
candidates = [self.path]
_gather(self.path, candidates)
for candidate in candidates:
path = os.path.join(candidate, 'PKG-INFO')
if os.path.exists(path):
with open(path) as f:
return f.read()
warnings.warn('No PKG-INFO found for path: %s' % self.path)
|