mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
python2.5 compatibillity
This commit is contained in:
@@ -2,7 +2,6 @@ import re
|
|||||||
|
|
||||||
import debug
|
import debug
|
||||||
import parsing
|
import parsing
|
||||||
import __builtin__
|
|
||||||
|
|
||||||
|
|
||||||
class Parser(object):
|
class Parser(object):
|
||||||
@@ -80,8 +79,8 @@ class Parser(object):
|
|||||||
pass
|
pass
|
||||||
code += '"""\n%s\n"""\n' % scope.__doc__
|
code += '"""\n%s\n"""\n' % scope.__doc__
|
||||||
|
|
||||||
names = set(dir(scope)) - {'__file__', '__name__', '__doc__',
|
names = set(dir(scope)) - set(['__file__', '__name__', '__doc__',
|
||||||
'__path__', '__package__'}
|
'__path__', '__package__'])
|
||||||
classes, funcs, stmts, members = get_types(names)
|
classes, funcs, stmts, members = get_types(names)
|
||||||
|
|
||||||
# classes
|
# classes
|
||||||
@@ -140,7 +139,6 @@ def parse_function_doc(func):
|
|||||||
This is nothing more than a docstring parser.
|
This is nothing more than a docstring parser.
|
||||||
"""
|
"""
|
||||||
# TODO: things like utime(path, (atime, mtime)) and a(b [, b]) -> None
|
# TODO: things like utime(path, (atime, mtime)) and a(b [, b]) -> None
|
||||||
params = []
|
|
||||||
doc = func.__doc__
|
doc = func.__doc__
|
||||||
|
|
||||||
# get full string, parse round parentheses: def func(a, (b,c))
|
# get full string, parse round parentheses: def func(a, (b,c))
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ follow_statement -> follow_call -> follow_paths -> follow_path
|
|||||||
|
|
||||||
TODO include super classes
|
TODO include super classes
|
||||||
"""
|
"""
|
||||||
|
# python2.5 compatibility
|
||||||
|
try:
|
||||||
|
next
|
||||||
|
except NameError:
|
||||||
|
def next(obj):
|
||||||
|
return obj.next()
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
import parsing
|
import parsing
|
||||||
|
|||||||
4
ftest.py
4
ftest.py
@@ -11,8 +11,8 @@ f_name = 'test.py'
|
|||||||
import os
|
import os
|
||||||
path = os.getcwd() + '/' + f_name
|
path = os.getcwd() + '/' + f_name
|
||||||
|
|
||||||
with open(path) as f:
|
f = open(path)
|
||||||
code = f.read()
|
code = f.read()
|
||||||
for i in range(1):
|
for i in range(1):
|
||||||
completions = functions.complete(code, 150, 200, path)
|
completions = functions.complete(code, 150, 200, path)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import debug
|
|||||||
|
|
||||||
__all__ = ['complete', 'get_completion_parts', 'complete_test', 'set_debug_function']
|
__all__ = ['complete', 'get_completion_parts', 'complete_test', 'set_debug_function']
|
||||||
|
|
||||||
|
|
||||||
class FileWithCursor(modules.File):
|
class FileWithCursor(modules.File):
|
||||||
"""
|
"""
|
||||||
Manages all files, that are parsed and caches them.
|
Manages all files, that are parsed and caches them.
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ def find_module(current_module, point_path):
|
|||||||
raise
|
raise
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
# TODO handle relative paths - they are included int the import object
|
||||||
current_namespace = None
|
current_namespace = None
|
||||||
sys.path.insert(0, os.path.dirname(current_module.module_path))
|
sys.path.insert(0, os.path.dirname(current_module.module_path))
|
||||||
# now execute those paths
|
# now execute those paths
|
||||||
@@ -108,8 +109,10 @@ def find_module(current_module, point_path):
|
|||||||
# is a directory module
|
# is a directory module
|
||||||
if is_package_directory:
|
if is_package_directory:
|
||||||
path += '/__init__.py'
|
path += '/__init__.py'
|
||||||
with open(path) as f:
|
# python2.5 cannot cope with the `with` statement
|
||||||
source = f.read()
|
#with open(path) as f:
|
||||||
|
# source = f.read()
|
||||||
|
source = open(path).read()
|
||||||
else:
|
else:
|
||||||
source = current_namespace[0].read()
|
source = current_namespace[0].read()
|
||||||
f = File(path, source)
|
f = File(path, source)
|
||||||
|
|||||||
Reference in New Issue
Block a user