You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd great if we could find a way to decouple the API from the filesystem, at least in parts. This won't work for functions like walk_up, but when I look at parse it'd relatively easy to just pass in a file like object:
def parse(self, file_handle):
# Open the Pipfile.
content = f.read()
...
Same goes for the find function. Instead of calling os.getcwd explicitly in find, call it in walk_up:
@staticmethod
def find(max_depth=3):
"""Returns the path of a Pipfile in parent directories."""
i = 0
for c, d, f in walk_up():
...
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(os.getcwd())
...
This would help external tools a lot to work with the API. There are probably still a lot of design decisions to make here, but if there's any interest in supporting external tools I'd be happy to submit a PR that addresses some of the points I mentioned earlier.
The text was updated successfully, but these errors were encountered:
The API is currently designed in a way that it tightly coupled with the file system. The
parse
function for example expects thePipfile
to be a filename: https://github.com/pypa/pipfile/blob/master/pipfile/api.py#L70It'd great if we could find a way to decouple the API from the filesystem, at least in parts. This won't work for functions like
walk_up
, but when I look atparse
it'd relatively easy to just pass in a file like object:Same goes for the
find
function. Instead of callingos.getcwd
explicitly infind
, call it inwalk_up
:This would help external tools a lot to work with the API. There are probably still a lot of design decisions to make here, but if there's any interest in supporting external tools I'd be happy to submit a PR that addresses some of the points I mentioned earlier.
The text was updated successfully, but these errors were encountered: