mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
update vendored pipfile
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
Vendored
+5
-39
@@ -16,37 +16,6 @@ def format_full_version(info):
|
||||
return version
|
||||
|
||||
|
||||
def walk_up(bottom):
|
||||
"""mimic os.walk, but walk 'up' instead of down the directory tree.
|
||||
From: https://gist.github.com/zdavkeos/1098474
|
||||
"""
|
||||
|
||||
bottom = os.path.realpath(bottom)
|
||||
|
||||
# get files in current dir
|
||||
try:
|
||||
names = os.listdir(bottom)
|
||||
except Exception:
|
||||
return
|
||||
|
||||
dirs, nondirs = [], []
|
||||
for name in names:
|
||||
if os.path.isdir(os.path.join(bottom, name)):
|
||||
dirs.append(name)
|
||||
else:
|
||||
nondirs.append(name)
|
||||
|
||||
yield bottom, dirs, nondirs
|
||||
|
||||
new_path = os.path.realpath(os.path.join(bottom, '..'))
|
||||
|
||||
# see if we are at the top
|
||||
if new_path == bottom:
|
||||
return
|
||||
|
||||
for x in walk_up(new_path):
|
||||
yield x
|
||||
|
||||
|
||||
class PipfileParser(object):
|
||||
def __init__(self, filename='Pipfile'):
|
||||
@@ -108,16 +77,13 @@ class Pipfile(object):
|
||||
def find(max_depth=3):
|
||||
"""Returns the path of a Pipfile in parent directories."""
|
||||
i = 0
|
||||
for c, d, f in walk_up(os.getcwd()):
|
||||
for c, d, f in os.walk(os.getcwd(), topdown=False):
|
||||
if i > max_depth:
|
||||
raise RuntimeError('No Pipfile found!')
|
||||
elif 'Pipfile' in f:
|
||||
return os.path.join(c, 'Pipfile')
|
||||
i += 1
|
||||
|
||||
if i < max_depth:
|
||||
if 'Pipfile':
|
||||
p = os.path.join(c, 'Pipfile')
|
||||
if os.path.isfile(p):
|
||||
return p
|
||||
raise RuntimeError('No Pipfile found!')
|
||||
|
||||
@classmethod
|
||||
def load(klass, filename):
|
||||
"""Load a Pipfile from a given filename."""
|
||||
|
||||
Reference in New Issue
Block a user