224 |
224 |
225 if sourceType != UNKNOWN_SOURCE: |
225 if sourceType != UNKNOWN_SOURCE: |
226 for p in path: # search in path |
226 for p in path: # search in path |
227 pathname = os.path.join(p, name) |
227 pathname = os.path.join(p, name) |
228 if os.path.exists(pathname): |
228 if os.path.exists(pathname): |
229 return (open(pathname), pathname, (ext, "r", sourceType)) |
229 return (open(pathname), pathname, (ext, "r", sourceType)) # noqa: Y115 |
230 # __IGNORE_WARNING_Y115__ |
|
231 raise ImportError |
230 raise ImportError |
232 else: |
231 else: |
233 # standard Python module file |
232 # standard Python module file |
234 if name.lower().endswith(".py"): |
233 if name.lower().endswith(".py"): |
235 name = name[:-3] |
234 name = name[:-3] |
237 spec = importlib.machinery.PathFinder.find_spec(name, path) |
236 spec = importlib.machinery.PathFinder.find_spec(name, path) |
238 if spec is None: |
237 if spec is None: |
239 raise ImportError |
238 raise ImportError |
240 if isinstance(spec.loader, importlib.machinery.SourceFileLoader): |
239 if isinstance(spec.loader, importlib.machinery.SourceFileLoader): |
241 ext = os.path.splitext(spec.origin)[-1] |
240 ext = os.path.splitext(spec.origin)[-1] |
242 return (open(spec.origin), spec.origin, (ext, "r", PY_SOURCE)) |
241 return (open(spec.origin), spec.origin, (ext, "r", PY_SOURCE)) # noqa: Y115 |
243 # __IGNORE_WARNING_Y115__ |
|
244 |
242 |
245 raise ImportError |
243 raise ImportError |
246 |
244 |
247 |
245 |
248 def getIcon(filename): |
246 def getIcon(filename): |