src/eric7/Utilities/ClassBrowsers/rbclbr.py

branch
server
changeset 10592
2bada76be1a6
parent 10439
21c28b0f9e41
child 10596
ea35c92a3c7c
equal deleted inserted replaced
10591:9acd8da2b378 10592:2bada76be1a6
15 import re 15 import re
16 16
17 from PyQt6.QtCore import QRegularExpression 17 from PyQt6.QtCore import QRegularExpression
18 18
19 from eric7 import Utilities 19 from eric7 import Utilities
20 from eric7.EricWidgets.EricApplication import ericApp
21 from eric7.SystemUtilities import FileSystemUtilities
20 from eric7.Utilities import ClassBrowsers 22 from eric7.Utilities import ClassBrowsers
21 23
22 from . import ClbrBaseClasses 24 from . import ClbrBaseClasses
23 25
24 SUPPORTED_TYPES = [ClassBrowsers.RB_SOURCE] 26 SUPPORTED_TYPES = [ClassBrowsers.RB_SOURCE]
275 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno) 277 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno)
276 VisibilityMixin.__init__(self) 278 VisibilityMixin.__init__(self)
277 self.setPrivate() 279 self.setPrivate()
278 280
279 281
280 def readmodule_ex(module, path=None, isTypeFile=False): # noqa: U100 282 def readmodule_ex(module, searchPath=None, isTypeFile=False): # noqa: U100
281 """ 283 """
282 Read a Ruby file and return a dictionary of classes, functions and modules. 284 Read a Ruby file and return a dictionary of classes, functions and modules.
283 285
284 @param module name of the Ruby file 286 @param module name of the Ruby file
285 @type str 287 @type str
286 @param path path the file should be searched in 288 @param searchPath path the file should be searched in
287 @type list of str 289 @type list of str
288 @param isTypeFile flag indicating a file of this type 290 @param isTypeFile flag indicating a file of this type
289 @type bool 291 @type bool
290 @return the resulting dictionary 292 @return the resulting dictionary
291 @rtype dict 293 @rtype dict
292 """ 294 """
293 # search the path for the file 295 fsInterface = ericApp().getObject("EricServer").getServiceInterface("FileSystem")
294 f = None 296
295 fullpath = [] if path is None else path[:] 297 if searchPath and FileSystemUtilities.isRemoteFileName(searchPath[0]):
296 f, file, (suff, mode, type) = ClassBrowsers.find_module(module, fullpath) 298 type = ClassBrowsers.determineSourceType(module)
297 if f: 299 file = fsInterface.join(searchPath[0], module)
298 f.close() 300 else:
301 # search the path for the module
302 fullpath = [] if searchPath is None else searchPath[:]
303 f, file, (suff, mode, type) = ClassBrowsers.find_module(module, fullpath)
304 if f:
305 f.close()
306
299 if type not in SUPPORTED_TYPES: 307 if type not in SUPPORTED_TYPES:
300 # not Ruby source, can't do anything with this module 308 # not Ruby source, can't do anything with this module
301 return {} 309 return {}
302 310
303 try: 311 try:
304 src = Utilities.readEncodedFile(file)[0] 312 if FileSystemUtilities.isRemoteFileName(file):
313 src = fsInterface.readEncodedFile(file)[0]
314 else:
315 src = Utilities.readEncodedFile(file)[0]
305 except (OSError, UnicodeError): 316 except (OSError, UnicodeError):
306 # can't do anything with this module 317 # can't do anything with this module
307 return {} 318 return {}
308 319
309 return scan(src, file, module) 320 return scan(src, file, module)

eric ide

mercurial