mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
used os.path.sep consistently
This commit is contained in:
@@ -7,12 +7,12 @@ import evaluate
|
|||||||
import modules
|
import modules
|
||||||
import debug
|
import debug
|
||||||
import imports
|
import imports
|
||||||
# TODO use os.path.sep and similar things
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
__all__ = ['complete', 'goto', 'get_definitions',
|
__all__ = ['complete', 'goto', 'get_definitions',
|
||||||
'NotFoundError', 'set_debug_function']
|
'NotFoundError', 'set_debug_function']
|
||||||
|
|
||||||
|
|
||||||
class NotFoundError(Exception):
|
class NotFoundError(Exception):
|
||||||
""" A custom error to avoid catching the wrong exceptions """
|
""" A custom error to avoid catching the wrong exceptions """
|
||||||
pass
|
pass
|
||||||
@@ -99,7 +99,7 @@ class Definition(object):
|
|||||||
def module_name(self):
|
def module_name(self):
|
||||||
path = self.module_path
|
path = self.module_path
|
||||||
try:
|
try:
|
||||||
return path[path.rindex('/') + 1:]
|
return path[path.rindex(os.path.sep) + 1:]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@@ -129,14 +129,15 @@ class Definition(object):
|
|||||||
elif isinstance(d, evaluate.parsing.Module):
|
elif isinstance(d, evaluate.parsing.Module):
|
||||||
p = str(d.path)
|
p = str(d.path)
|
||||||
# only show module name
|
# only show module name
|
||||||
p = re.sub(r'^.*?([\w\d]+)(/__init__)?.py$', r'\1', p)
|
sep = os.path.sep
|
||||||
|
p = re.sub(r'^.*?([\w\d]+)(%s__init__)?.py$' % sep, r'\1', p)
|
||||||
d = 'module ' + p
|
d = 'module ' + p
|
||||||
else:
|
else:
|
||||||
d = d.get_code().replace('\n', '')
|
d = d.get_code().replace('\n', '')
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.module_path[0] == '/':
|
if self.module_path[0] == os.path.sep:
|
||||||
position = '@%s' % (self.line_nr)
|
position = '@%s' % (self.line_nr)
|
||||||
else:
|
else:
|
||||||
# no path - is a builtin
|
# no path - is a builtin
|
||||||
|
|||||||
Reference in New Issue
Block a user