RefactoringRope/RefactoringClient.py

changeset 251
4dcc73076100
parent 245
75a35a927952
child 293
dd1c7ed6d880
equal deleted inserted replaced
250:7696de7c81bc 251:4dcc73076100
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import sys 12 import sys
13 import os 13 import os
14 14
15 try:
16 str = unicode # __IGNORE_WARNING__ __IGNORE_EXCEPTION__
17 except NameError:
18 pass
19
15 sys.path.insert(0, os.path.dirname(__file__)) 20 sys.path.insert(0, os.path.dirname(__file__))
16 if sys.version_info[0] >= 3:
17 # TODO: unify this
18 ## rope_path = os.path.join(os.path.dirname(__file__), 'rope_py3')
19 rope_path = os.path.join(os.path.dirname(__file__), 'rope_py2')
20 else:
21 rope_path = os.path.join(os.path.dirname(__file__), 'rope_py2')
22 str = unicode # __IGNORE_WARNING__
23 sys.path.insert(0, rope_path)
24 21
25 import rope 22 import rope
26 import rope.base.project 23 import rope.base.project
27 import rope.base.libutils 24 import rope.base.libutils
28 25
112 @param method requested method name 109 @param method requested method name
113 @type str 110 @type str
114 @param params dictionary with method specific parameters 111 @param params dictionary with method specific parameters
115 @type dict 112 @type dict
116 """ 113 """
117 ## if "filename" in params and sys.version_info[0] == 2:
118 ## params["filename"] = params["filename"].encode(
119 ## sys.getfilesystemencoding())
120
121 self.__methodMapping[method](params) 114 self.__methodMapping[method](params)
122 115
123 def __handleRopeError(self, err): 116 def __handleRopeError(self, err):
124 """ 117 """
125 Private method to process a rope error. 118 Private method to process a rope error.
127 @param err rope exception object 120 @param err rope exception object
128 @type Exception 121 @type Exception
129 @return dictionary containing the error information 122 @return dictionary containing the error information
130 @rtype dict 123 @rtype dict
131 """ 124 """
125 import traceback
126 tb = traceback.format_tb(sys.exc_info()[2])
132 ropeError = str(type(err)).split()[-1] 127 ropeError = str(type(err)).split()[-1]
133 ropeError = ropeError[1:-2].split('.')[-1] 128 ropeError = ropeError[1:-2].split('.')[-1]
134 errorDict = { 129 errorDict = {
135 "Error": ropeError, 130 "Error": ropeError,
136 "ErrorString": str(err), 131 "ErrorString": str(err),
132 "Traceback": tb,
137 } 133 }
138 if ropeError == 'ModuleSyntaxError': 134 if ropeError == 'ModuleSyntaxError':
139 errorDict["ErrorFile"] = err.filename 135 errorDict["ErrorFile"] = err.filename
140 errorDict["ErrorLine"] = err.lineno 136 errorDict["ErrorLine"] = err.lineno
141 137
183 """ 179 """
184 result = { 180 result = {
185 "RopeFolderName": self.__project.ropefolder.real_path, 181 "RopeFolderName": self.__project.ropefolder.real_path,
186 "DefaultConfig": self.__project._default_config(), 182 "DefaultConfig": self.__project._default_config(),
187 "RopeHelpFile": os.path.join( 183 "RopeHelpFile": os.path.join(
188 rope_path, "rope", "docs", "overview.rst"), 184 os.path.dirname(__file__), "rope", "docs", "overview.rst"),
189 "RopeInfo": rope.INFO, 185 "RopeInfo": rope.INFO,
190 "RopeVersion": rope.VERSION, 186 "RopeVersion": rope.VERSION,
191 "RopeCopyright": rope.COPYRIGHT, 187 "RopeCopyright": rope.COPYRIGHT,
192 "PythonVersion": "Python{0}".format(sys.version_info[0]), 188 "PythonVersion": "Python{0}".format(sys.version_info[0]),
193 } 189 }

eric ide

mercurial