Merge branch 'dev' of github.com:davidhalter/jedi into dev

This commit is contained in:
David Halter
2013-07-10 10:24:22 +02:00
4 changed files with 30 additions and 47 deletions

3
docs/_static/logo-src.txt vendored Normal file
View File

@@ -0,0 +1,3 @@
The source of the logo is a photoshop file hosted here:
https://dl.dropboxusercontent.com/u/170011615/Jedi12_Logo.psd.xz

BIN
docs/_static/logo.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -54,7 +54,7 @@ Emacs:
- `Jedi.el <https://github.com/tkf/emacs-jedi>`_ - `Jedi.el <https://github.com/tkf/emacs-jedi>`_
Sublime Text 2: Sublime Text 2/3:
- `SublimeJEDI <https://github.com/svaiter/SublimeJEDI>`_ - `SublimeJEDI <https://github.com/svaiter/SublimeJEDI>`_

View File

@@ -16,58 +16,45 @@ is_py33 = sys.hexversion >= 0x03030000
def find_module_py33(string, path=None): def find_module_py33(string, path=None):
mod_info = (None, None, None) loader = importlib.machinery.PathFinder.find_module(string, path)
loader = None
if path is not None: if loader is None and path is None: # Fallback to find builtins
# Check for the module in the specidied path loader = importlib.find_loader(string)
loader = importlib.machinery.PathFinder.find_module(string, path)
else:
# Check for the module in sys.path
loader = importlib.machinery.PathFinder.find_module(string, sys.path)
if loader is None:
# Fallback to find builtins
loader = importlib.find_loader(string)
if loader is None: if loader is None:
raise ImportError raise ImportError("Couldn't find a loader for {0}".format(string))
try: try:
if (loader.is_package(string)): is_package = loader.is_package(string)
mod_info = (None, os.path.dirname(loader.path), True) if is_package:
module_path = os.path.dirname(loader.path)
module_file = None
else: else:
filename = loader.get_filename(string) module_path = loader.get_filename(string)
if filename and os.path.exists(filename): module_file = open(module_path)
mod_info = (open(filename, 'U'), filename, False)
else:
mod_info = (None, filename, False)
except AttributeError: except AttributeError:
mod_info = (None, loader.load_module(string).__name__, False) module_path = loader.load_module(string).__name__
module_file = None
return mod_info return module_file, module_path, is_package
def find_module_pre_py33(string, path=None): def find_module_pre_py33(string, path=None):
mod_info = None module_file, module_path, description = imp.find_module(string, path)
if path is None: module_type = description[2]
mod_info = imp.find_module(string) return module_file, module_path, module_type is imp.PKG_DIRECTORY
else:
mod_info = imp.find_module(string, path)
return (mod_info[0], mod_info[1], mod_info[2][2] == imp.PKG_DIRECTORY)
def find_module(string, path=None): find_module = find_module_py33 if is_py33 else find_module_pre_py33
"""Provides information about a module. find_module.__doc__ = """
Provides information about a module.
This function isolates the differences in importing libraries introduced with This function isolates the differences in importing libraries introduced with
python 3.3 on; it gets a module name and optionally a path. It will return a python 3.3 on; it gets a module name and optionally a path. It will return a
tuple containin an open file for the module (if not builtin), the filename tuple containin an open file for the module (if not builtin), the filename
or the name of the module if it is a builtin one and a boolean indicating or the name of the module if it is a builtin one and a boolean indicating
if the module is contained in a package.""" if the module is contained in a package.
if is_py33: """
return find_module_py33(string, path)
else:
return find_module_pre_py33(string, path)
# next was defined in python 2.6, in python 3 obj.next won't be possible # next was defined in python 2.6, in python 3 obj.next won't be possible
# anymore # anymore
@@ -157,13 +144,6 @@ class Python3Method(object):
else: else:
return lambda *args, **kwargs: self.func(obj, *args, **kwargs) return lambda *args, **kwargs: self.func(obj, *args, **kwargs)
try:
# the python3 way
from functools import reduce
except ImportError:
reduce = reduce
def use_metaclass(meta, *bases): def use_metaclass(meta, *bases):
""" Create a class with a metaclass. """ """ Create a class with a metaclass. """
if not bases: if not bases: