mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Revert "Fix: no longer shows folders recursively to root"
This reverts commit 03b4177d3d.
This commit is contained in:
@@ -110,10 +110,7 @@ class Project(object):
|
|||||||
suffixed += discover_buildout_paths(inference_state, inference_state.script_path)
|
suffixed += discover_buildout_paths(inference_state, inference_state.script_path)
|
||||||
|
|
||||||
if add_parent_paths:
|
if add_parent_paths:
|
||||||
traversed = list(traverse_parents(
|
traversed = list(traverse_parents(inference_state.script_path))
|
||||||
inference_state.script_path,
|
|
||||||
root=self._path,
|
|
||||||
))
|
|
||||||
|
|
||||||
# AFAIK some libraries have imports like `foo.foo.bar`, which
|
# AFAIK some libraries have imports like `foo.foo.bar`, which
|
||||||
# leads to the conclusion to by default prefer longer paths
|
# leads to the conclusion to by default prefer longer paths
|
||||||
|
|||||||
@@ -2,31 +2,15 @@ import os
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
|
||||||
def traverse_parents(path, root=None, include_current=False):
|
def traverse_parents(path, include_current=False):
|
||||||
"""Iterate directories from a path to search root
|
|
||||||
|
|
||||||
:path: the path of the script/directory to check.
|
|
||||||
:root: the root of the upward search. Assumes the system root if root is
|
|
||||||
None.
|
|
||||||
:include_current: includes the current file / directory.
|
|
||||||
|
|
||||||
If the root path is not a substring of the provided path, assume the root
|
|
||||||
search path as well.
|
|
||||||
"""
|
|
||||||
if not include_current:
|
if not include_current:
|
||||||
path = os.path.dirname(path)
|
path = os.path.dirname(path)
|
||||||
|
|
||||||
previous = None
|
previous = None
|
||||||
if root is None or not path.startswith(root):
|
while previous != path:
|
||||||
while previous != path:
|
yield path
|
||||||
yield path
|
previous = path
|
||||||
previous = path
|
path = os.path.dirname(path)
|
||||||
path = os.path.dirname(path)
|
|
||||||
else:
|
|
||||||
while previous != root:
|
|
||||||
yield path
|
|
||||||
previous = path
|
|
||||||
path = os.path.dirname(path)
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|||||||
Reference in New Issue
Block a user