MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _SixMetaPathImporter

Class _SixMetaPathImporter

thirdparty/six/__init__.py:169–240  ·  view source on GitHub ↗

A meta path importer to import six.moves and its submodules. This class implements a PEP302 finder and loader. It should be compatible with Python 2.5 and all existing versions of Python3

Source from the content-addressed store, hash-verified

167
168
169class _SixMetaPathImporter(object):
170
171 """
172 A meta path importer to import six.moves and its submodules.
173
174 This class implements a PEP302 finder and loader. It should be compatible
175 with Python 2.5 and all existing versions of Python3
176 """
177
178 def __init__(self, six_module_name):
179 self.name = six_module_name
180 self.known_modules = {}
181
182 def _add_module(self, mod, *fullnames):
183 for fullname in fullnames:
184 self.known_modules[self.name + "." + fullname] = mod
185
186 def _get_module(self, fullname):
187 return self.known_modules[self.name + "." + fullname]
188
189 def find_module(self, fullname, path=None):
190 if fullname in self.known_modules:
191 return self
192 return None
193
194 def find_spec(self, fullname, path, target=None):
195 if fullname in self.known_modules:
196 return spec_from_loader(fullname, self)
197 return None
198
199 def __get_module(self, fullname):
200 try:
201 return self.known_modules[fullname]
202 except KeyError:
203 raise ImportError("This loader does not know module " + fullname)
204
205 def load_module(self, fullname):
206 try:
207 # in case of a reload
208 return sys.modules[fullname]
209 except KeyError:
210 pass
211 mod = self.__get_module(fullname)
212 if isinstance(mod, MovedModule):
213 mod = mod._resolve()
214 else:
215 mod.__loader__ = self
216 sys.modules[fullname] = mod
217 return mod
218
219 def is_package(self, fullname):
220 """
221 Return true, if the named module is a package.
222
223 We need this method to get correct spec objects with
224 Python 3.4 (see PEP451)
225 """
226 return hasattr(self.__get_module(fullname), "__path__")

Callers 1

__init__.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…