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