示例#1
0
文件: project.py 项目: syntonym/jedi
    def _get_sys_path(self, evaluator, environment=None):
        """
        Keep this method private for all users of jedi. However internally this
        one is used like a public method.
        """
        suffixed = []
        prefixed = []

        sys_path = list(self._get_base_sys_path(environment))
        if self._smart_sys_path:
            prefixed.append(self._path)

            if evaluator.script_path is not None:
                suffixed += discover_buildout_paths(evaluator, evaluator.script_path)

                traversed = []
                for parent in traverse_parents(evaluator.script_path):
                    traversed.append(parent)
                    if parent == self._path:
                        # Don't go futher than the project path.
                        break

                # AFAIK some libraries have imports like `foo.foo.bar`, which
                # leads to the conclusion to by default prefer longer paths
                # rather than shorter ones by default.
                suffixed += reversed(traversed)

        if self._django:
            prefixed.append(self._path)

        path = prefixed + sys_path + suffixed
        return list(_force_unicode_list(_remove_duplicates_from_path(path)))
示例#2
0
    def _get_sys_path(self, evaluator, environment=None):
        """
        Keep this method private for all users of jedi. However internally this
        one is used like a public method.
        """
        suffixed = []
        prefixed = []

        sys_path = list(self._get_base_sys_path(environment))
        if self._smart_sys_path:
            prefixed.append(self._path)

            if evaluator.script_path is not None:
                suffixed += discover_buildout_paths(evaluator, evaluator.script_path)

                traversed = list(traverse_parents(evaluator.script_path))

                # AFAIK some libraries have imports like `foo.foo.bar`, which
                # leads to the conclusion to by default prefer longer paths
                # rather than shorter ones by default.
                suffixed += reversed(traversed)

        if self._django:
            prefixed.append(self._path)

        path = prefixed + sys_path + suffixed
        return list(_force_unicode_list(_remove_duplicates_from_path(path)))