Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
_wrap | (new, old) | Simple substitute for functools.update_wrapper. | Simple substitute for functools.update_wrapper. | def _wrap(new, old):
"""Simple substitute for functools.update_wrapper."""
for replace in ['__module__', '__name__', '__qualname__', '__doc__']:
if hasattr(old, replace):
setattr(new, replace, getattr(old, replace))
new.__dict__.update(old.__dict__) | [
"def",
"_wrap",
"(",
"new",
",",
"old",
")",
":",
"for",
"replace",
"in",
"[",
"'__module__'",
",",
"'__name__'",
",",
"'__qualname__'",
",",
"'__doc__'",
"]",
":",
"if",
"hasattr",
"(",
"old",
",",
"replace",
")",
":",
"setattr",
"(",
"new",
",",
"r... | [
26,
0
] | [
31,
37
] | python | en | ['en', 'en', 'en'] | True |
_get_module_lock | (name) | Get or create the module lock for a given module name.
Acquire/release internally the global import lock to protect
_module_locks. | Get or create the module lock for a given module name. | def _get_module_lock(name):
"""Get or create the module lock for a given module name.
Acquire/release internally the global import lock to protect
_module_locks."""
_imp.acquire_lock()
try:
try:
lock = _module_locks[name]()
except KeyError:
lock = None
... | [
"def",
"_get_module_lock",
"(",
"name",
")",
":",
"_imp",
".",
"acquire_lock",
"(",
")",
"try",
":",
"try",
":",
"lock",
"=",
"_module_locks",
"[",
"name",
"]",
"(",
")",
"except",
"KeyError",
":",
"lock",
"=",
"None",
"if",
"lock",
"is",
"None",
":"... | [
156,
0
] | [
190,
15
] | python | en | ['en', 'en', 'en'] | True |
_lock_unlock_module | (name) | Acquires then releases the module lock for a given module name.
This is used to ensure a module is completely initialized, in the
event it is being imported by another thread.
| Acquires then releases the module lock for a given module name. | def _lock_unlock_module(name):
"""Acquires then releases the module lock for a given module name.
This is used to ensure a module is completely initialized, in the
event it is being imported by another thread.
"""
lock = _get_module_lock(name)
try:
lock.acquire()
except _DeadlockErr... | [
"def",
"_lock_unlock_module",
"(",
"name",
")",
":",
"lock",
"=",
"_get_module_lock",
"(",
"name",
")",
"try",
":",
"lock",
".",
"acquire",
"(",
")",
"except",
"_DeadlockError",
":",
"# Concurrent circular import, we'll accept a partially initialized",
"# module object.... | [
193,
0
] | [
207,
22
] | python | en | ['en', 'en', 'en'] | True |
_call_with_frames_removed | (f, *args, **kwds) | remove_importlib_frames in import.c will always remove sequences
of importlib frames that end with a call to this function
Use it instead of a normal call in places where including the importlib
frames introduces unwanted noise into the traceback (e.g. when executing
module code)
| remove_importlib_frames in import.c will always remove sequences
of importlib frames that end with a call to this function | def _call_with_frames_removed(f, *args, **kwds):
"""remove_importlib_frames in import.c will always remove sequences
of importlib frames that end with a call to this function
Use it instead of a normal call in places where including the importlib
frames introduces unwanted noise into the traceback (e.g... | [
"def",
"_call_with_frames_removed",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwds",
")"
] | [
210,
0
] | [
218,
27
] | python | en | ['en', 'en', 'en'] | True |
_verbose_message | (message, *args, verbosity=1) | Print the message to stderr if -v/PYTHONVERBOSE is turned on. | Print the message to stderr if -v/PYTHONVERBOSE is turned on. | def _verbose_message(message, *args, verbosity=1):
"""Print the message to stderr if -v/PYTHONVERBOSE is turned on."""
if sys.flags.verbose >= verbosity:
if not message.startswith(('#', 'import ')):
message = '# ' + message
print(message.format(*args), file=sys.stderr) | [
"def",
"_verbose_message",
"(",
"message",
",",
"*",
"args",
",",
"verbosity",
"=",
"1",
")",
":",
"if",
"sys",
".",
"flags",
".",
"verbose",
">=",
"verbosity",
":",
"if",
"not",
"message",
".",
"startswith",
"(",
"(",
"'#'",
",",
"'import '",
")",
"... | [
221,
0
] | [
226,
53
] | python | en | ['en', 'en', 'en'] | True |
_requires_builtin | (fxn) | Decorator to verify the named module is built-in. | Decorator to verify the named module is built-in. | def _requires_builtin(fxn):
"""Decorator to verify the named module is built-in."""
def _requires_builtin_wrapper(self, fullname):
if fullname not in sys.builtin_module_names:
raise ImportError('{!r} is not a built-in module'.format(fullname),
name=fullname)
... | [
"def",
"_requires_builtin",
"(",
"fxn",
")",
":",
"def",
"_requires_builtin_wrapper",
"(",
"self",
",",
"fullname",
")",
":",
"if",
"fullname",
"not",
"in",
"sys",
".",
"builtin_module_names",
":",
"raise",
"ImportError",
"(",
"'{!r} is not a built-in module'",
".... | [
229,
0
] | [
237,
36
] | python | en | ['en', 'en', 'en'] | True |
_requires_frozen | (fxn) | Decorator to verify the named module is frozen. | Decorator to verify the named module is frozen. | def _requires_frozen(fxn):
"""Decorator to verify the named module is frozen."""
def _requires_frozen_wrapper(self, fullname):
if not _imp.is_frozen(fullname):
raise ImportError('{!r} is not a frozen module'.format(fullname),
name=fullname)
return fxn(se... | [
"def",
"_requires_frozen",
"(",
"fxn",
")",
":",
"def",
"_requires_frozen_wrapper",
"(",
"self",
",",
"fullname",
")",
":",
"if",
"not",
"_imp",
".",
"is_frozen",
"(",
"fullname",
")",
":",
"raise",
"ImportError",
"(",
"'{!r} is not a frozen module'",
".",
"fo... | [
240,
0
] | [
248,
35
] | python | en | ['en', 'en', 'en'] | True |
_load_module_shim | (self, fullname) | Load the specified module into sys.modules and return it.
This method is deprecated. Use loader.exec_module instead.
| Load the specified module into sys.modules and return it. | def _load_module_shim(self, fullname):
"""Load the specified module into sys.modules and return it.
This method is deprecated. Use loader.exec_module instead.
"""
spec = spec_from_loader(fullname, self)
if fullname in sys.modules:
module = sys.modules[fullname]
_exec(spec, module)... | [
"def",
"_load_module_shim",
"(",
"self",
",",
"fullname",
")",
":",
"spec",
"=",
"spec_from_loader",
"(",
"fullname",
",",
"self",
")",
"if",
"fullname",
"in",
"sys",
".",
"modules",
":",
"module",
"=",
"sys",
".",
"modules",
"[",
"fullname",
"]",
"_exec... | [
252,
0
] | [
264,
26
] | python | en | ['en', 'en', 'en'] | True |
spec_from_loader | (name, loader, *, origin=None, is_package=None) | Return a module spec based on various loader methods. | Return a module spec based on various loader methods. | def spec_from_loader(name, loader, *, origin=None, is_package=None):
"""Return a module spec based on various loader methods."""
if hasattr(loader, 'get_filename'):
if _bootstrap_external is None:
raise NotImplementedError
spec_from_file_location = _bootstrap_external.spec_from_file_... | [
"def",
"spec_from_loader",
"(",
"name",
",",
"loader",
",",
"*",
",",
"origin",
"=",
"None",
",",
"is_package",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"loader",
",",
"'get_filename'",
")",
":",
"if",
"_bootstrap_external",
"is",
"None",
":",
"raise... | [
432,
0
] | [
455,
73
] | python | en | ['en', 'da', 'en'] | True |
module_from_spec | (spec) | Create a module based on the provided spec. | Create a module based on the provided spec. | def module_from_spec(spec):
"""Create a module based on the provided spec."""
# Typically loaders will not implement create_module().
module = None
if hasattr(spec.loader, 'create_module'):
# If create_module() returns `None` then it means default
# module creation should be used.
... | [
"def",
"module_from_spec",
"(",
"spec",
")",
":",
"# Typically loaders will not implement create_module().",
"module",
"=",
"None",
"if",
"hasattr",
"(",
"spec",
".",
"loader",
",",
"'create_module'",
")",
":",
"# If create_module() returns `None` then it means default",
"#... | [
563,
0
] | [
577,
17
] | python | en | ['en', 'en', 'en'] | True |
_module_repr_from_spec | (spec) | Return the repr to use for the module. | Return the repr to use for the module. | def _module_repr_from_spec(spec):
"""Return the repr to use for the module."""
# We mostly replicate _module_repr() using the spec attributes.
name = '?' if spec.name is None else spec.name
if spec.origin is None:
if spec.loader is None:
return '<module {!r}>'.format(name)
el... | [
"def",
"_module_repr_from_spec",
"(",
"spec",
")",
":",
"# We mostly replicate _module_repr() using the spec attributes.",
"name",
"=",
"'?'",
"if",
"spec",
".",
"name",
"is",
"None",
"else",
"spec",
".",
"name",
"if",
"spec",
".",
"origin",
"is",
"None",
":",
"... | [
580,
0
] | [
593,
70
] | python | en | ['en', 'en', 'en'] | True |
_exec | (spec, module) | Execute the spec's specified module in an existing module's namespace. | Execute the spec's specified module in an existing module's namespace. | def _exec(spec, module):
"""Execute the spec's specified module in an existing module's namespace."""
name = spec.name
with _ModuleLockManager(name):
if sys.modules.get(name) is not module:
msg = 'module {!r} not in sys.modules'.format(name)
raise ImportError(msg, name=name)
... | [
"def",
"_exec",
"(",
"spec",
",",
"module",
")",
":",
"name",
"=",
"spec",
".",
"name",
"with",
"_ModuleLockManager",
"(",
"name",
")",
":",
"if",
"sys",
".",
"modules",
".",
"get",
"(",
"name",
")",
"is",
"not",
"module",
":",
"msg",
"=",
"'module... | [
597,
0
] | [
618,
28
] | python | en | ['en', 'en', 'en'] | True |
_load | (spec) | Return a new module object, loaded by the spec's loader.
The module is not added to its parent.
If a module is already in sys.modules, that existing module gets
clobbered.
| Return a new module object, loaded by the spec's loader. | def _load(spec):
"""Return a new module object, loaded by the spec's loader.
The module is not added to its parent.
If a module is already in sys.modules, that existing module gets
clobbered.
"""
with _ModuleLockManager(spec.name):
return _load_unlocked(spec) | [
"def",
"_load",
"(",
"spec",
")",
":",
"with",
"_ModuleLockManager",
"(",
"spec",
".",
"name",
")",
":",
"return",
"_load_unlocked",
"(",
"spec",
")"
] | [
673,
0
] | [
683,
35
] | python | en | ['en', 'en', 'en'] | True |
_resolve_name | (name, package, level) | Resolve a relative module name to an absolute one. | Resolve a relative module name to an absolute one. | def _resolve_name(name, package, level):
"""Resolve a relative module name to an absolute one."""
bits = package.rsplit('.', level - 1)
if len(bits) < level:
raise ValueError('attempted relative import beyond top-level package')
base = bits[0]
return '{}.{}'.format(base, name) if name else b... | [
"def",
"_resolve_name",
"(",
"name",
",",
"package",
",",
"level",
")",
":",
"bits",
"=",
"package",
".",
"rsplit",
"(",
"'.'",
",",
"level",
"-",
"1",
")",
"if",
"len",
"(",
"bits",
")",
"<",
"level",
":",
"raise",
"ValueError",
"(",
"'attempted rel... | [
851,
0
] | [
857,
55
] | python | en | ['en', 'en', 'en'] | True |
_find_spec | (name, path, target=None) | Find a module's spec. | Find a module's spec. | def _find_spec(name, path, target=None):
"""Find a module's spec."""
meta_path = sys.meta_path
if meta_path is None:
# PyImport_Cleanup() is running or has been called.
raise ImportError("sys.meta_path is None, Python is likely "
"shutting down")
if not meta_pa... | [
"def",
"_find_spec",
"(",
"name",
",",
"path",
",",
"target",
"=",
"None",
")",
":",
"meta_path",
"=",
"sys",
".",
"meta_path",
"if",
"meta_path",
"is",
"None",
":",
"# PyImport_Cleanup() is running or has been called.",
"raise",
"ImportError",
"(",
"\"sys.meta_pa... | [
869,
0
] | [
913,
19
] | python | en | ['en', 'co', 'en'] | True |
_sanity_check | (name, package, level) | Verify arguments are "sane". | Verify arguments are "sane". | def _sanity_check(name, package, level):
"""Verify arguments are "sane"."""
if not isinstance(name, str):
raise TypeError('module name must be str, not {}'.format(type(name)))
if level < 0:
raise ValueError('level must be >= 0')
if level > 0:
if not isinstance(package, str):
... | [
"def",
"_sanity_check",
"(",
"name",
",",
"package",
",",
"level",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"'module name must be str, not {}'",
".",
"format",
"(",
"type",
"(",
"name",
")",
")",
... | [
916,
0
] | [
929,
45
] | python | en | ['en', 'fr', 'en'] | True |
_find_and_load | (name, import_) | Find and load the module. | Find and load the module. | def _find_and_load(name, import_):
"""Find and load the module."""
with _ModuleLockManager(name):
module = sys.modules.get(name, _NEEDS_LOADING)
if module is _NEEDS_LOADING:
return _find_and_load_unlocked(name, import_)
if module is None:
message = ('import of {} halted;... | [
"def",
"_find_and_load",
"(",
"name",
",",
"import_",
")",
":",
"with",
"_ModuleLockManager",
"(",
"name",
")",
":",
"module",
"=",
"sys",
".",
"modules",
".",
"get",
"(",
"name",
",",
"_NEEDS_LOADING",
")",
"if",
"module",
"is",
"_NEEDS_LOADING",
":",
"... | [
965,
0
] | [
978,
17
] | python | en | ['en', 'en', 'en'] | True |
_gcd_import | (name, package=None, level=0) | Import and return the module based on its name, the package the call is
being made from, and the level adjustment.
This function represents the greatest common denominator of functionality
between import_module and __import__. This includes setting __package__ if
the loader did not.
| Import and return the module based on its name, the package the call is
being made from, and the level adjustment. | def _gcd_import(name, package=None, level=0):
"""Import and return the module based on its name, the package the call is
being made from, and the level adjustment.
This function represents the greatest common denominator of functionality
between import_module and __import__. This includes setting __pac... | [
"def",
"_gcd_import",
"(",
"name",
",",
"package",
"=",
"None",
",",
"level",
"=",
"0",
")",
":",
"_sanity_check",
"(",
"name",
",",
"package",
",",
"level",
")",
"if",
"level",
">",
"0",
":",
"name",
"=",
"_resolve_name",
"(",
"name",
",",
"package"... | [
981,
0
] | [
993,
44
] | python | en | ['en', 'en', 'en'] | True |
_handle_fromlist | (module, fromlist, import_, *, recursive=False) | Figure out what __import__ should return.
The import_ parameter is a callable which takes the name of module to
import. It is required to decouple the function from assuming importlib's
import implementation is desired.
| Figure out what __import__ should return. | def _handle_fromlist(module, fromlist, import_, *, recursive=False):
"""Figure out what __import__ should return.
The import_ parameter is a callable which takes the name of module to
import. It is required to decouple the function from assuming importlib's
import implementation is desired.
"""
... | [
"def",
"_handle_fromlist",
"(",
"module",
",",
"fromlist",
",",
"import_",
",",
"*",
",",
"recursive",
"=",
"False",
")",
":",
"# The hell that is fromlist ...",
"# If a package was imported, try to import stuff from fromlist.",
"if",
"hasattr",
"(",
"module",
",",
"'__... | [
996,
0
] | [
1031,
17
] | python | en | ['en', 'en', 'en'] | True |
_calc___package__ | (globals) | Calculate what __package__ should be.
__package__ is not guaranteed to be defined or could be set to None
to represent that its proper value is unknown.
| Calculate what __package__ should be. | def _calc___package__(globals):
"""Calculate what __package__ should be.
__package__ is not guaranteed to be defined or could be set to None
to represent that its proper value is unknown.
"""
package = globals.get('__package__')
spec = globals.get('__spec__')
if package is not None:
... | [
"def",
"_calc___package__",
"(",
"globals",
")",
":",
"package",
"=",
"globals",
".",
"get",
"(",
"'__package__'",
")",
"spec",
"=",
"globals",
".",
"get",
"(",
"'__spec__'",
")",
"if",
"package",
"is",
"not",
"None",
":",
"if",
"spec",
"is",
"not",
"N... | [
1034,
0
] | [
1058,
18
] | python | en | ['en', 'en', 'en'] | True |
__import__ | (name, globals=None, locals=None, fromlist=(), level=0) | Import a module.
The 'globals' argument is used to infer where the import is occurring from
to handle relative imports. The 'locals' argument is ignored. The
'fromlist' argument specifies what should exist as attributes on the module
being imported (e.g. ``from module import <fromlist>``). The 'level'... | Import a module. | def __import__(name, globals=None, locals=None, fromlist=(), level=0):
"""Import a module.
The 'globals' argument is used to infer where the import is occurring from
to handle relative imports. The 'locals' argument is ignored. The
'fromlist' argument specifies what should exist as attributes on the mo... | [
"def",
"__import__",
"(",
"name",
",",
"globals",
"=",
"None",
",",
"locals",
"=",
"None",
",",
"fromlist",
"=",
"(",
")",
",",
"level",
"=",
"0",
")",
":",
"if",
"level",
"==",
"0",
":",
"module",
"=",
"_gcd_import",
"(",
"name",
")",
"else",
":... | [
1061,
0
] | [
1093,
62
] | python | en | ['en', 'ro', 'en'] | True |
_setup | (sys_module, _imp_module) | Setup importlib by importing needed built-in modules and injecting them
into the global namespace.
As sys is needed for sys.modules access and _imp is needed to load built-in
modules, those two modules must be explicitly passed in.
| Setup importlib by importing needed built-in modules and injecting them
into the global namespace. | def _setup(sys_module, _imp_module):
"""Setup importlib by importing needed built-in modules and injecting them
into the global namespace.
As sys is needed for sys.modules access and _imp is needed to load built-in
modules, those two modules must be explicitly passed in.
"""
global _imp, sys
... | [
"def",
"_setup",
"(",
"sys_module",
",",
"_imp_module",
")",
":",
"global",
"_imp",
",",
"sys",
"_imp",
"=",
"_imp_module",
"sys",
"=",
"sys_module",
"# Set up the spec for existing builtin/frozen modules.",
"module_type",
"=",
"type",
"(",
"sys",
")",
"for",
"nam... | [
1103,
0
] | [
1147,
52
] | python | en | ['en', 'en', 'en'] | True |
_install | (sys_module, _imp_module) | Install importlib as the implementation of import. | Install importlib as the implementation of import. | def _install(sys_module, _imp_module):
"""Install importlib as the implementation of import."""
_setup(sys_module, _imp_module)
sys.meta_path.append(BuiltinImporter)
sys.meta_path.append(FrozenImporter)
global _bootstrap_external
import _frozen_importlib_external
_bootstrap_external = _fro... | [
"def",
"_install",
"(",
"sys_module",
",",
"_imp_module",
")",
":",
"_setup",
"(",
"sys_module",
",",
"_imp_module",
")",
"sys",
".",
"meta_path",
".",
"append",
"(",
"BuiltinImporter",
")",
"sys",
".",
"meta_path",
".",
"append",
"(",
"FrozenImporter",
")",... | [
1150,
0
] | [
1160,
62
] | python | en | ['en', 'en', 'en'] | True |
_ModuleLock.acquire | (self) |
Acquire the module lock. If a potential deadlock is detected,
a _DeadlockError is raised.
Otherwise, the lock is always acquired and True is returned.
|
Acquire the module lock. If a potential deadlock is detected,
a _DeadlockError is raised.
Otherwise, the lock is always acquired and True is returned.
| def acquire(self):
"""
Acquire the module lock. If a potential deadlock is detected,
a _DeadlockError is raised.
Otherwise, the lock is always acquired and True is returned.
"""
tid = _thread.get_ident()
_blocking_on[tid] = self
try:
while Tru... | [
"def",
"acquire",
"(",
"self",
")",
":",
"tid",
"=",
"_thread",
".",
"get_ident",
"(",
")",
"_blocking_on",
"[",
"tid",
"]",
"=",
"self",
"try",
":",
"while",
"True",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"count",
"==",
"0",
"... | [
77,
4
] | [
100,
33
] | python | en | ['en', 'error', 'th'] | False |
ModuleSpec.parent | (self) | The name of the module's parent. | The name of the module's parent. | def parent(self):
"""The name of the module's parent."""
if self.submodule_search_locations is None:
return self.name.rpartition('.')[0]
else:
return self.name | [
"def",
"parent",
"(",
"self",
")",
":",
"if",
"self",
".",
"submodule_search_locations",
"is",
"None",
":",
"return",
"self",
".",
"name",
".",
"rpartition",
"(",
"'.'",
")",
"[",
"0",
"]",
"else",
":",
"return",
"self",
".",
"name"
] | [
416,
4
] | [
421,
28
] | python | en | ['en', 'en', 'en'] | True |
BuiltinImporter.module_repr | (module) | Return repr for the module.
The method is deprecated. The import machinery does the job itself.
| Return repr for the module. | def module_repr(module):
"""Return repr for the module.
The method is deprecated. The import machinery does the job itself.
"""
return '<module {!r} (built-in)>'.format(module.__name__) | [
"def",
"module_repr",
"(",
"module",
")",
":",
"return",
"'<module {!r} (built-in)>'",
".",
"format",
"(",
"module",
".",
"__name__",
")"
] | [
698,
4
] | [
704,
65
] | python | en | ['en', 'it', 'en'] | True |
BuiltinImporter.find_module | (cls, fullname, path=None) | Find the built-in module.
If 'path' is ever specified then the search is considered a failure.
This method is deprecated. Use find_spec() instead.
| Find the built-in module. | def find_module(cls, fullname, path=None):
"""Find the built-in module.
If 'path' is ever specified then the search is considered a failure.
This method is deprecated. Use find_spec() instead.
"""
spec = cls.find_spec(fullname, path)
return spec.loader if spec is not ... | [
"def",
"find_module",
"(",
"cls",
",",
"fullname",
",",
"path",
"=",
"None",
")",
":",
"spec",
"=",
"cls",
".",
"find_spec",
"(",
"fullname",
",",
"path",
")",
"return",
"spec",
".",
"loader",
"if",
"spec",
"is",
"not",
"None",
"else",
"None"
] | [
716,
4
] | [
725,
56
] | python | en | ['en', 'en', 'en'] | True |
BuiltinImporter.create_module | (self, spec) | Create a built-in module | Create a built-in module | def create_module(self, spec):
"""Create a built-in module"""
if spec.name not in sys.builtin_module_names:
raise ImportError('{!r} is not a built-in module'.format(spec.name),
name=spec.name)
return _call_with_frames_removed(_imp.create_builtin, spec) | [
"def",
"create_module",
"(",
"self",
",",
"spec",
")",
":",
"if",
"spec",
".",
"name",
"not",
"in",
"sys",
".",
"builtin_module_names",
":",
"raise",
"ImportError",
"(",
"'{!r} is not a built-in module'",
".",
"format",
"(",
"spec",
".",
"name",
")",
",",
... | [
728,
4
] | [
733,
67
] | python | en | ['en', 'co', 'en'] | True |
BuiltinImporter.exec_module | (self, module) | Exec a built-in module | Exec a built-in module | def exec_module(self, module):
"""Exec a built-in module"""
_call_with_frames_removed(_imp.exec_builtin, module) | [
"def",
"exec_module",
"(",
"self",
",",
"module",
")",
":",
"_call_with_frames_removed",
"(",
"_imp",
".",
"exec_builtin",
",",
"module",
")"
] | [
736,
4
] | [
738,
60
] | python | en | ['en', 'nl', 'en'] | True |
BuiltinImporter.get_code | (cls, fullname) | Return None as built-in modules do not have code objects. | Return None as built-in modules do not have code objects. | def get_code(cls, fullname):
"""Return None as built-in modules do not have code objects."""
return None | [
"def",
"get_code",
"(",
"cls",
",",
"fullname",
")",
":",
"return",
"None"
] | [
742,
4
] | [
744,
19
] | python | en | ['en', 'en', 'en'] | True |
BuiltinImporter.get_source | (cls, fullname) | Return None as built-in modules do not have source code. | Return None as built-in modules do not have source code. | def get_source(cls, fullname):
"""Return None as built-in modules do not have source code."""
return None | [
"def",
"get_source",
"(",
"cls",
",",
"fullname",
")",
":",
"return",
"None"
] | [
748,
4
] | [
750,
19
] | python | en | ['en', 'en', 'en'] | True |
BuiltinImporter.is_package | (cls, fullname) | Return False as built-in modules are never packages. | Return False as built-in modules are never packages. | def is_package(cls, fullname):
"""Return False as built-in modules are never packages."""
return False | [
"def",
"is_package",
"(",
"cls",
",",
"fullname",
")",
":",
"return",
"False"
] | [
754,
4
] | [
756,
20
] | python | en | ['en', 'en', 'en'] | True |
FrozenImporter.module_repr | (m) | Return repr for the module.
The method is deprecated. The import machinery does the job itself.
| Return repr for the module. | def module_repr(m):
"""Return repr for the module.
The method is deprecated. The import machinery does the job itself.
"""
return '<module {!r} (frozen)>'.format(m.__name__) | [
"def",
"module_repr",
"(",
"m",
")",
":",
"return",
"'<module {!r} (frozen)>'",
".",
"format",
"(",
"m",
".",
"__name__",
")"
] | [
771,
4
] | [
777,
58
] | python | en | ['en', 'it', 'en'] | True |
FrozenImporter.find_module | (cls, fullname, path=None) | Find a frozen module.
This method is deprecated. Use find_spec() instead.
| Find a frozen module. | def find_module(cls, fullname, path=None):
"""Find a frozen module.
This method is deprecated. Use find_spec() instead.
"""
return cls if _imp.is_frozen(fullname) else None | [
"def",
"find_module",
"(",
"cls",
",",
"fullname",
",",
"path",
"=",
"None",
")",
":",
"return",
"cls",
"if",
"_imp",
".",
"is_frozen",
"(",
"fullname",
")",
"else",
"None"
] | [
787,
4
] | [
793,
56
] | python | en | ['en', 'fy', 'en'] | True |
FrozenImporter.create_module | (cls, spec) | Use default semantics for module creation. | Use default semantics for module creation. | def create_module(cls, spec):
"""Use default semantics for module creation.""" | [
"def",
"create_module",
"(",
"cls",
",",
"spec",
")",
":"
] | [
796,
4
] | [
797,
56
] | python | fr | ['fr', 'fr', 'en'] | True |
FrozenImporter.load_module | (cls, fullname) | Load a frozen module.
This method is deprecated. Use exec_module() instead.
| Load a frozen module. | def load_module(cls, fullname):
"""Load a frozen module.
This method is deprecated. Use exec_module() instead.
"""
return _load_module_shim(cls, fullname) | [
"def",
"load_module",
"(",
"cls",
",",
"fullname",
")",
":",
"return",
"_load_module_shim",
"(",
"cls",
",",
"fullname",
")"
] | [
809,
4
] | [
815,
47
] | python | en | ['en', 'fy', 'en'] | True |
FrozenImporter.get_code | (cls, fullname) | Return the code object for the frozen module. | Return the code object for the frozen module. | def get_code(cls, fullname):
"""Return the code object for the frozen module."""
return _imp.get_frozen_object(fullname) | [
"def",
"get_code",
"(",
"cls",
",",
"fullname",
")",
":",
"return",
"_imp",
".",
"get_frozen_object",
"(",
"fullname",
")"
] | [
819,
4
] | [
821,
47
] | python | en | ['en', 'en', 'en'] | True |
FrozenImporter.get_source | (cls, fullname) | Return None as frozen modules do not have source code. | Return None as frozen modules do not have source code. | def get_source(cls, fullname):
"""Return None as frozen modules do not have source code."""
return None | [
"def",
"get_source",
"(",
"cls",
",",
"fullname",
")",
":",
"return",
"None"
] | [
825,
4
] | [
827,
19
] | python | en | ['en', 'en', 'en'] | True |
FrozenImporter.is_package | (cls, fullname) | Return True if the frozen module is a package. | Return True if the frozen module is a package. | def is_package(cls, fullname):
"""Return True if the frozen module is a package."""
return _imp.is_frozen_package(fullname) | [
"def",
"is_package",
"(",
"cls",
",",
"fullname",
")",
":",
"return",
"_imp",
".",
"is_frozen_package",
"(",
"fullname",
")"
] | [
831,
4
] | [
833,
47
] | python | en | ['en', 'fy', 'en'] | True |
_ImportLockContext.__enter__ | (self) | Acquire the import lock. | Acquire the import lock. | def __enter__(self):
"""Acquire the import lock."""
_imp.acquire_lock() | [
"def",
"__enter__",
"(",
"self",
")",
":",
"_imp",
".",
"acquire_lock",
"(",
")"
] | [
842,
4
] | [
844,
27
] | python | en | ['en', 'la', 'en'] | True |
_ImportLockContext.__exit__ | (self, exc_type, exc_value, exc_traceback) | Release the import lock regardless of any raised exceptions. | Release the import lock regardless of any raised exceptions. | def __exit__(self, exc_type, exc_value, exc_traceback):
"""Release the import lock regardless of any raised exceptions."""
_imp.release_lock() | [
"def",
"__exit__",
"(",
"self",
",",
"exc_type",
",",
"exc_value",
",",
"exc_traceback",
")",
":",
"_imp",
".",
"release_lock",
"(",
")"
] | [
846,
4
] | [
848,
27
] | python | en | ['en', 'en', 'en'] | True |
importETree | () | Import the best implementation of ElementTree, return a module object. | Import the best implementation of ElementTree, return a module object. | def importETree():
"""Import the best implementation of ElementTree, return a module object."""
etree_in_c = None
try: # Is it Python 2.5+ with C implemenation of ElementTree installed?
import xml.etree.cElementTree as etree_in_c
except ImportError:
try: # Is it Python 2.5+ with Python i... | [
"def",
"importETree",
"(",
")",
":",
"etree_in_c",
"=",
"None",
"try",
":",
"# Is it Python 2.5+ with C implemenation of ElementTree installed?",
"import",
"xml",
".",
"etree",
".",
"cElementTree",
"as",
"etree_in_c",
"except",
"ImportError",
":",
"try",
":",
"# Is it... | [
5,
0
] | [
31,
20
] | python | en | ['en', 'fy', 'en'] | True |
create_requirements_index_file | (venv_path: str, requirements_file: str) |
Creates a file, called package_index, in the virtual environment
directory that contains all the PIP packages installed in the
virtual environment. This file is used to determine the packages
that can be copied to a new virtual environment.
|
Creates a file, called package_index, in the virtual environment
directory that contains all the PIP packages installed in the
virtual environment. This file is used to determine the packages
that can be copied to a new virtual environment.
| def create_requirements_index_file(venv_path: str, requirements_file: str) -> str:
"""
Creates a file, called package_index, in the virtual environment
directory that contains all the PIP packages installed in the
virtual environment. This file is used to determine the packages
that can be copied to... | [
"def",
"create_requirements_index_file",
"(",
"venv_path",
":",
"str",
",",
"requirements_file",
":",
"str",
")",
"->",
"str",
":",
"index_filename",
"=",
"get_index_filename",
"(",
"venv_path",
")",
"packages",
"=",
"get_package_names",
"(",
"requirements_file",
")... | [
126,
0
] | [
139,
25
] | python | en | ['en', 'error', 'th'] | False |
get_venv_packages | (venv_path: str) |
Returns the packages installed in the virtual environment using the
package index file.
|
Returns the packages installed in the virtual environment using the
package index file.
| def get_venv_packages(venv_path: str) -> Set[str]:
"""
Returns the packages installed in the virtual environment using the
package index file.
"""
with open(get_index_filename(venv_path)) as reader:
return {p.strip() for p in reader.read().split("\n") if p.strip()} | [
"def",
"get_venv_packages",
"(",
"venv_path",
":",
"str",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"with",
"open",
"(",
"get_index_filename",
"(",
"venv_path",
")",
")",
"as",
"reader",
":",
"return",
"{",
"p",
".",
"strip",
"(",
")",
"for",
"p",
"in"... | [
142,
0
] | [
148,
74
] | python | en | ['en', 'error', 'th'] | False |
try_to_copy_venv | (venv_path: str, new_packages: Set[str]) |
Tries to copy packages from an old virtual environment in the cache
to the new virtual environment. The algorithm works as follows:
1. Find a virtual environment, v, from the cache that has the
highest overlap with the new requirements such that:
a. The new requirements only add to ... |
Tries to copy packages from an old virtual environment in the cache
to the new virtual environment. The algorithm works as follows:
1. Find a virtual environment, v, from the cache that has the
highest overlap with the new requirements such that:
a. The new requirements only add to ... | def try_to_copy_venv(venv_path: str, new_packages: Set[str]) -> bool:
"""
Tries to copy packages from an old virtual environment in the cache
to the new virtual environment. The algorithm works as follows:
1. Find a virtual environment, v, from the cache that has the
highest overlap with the... | [
"def",
"try_to_copy_venv",
"(",
"venv_path",
":",
"str",
",",
"new_packages",
":",
"Set",
"[",
"str",
"]",
")",
"->",
"bool",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"VENV_CACHE_PATH",
")",
":",
"return",
"False",
"desired_python_version",... | [
151,
0
] | [
232,
16
] | python | en | ['en', 'error', 'th'] | False |
do_patch_activate_script | (venv_path: str) |
Patches the bin/activate script so that the value of the environment variable VIRTUAL_ENV
is set to venv_path during the script's execution whenever it is sourced.
|
Patches the bin/activate script so that the value of the environment variable VIRTUAL_ENV
is set to venv_path during the script's execution whenever it is sourced.
| def do_patch_activate_script(venv_path: str) -> None:
"""
Patches the bin/activate script so that the value of the environment variable VIRTUAL_ENV
is set to venv_path during the script's execution whenever it is sourced.
"""
# venv_path should be what we want to have in VIRTUAL_ENV after patching
... | [
"def",
"do_patch_activate_script",
"(",
"venv_path",
":",
"str",
")",
"->",
"None",
":",
"# venv_path should be what we want to have in VIRTUAL_ENV after patching",
"script_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"venv_path",
",",
"\"bin\"",
",",
"\"activate\""... | [
264,
0
] | [
279,
31
] | python | en | ['en', 'error', 'th'] | False |
image_get | (request, image_id) | Returns an Image object populated with metadata for a given image. | Returns an Image object populated with metadata for a given image. | def image_get(request, image_id):
"""Returns an Image object populated with metadata for a given image."""
image = glanceclient(request).images.get(image_id)
return Image(image) | [
"def",
"image_get",
"(",
"request",
",",
"image_id",
")",
":",
"image",
"=",
"glanceclient",
"(",
"request",
")",
".",
"images",
".",
"get",
"(",
"image_id",
")",
"return",
"Image",
"(",
"image",
")"
] | [
271,
0
] | [
274,
23
] | python | en | ['en', 'en', 'en'] | True |
image_list_detailed | (request, marker=None, sort_dir='desc',
sort_key='created_at', filters=None, paginate=False,
reversed_order=False, **kwargs) | Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward on top of ascetic
OpenStack pagination API - which natively supports only iterating forward
through the entries. Thus in order to retrieve list of objects at previous
page, a request with the ... | Thin layer above glanceclient, for handling pagination issues. | def image_list_detailed(request, marker=None, sort_dir='desc',
sort_key='created_at', filters=None, paginate=False,
reversed_order=False, **kwargs):
"""Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward ... | [
"def",
"image_list_detailed",
"(",
"request",
",",
"marker",
"=",
"None",
",",
"sort_dir",
"=",
"'desc'",
",",
"sort_key",
"=",
"'created_at'",
",",
"filters",
"=",
"None",
",",
"paginate",
"=",
"False",
",",
"reversed_order",
"=",
"False",
",",
"*",
"*",
... | [
291,
0
] | [
394,
55
] | python | en | ['en', 'en', 'en'] | True |
create_image_metadata | (data) | Generate metadata dict for a new image from a given form data. | Generate metadata dict for a new image from a given form data. | def create_image_metadata(data):
"""Generate metadata dict for a new image from a given form data."""
# Default metadata
meta = {'protected': data.get('protected', False),
'disk_format': data.get('disk_format', 'raw'),
'container_format': data.get('container_format', 'bare'),
... | [
"def",
"create_image_metadata",
"(",
"data",
")",
":",
"# Default metadata",
"meta",
"=",
"{",
"'protected'",
":",
"data",
".",
"get",
"(",
"'protected'",
",",
"False",
")",
",",
"'disk_format'",
":",
"data",
".",
"get",
"(",
"'disk_format'",
",",
"'raw'",
... | [
459,
0
] | [
518,
15
] | python | en | ['en', 'en', 'en'] | True |
image_create | (request, **kwargs) | Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image already resides.
In the case of 'copy_from... | Create image. | def image_create(request, **kwargs):
"""Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image alr... | [
"def",
"image_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"pop",
"(",
"'data'",
",",
"None",
")",
"location",
"=",
"None",
"if",
"VERSIONS",
".",
"active",
">=",
"2",
":",
"location",
"=",
"kwargs",
".",
... | [
533,
0
] | [
593,
23
] | python | en | ['en', 'et', 'en'] | False |
image_update_properties | (request, image_id, remove_props=None, **kwargs) | Add or update a custom property of an image. | Add or update a custom property of an image. | def image_update_properties(request, image_id, remove_props=None, **kwargs):
"""Add or update a custom property of an image."""
return glanceclient(request, '2').images.update(image_id,
remove_props,
**kwargs... | [
"def",
"image_update_properties",
"(",
"request",
",",
"image_id",
",",
"remove_props",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"glanceclient",
"(",
"request",
",",
"'2'",
")",
".",
"images",
".",
"update",
"(",
"image_id",
",",
"remove_p... | [
597,
0
] | [
601,
61
] | python | en | ['en', 'en', 'en'] | True |
image_delete_properties | (request, image_id, keys) | Delete custom properties for an image. | Delete custom properties for an image. | def image_delete_properties(request, image_id, keys):
"""Delete custom properties for an image."""
return glanceclient(request, '2').images.update(image_id, keys) | [
"def",
"image_delete_properties",
"(",
"request",
",",
"image_id",
",",
"keys",
")",
":",
"return",
"glanceclient",
"(",
"request",
",",
"'2'",
")",
".",
"images",
".",
"update",
"(",
"image_id",
",",
"keys",
")"
] | [
605,
0
] | [
607,
67
] | python | en | ['en', 'en', 'en'] | True |
filter_properties_target | (namespaces_iter,
resource_types,
properties_target) | Filter metadata namespaces.
Filtering is done based ongiven resource types and a properties target.
:param namespaces_iter: Metadata namespaces iterable.
:param resource_types: List of resource type names.
:param properties_target: Name of the properties target.
| Filter metadata namespaces. | def filter_properties_target(namespaces_iter,
resource_types,
properties_target):
"""Filter metadata namespaces.
Filtering is done based ongiven resource types and a properties target.
:param namespaces_iter: Metadata namespaces iterable.
:para... | [
"def",
"filter_properties_target",
"(",
"namespaces_iter",
",",
"resource_types",
",",
"properties_target",
")",
":",
"def",
"filter_namespace",
"(",
"namespace",
")",
":",
"for",
"asn",
"in",
"namespace",
".",
"get",
"(",
"'resource_type_associations'",
")",
":",
... | [
646,
0
] | [
663,
52
] | python | en | ['en', 'la', 'en'] | True |
metadefs_namespace_list | (request,
filters=None,
sort_dir='asc',
sort_key='namespace',
marker=None,
paginate=False) | Retrieve a listing of Namespaces
:param paginate: If true will perform pagination based on settings.
:param marker: Specifies the namespace of the last-seen namespace.
The typical pattern of limit and marker is to make an
initial limited request and then to use the last
n... | Retrieve a listing of Namespaces | def metadefs_namespace_list(request,
filters=None,
sort_dir='asc',
sort_key='namespace',
marker=None,
paginate=False):
"""Retrieve a listing of Namespaces
:param paginate:... | [
"def",
"metadefs_namespace_list",
"(",
"request",
",",
"filters",
"=",
"None",
",",
"sort_dir",
"=",
"'asc'",
",",
"sort_key",
"=",
"'namespace'",
",",
"marker",
"=",
"None",
",",
"paginate",
"=",
"False",
")",
":",
"# Listing namespaces requires the v2 API. If no... | [
680,
0
] | [
763,
51
] | python | en | ['en', 'pt', 'en'] | True |
_default_key_normalizer | (key_class, request_context) |
Create a pool key out of a request context dictionary.
According to RFC 3986, both the scheme and host are case-insensitive.
Therefore, this function normalizes both before constructing the pool
key for an HTTPS request. If you wish to change this behaviour, provide
alternate callables to ``key_fn... |
Create a pool key out of a request context dictionary. | def _default_key_normalizer(key_class, request_context):
"""
Create a pool key out of a request context dictionary.
According to RFC 3986, both the scheme and host are case-insensitive.
Therefore, this function normalizes both before constructing the pool
key for an HTTPS request. If you wish to ch... | [
"def",
"_default_key_normalizer",
"(",
"key_class",
",",
"request_context",
")",
":",
"# Since we mutate the dictionary, make a copy first",
"context",
"=",
"request_context",
".",
"copy",
"(",
")",
"context",
"[",
"\"scheme\"",
"]",
"=",
"context",
"[",
"\"scheme\"",
... | [
73,
0
] | [
119,
31
] | python | en | ['en', 'error', 'th'] | False |
PoolManager._new_pool | (self, scheme, host, port, request_context=None) |
Create a new :class:`ConnectionPool` based on host, port, scheme, and
any additional pool keyword arguments.
If ``request_context`` is provided, it is provided as keyword arguments
to the pool class used. This method is used to actually create the
connection pools handed out by... |
Create a new :class:`ConnectionPool` based on host, port, scheme, and
any additional pool keyword arguments. | def _new_pool(self, scheme, host, port, request_context=None):
"""
Create a new :class:`ConnectionPool` based on host, port, scheme, and
any additional pool keyword arguments.
If ``request_context`` is provided, it is provided as keyword arguments
to the pool class used. This me... | [
"def",
"_new_pool",
"(",
"self",
",",
"scheme",
",",
"host",
",",
"port",
",",
"request_context",
"=",
"None",
")",
":",
"pool_cls",
"=",
"self",
".",
"pool_classes_by_scheme",
"[",
"scheme",
"]",
"if",
"request_context",
"is",
"None",
":",
"request_context"... | [
182,
4
] | [
207,
54
] | python | en | ['en', 'error', 'th'] | False |
PoolManager.clear | (self) |
Empty our store of pools and direct them all to close.
This will not affect in-flight connections, but they will not be
re-used after completion.
|
Empty our store of pools and direct them all to close. | def clear(self):
"""
Empty our store of pools and direct them all to close.
This will not affect in-flight connections, but they will not be
re-used after completion.
"""
self.pools.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"pools",
".",
"clear",
"(",
")"
] | [
209,
4
] | [
216,
26
] | python | en | ['en', 'error', 'th'] | False |
PoolManager.connection_from_host | (self, host, port=None, scheme="http", pool_kwargs=None) |
Get a :class:`ConnectionPool` based on the host, port, and scheme.
If ``port`` isn't given, it will be derived from the ``scheme`` using
``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is
provided, it is merged with the instance's ``connection_pool_kw``
variable a... |
Get a :class:`ConnectionPool` based on the host, port, and scheme. | def connection_from_host(self, host, port=None, scheme="http", pool_kwargs=None):
"""
Get a :class:`ConnectionPool` based on the host, port, and scheme.
If ``port`` isn't given, it will be derived from the ``scheme`` using
``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is... | [
"def",
"connection_from_host",
"(",
"self",
",",
"host",
",",
"port",
"=",
"None",
",",
"scheme",
"=",
"\"http\"",
",",
"pool_kwargs",
"=",
"None",
")",
":",
"if",
"not",
"host",
":",
"raise",
"LocationValueError",
"(",
"\"No host specified.\"",
")",
"reques... | [
218,
4
] | [
239,
60
] | python | en | ['en', 'error', 'th'] | False |
PoolManager.connection_from_context | (self, request_context) |
Get a :class:`ConnectionPool` based on the request context.
``request_context`` must at least contain the ``scheme`` key and its
value must be a key in ``key_fn_by_scheme`` instance variable.
|
Get a :class:`ConnectionPool` based on the request context. | def connection_from_context(self, request_context):
"""
Get a :class:`ConnectionPool` based on the request context.
``request_context`` must at least contain the ``scheme`` key and its
value must be a key in ``key_fn_by_scheme`` instance variable.
"""
scheme = request_co... | [
"def",
"connection_from_context",
"(",
"self",
",",
"request_context",
")",
":",
"scheme",
"=",
"request_context",
"[",
"\"scheme\"",
"]",
".",
"lower",
"(",
")",
"pool_key_constructor",
"=",
"self",
".",
"key_fn_by_scheme",
"[",
"scheme",
"]",
"pool_key",
"=",
... | [
241,
4
] | [
252,
87
] | python | en | ['en', 'error', 'th'] | False |
PoolManager.connection_from_pool_key | (self, pool_key, request_context=None) |
Get a :class:`ConnectionPool` based on the provided pool key.
``pool_key`` should be a namedtuple that only contains immutable
objects. At a minimum it must have the ``scheme``, ``host``, and
``port`` fields.
|
Get a :class:`ConnectionPool` based on the provided pool key. | def connection_from_pool_key(self, pool_key, request_context=None):
"""
Get a :class:`ConnectionPool` based on the provided pool key.
``pool_key`` should be a namedtuple that only contains immutable
objects. At a minimum it must have the ``scheme``, ``host``, and
``port`` fields... | [
"def",
"connection_from_pool_key",
"(",
"self",
",",
"pool_key",
",",
"request_context",
"=",
"None",
")",
":",
"with",
"self",
".",
"pools",
".",
"lock",
":",
"# If the scheme, host, or port doesn't match existing open",
"# connections, open a new ConnectionPool.",
"pool",... | [
254,
4
] | [
276,
19
] | python | en | ['en', 'error', 'th'] | False |
PoolManager.connection_from_url | (self, url, pool_kwargs=None) |
Similar to :func:`urllib3.connectionpool.connection_from_url`.
If ``pool_kwargs`` is not provided and a new pool needs to be
constructed, ``self.connection_pool_kw`` is used to initialize
the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs``
is provided, it is ... |
Similar to :func:`urllib3.connectionpool.connection_from_url`. | def connection_from_url(self, url, pool_kwargs=None):
"""
Similar to :func:`urllib3.connectionpool.connection_from_url`.
If ``pool_kwargs`` is not provided and a new pool needs to be
constructed, ``self.connection_pool_kw`` is used to initialize
the :class:`urllib3.connectionpoo... | [
"def",
"connection_from_url",
"(",
"self",
",",
"url",
",",
"pool_kwargs",
"=",
"None",
")",
":",
"u",
"=",
"parse_url",
"(",
"url",
")",
"return",
"self",
".",
"connection_from_host",
"(",
"u",
".",
"host",
",",
"port",
"=",
"u",
".",
"port",
",",
"... | [
278,
4
] | [
292,
9
] | python | en | ['en', 'error', 'th'] | False |
PoolManager._merge_pool_kwargs | (self, override) |
Merge a dictionary of override values for self.connection_pool_kw.
This does not modify self.connection_pool_kw and returns a new dict.
Any keys in the override dictionary with a value of ``None`` are
removed from the merged dictionary.
|
Merge a dictionary of override values for self.connection_pool_kw. | def _merge_pool_kwargs(self, override):
"""
Merge a dictionary of override values for self.connection_pool_kw.
This does not modify self.connection_pool_kw and returns a new dict.
Any keys in the override dictionary with a value of ``None`` are
removed from the merged dictionary... | [
"def",
"_merge_pool_kwargs",
"(",
"self",
",",
"override",
")",
":",
"base_pool_kwargs",
"=",
"self",
".",
"connection_pool_kw",
".",
"copy",
"(",
")",
"if",
"override",
":",
"for",
"key",
",",
"value",
"in",
"override",
".",
"items",
"(",
")",
":",
"if"... | [
294,
4
] | [
312,
31
] | python | en | ['en', 'error', 'th'] | False |
PoolManager.urlopen | (self, method, url, redirect=True, **kw) |
Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`
with custom cross-host redirect logic and only sends the request-uri
portion of the ``url``.
The given ``url`` parameter must be absolute, such that an appropriate
:class:`urllib3.connectionpool.ConnectionPool` c... |
Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`
with custom cross-host redirect logic and only sends the request-uri
portion of the ``url``. | def urlopen(self, method, url, redirect=True, **kw):
"""
Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`
with custom cross-host redirect logic and only sends the request-uri
portion of the ``url``.
The given ``url`` parameter must be absolute, such that an appr... | [
"def",
"urlopen",
"(",
"self",
",",
"method",
",",
"url",
",",
"redirect",
"=",
"True",
",",
"*",
"*",
"kw",
")",
":",
"u",
"=",
"parse_url",
"(",
"url",
")",
"conn",
"=",
"self",
".",
"connection_from_host",
"(",
"u",
".",
"host",
",",
"port",
"... | [
314,
4
] | [
377,
60
] | python | en | ['en', 'error', 'th'] | False |
ProxyManager._set_proxy_headers | (self, url, headers=None) |
Sets headers needed by proxies: specifically, the Accept and Host
headers. Only sets headers not provided by the user.
|
Sets headers needed by proxies: specifically, the Accept and Host
headers. Only sets headers not provided by the user.
| def _set_proxy_headers(self, url, headers=None):
"""
Sets headers needed by proxies: specifically, the Accept and Host
headers. Only sets headers not provided by the user.
"""
headers_ = {"Accept": "*/*"}
netloc = parse_url(url).netloc
if netloc:
head... | [
"def",
"_set_proxy_headers",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
")",
":",
"headers_",
"=",
"{",
"\"Accept\"",
":",
"\"*/*\"",
"}",
"netloc",
"=",
"parse_url",
"(",
"url",
")",
".",
"netloc",
"if",
"netloc",
":",
"headers_",
"[",
"\"H... | [
448,
4
] | [
461,
23
] | python | en | ['en', 'error', 'th'] | False |
ProxyManager.urlopen | (self, method, url, redirect=True, **kw) | Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute. | Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute. | def urlopen(self, method, url, redirect=True, **kw):
"Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute."
u = parse_url(url)
self._validate_proxy_scheme_url_selection(u.scheme)
if u.scheme == "http":
# For proxied HTTPS requests, httplib sets the necessary head... | [
"def",
"urlopen",
"(",
"self",
",",
"method",
",",
"url",
",",
"redirect",
"=",
"True",
",",
"*",
"*",
"kw",
")",
":",
"u",
"=",
"parse_url",
"(",
"url",
")",
"self",
".",
"_validate_proxy_scheme_url_selection",
"(",
"u",
".",
"scheme",
")",
"if",
"u... | [
475,
4
] | [
487,
86
] | python | en | ['en', 'en', 'nl'] | True |
test_wrapped_model_regression | (test_model, seed) | Testing if Regression Wrapper properly remaps properties and functions to those of the provided regressor. | Testing if Regression Wrapper properly remaps properties and functions to those of the provided regressor. | def test_wrapped_model_regression(test_model, seed):
"""Testing if Regression Wrapper properly remaps properties and functions to those of the provided regressor."""
wrapped = WrappedModelRegression(
regressor=test_model,
transformer=QuantileTransformer(output_distribution="normal", random_state... | [
"def",
"test_wrapped_model_regression",
"(",
"test_model",
",",
"seed",
")",
":",
"wrapped",
"=",
"WrappedModelRegression",
"(",
"regressor",
"=",
"test_model",
",",
"transformer",
"=",
"QuantileTransformer",
"(",
"output_distribution",
"=",
"\"normal\"",
",",
"random... | [
23,
0
] | [
35,
50
] | python | en | ['en', 'en', 'en'] | True |
test_wrapped_model_regression_params | (test_model, seed) | Testing if Regression Wrapper properly remaps get_params() function to that of the regressor. | Testing if Regression Wrapper properly remaps get_params() function to that of the regressor. | def test_wrapped_model_regression_params(test_model, seed):
"""Testing if Regression Wrapper properly remaps get_params() function to that of the regressor."""
wrapped = WrappedModelRegression(
regressor=test_model,
transformer=QuantileTransformer(output_distribution="normal", random_state=seed)... | [
"def",
"test_wrapped_model_regression_params",
"(",
"test_model",
",",
"seed",
")",
":",
"wrapped",
"=",
"WrappedModelRegression",
"(",
"regressor",
"=",
"test_model",
",",
"transformer",
"=",
"QuantileTransformer",
"(",
"output_distribution",
"=",
"\"normal\"",
",",
... | [
47,
0
] | [
53,
58
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_init | (data_classification_balanced, split_dataset_classification, seed, category_type) | Testing if initialization of ModelFinder's properties works correctly depending on the category_type. | Testing if initialization of ModelFinder's properties works correctly depending on the category_type. | def test_model_finder_init(data_classification_balanced, split_dataset_classification, seed, category_type):
"""Testing if initialization of ModelFinder's properties works correctly depending on the category_type."""
if category_type == "categorical":
expected_problem = ModelFinder._classification
... | [
"def",
"test_model_finder_init",
"(",
"data_classification_balanced",
",",
"split_dataset_classification",
",",
"seed",
",",
"category_type",
")",
":",
"if",
"category_type",
"==",
"\"categorical\"",
":",
"expected_problem",
"=",
"ModelFinder",
".",
"_classification",
"ex... | [
63,
0
] | [
91,
57
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_init_improper_problem_type | (
data_classification_balanced, split_dataset_classification, seed, category_type
) | Testing if error is raised when incorrect category_type is provided to ModelFinder. | Testing if error is raised when incorrect category_type is provided to ModelFinder. | def test_model_finder_init_improper_problem_type(
data_classification_balanced, split_dataset_classification, seed, category_type
):
"""Testing if error is raised when incorrect category_type is provided to ModelFinder."""
X = data_classification_balanced[0]
y = data_classification_balanced[1]
e... | [
"def",
"test_model_finder_init_improper_problem_type",
"(",
"data_classification_balanced",
",",
"split_dataset_classification",
",",
"seed",
",",
"category_type",
")",
":",
"X",
"=",
"data_classification_balanced",
"[",
"0",
"]",
"y",
"=",
"data_classification_balanced",
"... | [
104,
0
] | [
119,
40
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_search_incorrect_mode | (model_finder_classification, mode) | Testing if search() function raises an error when incorrect mode is provided. | Testing if search() function raises an error when incorrect mode is provided. | def test_model_finder_search_incorrect_mode(model_finder_classification, mode):
"""Testing if search() function raises an error when incorrect mode is provided."""
categories = ", ".join(model_finder_classification._modes)
with pytest.raises(ValueError) as excinfo:
model_finder_classification.search... | [
"def",
"test_model_finder_search_incorrect_mode",
"(",
"model_finder_classification",
",",
"mode",
")",
":",
"categories",
"=",
"\", \"",
".",
"join",
"(",
"model_finder_classification",
".",
"_modes",
")",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
"a... | [
132,
0
] | [
137,
43
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_search_incorrect_model | (model_finder_classification, incorrect_model) | Testing if search() function raises an error when incorrect type of models is provided. | Testing if search() function raises an error when incorrect type of models is provided. | def test_model_finder_search_incorrect_model(model_finder_classification, incorrect_model):
"""Testing if search() function raises an error when incorrect type of models is provided."""
mode = model_finder_classification._mode_quick
with pytest.raises(ValueError) as excinfo:
model_finder_classificat... | [
"def",
"test_model_finder_search_incorrect_model",
"(",
"model_finder_classification",
",",
"incorrect_model",
")",
":",
"mode",
"=",
"model_finder_classification",
".",
"_mode_quick",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
"as",
"excinfo",
":",
"model... | [
149,
0
] | [
154,
75
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_fit | (model_finder_classification, seed) | Testing if fit() function properly fits the model. | Testing if fit() function properly fits the model. | def test_model_finder_fit(model_finder_classification, seed):
"""Testing if fit() function properly fits the model."""
mf = model_finder_classification
mf.set_model(LogisticRegression())
mf.fit()
try:
mf.predict(mf.X.toarray())
except NotFittedError:
pytest.fail() | [
"def",
"test_model_finder_fit",
"(",
"model_finder_classification",
",",
"seed",
")",
":",
"mf",
"=",
"model_finder_classification",
"mf",
".",
"set_model",
"(",
"LogisticRegression",
"(",
")",
")",
"mf",
".",
"fit",
"(",
")",
"try",
":",
"mf",
".",
"predict",... | [
157,
0
] | [
165,
21
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_fit_no_model | (model_finder_classification) | Testing if fit() function raises an error when there is no Model set. | Testing if fit() function raises an error when there is no Model set. | def test_model_finder_fit_no_model(model_finder_classification):
"""Testing if fit() function raises an error when there is no Model set."""
with pytest.raises(ModelNotSetError):
model_finder_classification.fit() | [
"def",
"test_model_finder_fit_no_model",
"(",
"model_finder_classification",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ModelNotSetError",
")",
":",
"model_finder_classification",
".",
"fit",
"(",
")"
] | [
168,
0
] | [
171,
41
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_predict | (model_finder_classification, seed) | Testing if predict() function correctly predicts the output. | Testing if predict() function correctly predicts the output. | def test_model_finder_predict(model_finder_classification, seed):
"""Testing if predict() function correctly predicts the output."""
expected_result = [1, ]
test = np.array([1.34, -0.25, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0]).reshape(1, -1)
mf = model_finder_classificatio... | [
"def",
"test_model_finder_predict",
"(",
"model_finder_classification",
",",
"seed",
")",
":",
"expected_result",
"=",
"[",
"1",
",",
"]",
"test",
"=",
"np",
".",
"array",
"(",
"[",
"1.34",
",",
"-",
"0.25",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",... | [
174,
0
] | [
184,
43
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_predict_no_model | (model_finder_classification) | Testing if predict() function raises an error when no Model is set. | Testing if predict() function raises an error when no Model is set. | def test_model_finder_predict_no_model(model_finder_classification):
"""Testing if predict() function raises an error when no Model is set."""
with pytest.raises(ModelNotSetError):
model_finder_classification.predict(["test_input"]) | [
"def",
"test_model_finder_predict_no_model",
"(",
"model_finder_classification",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ModelNotSetError",
")",
":",
"model_finder_classification",
".",
"predict",
"(",
"[",
"\"test_input\"",
"]",
")"
] | [
187,
0
] | [
190,
59
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_gridsearch_not_fitted_warning | (model_finder_classification, incorrect_grid) | Testing if warning is raised when NotFittedError happens in gridsearch. | Testing if warning is raised when NotFittedError happens in gridsearch. | def test_model_finder_gridsearch_not_fitted_warning(model_finder_classification, incorrect_grid):
"""Testing if warning is raised when NotFittedError happens in gridsearch."""
model = list(incorrect_grid.keys())[0]
params = list(incorrect_grid.values())[0]
expected_params = {"{}: {}".format(key, item) f... | [
"def",
"test_model_finder_gridsearch_not_fitted_warning",
"(",
"model_finder_classification",
",",
"incorrect_grid",
")",
":",
"model",
"=",
"list",
"(",
"incorrect_grid",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"params",
"=",
"list",
"(",
"incorrect_grid",
"."... | [
200,
0
] | [
212,
61
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_create_gridsearch_results_dataframe | (model_finder_classification, input_dict, expected_result) | Testing if creating gridsearch results dataframe works correctly. | Testing if creating gridsearch results dataframe works correctly. | def test_model_finder_create_gridsearch_results_dataframe(model_finder_classification, input_dict, expected_result):
"""Testing if creating gridsearch results dataframe works correctly."""
expected_result = expected_result.rename({"model": model_finder_classification._model_name})
actual_result = model_find... | [
"def",
"test_model_finder_create_gridsearch_results_dataframe",
"(",
"model_finder_classification",
",",
"input_dict",
",",
"expected_result",
")",
":",
"expected_result",
"=",
"expected_result",
".",
"rename",
"(",
"{",
"\"model\"",
":",
"model_finder_classification",
".",
... | [
250,
0
] | [
255,
71
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_create_search_results_dataframe | (
model_finder_classification, input_dict, scoring, expected_result
) | Testing if creating search results dataframe works correctly. | Testing if creating search results dataframe works correctly. | def test_model_finder_create_search_results_dataframe(
model_finder_classification, input_dict, scoring, expected_result
):
"""Testing if creating search results dataframe works correctly."""
actual_result = model_finder_classification._create_search_results_dataframe(input_dict, scoring)
assert act... | [
"def",
"test_model_finder_create_search_results_dataframe",
"(",
"model_finder_classification",
",",
"input_dict",
",",
"scoring",
",",
"expected_result",
")",
":",
"actual_result",
"=",
"model_finder_classification",
".",
"_create_search_results_dataframe",
"(",
"input_dict",
... | [
297,
0
] | [
302,
71
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_get_scorings | (model_finder_classification, scoring, expected_result) | Testing if appending the scoring to default scoring_functions works properly. | Testing if appending the scoring to default scoring_functions works properly. | def test_model_finder_get_scorings(model_finder_classification, scoring, expected_result):
"""Testing if appending the scoring to default scoring_functions works properly."""
model_finder_classification.scoring_functions = [r2_score, accuracy_score]
actual_result = model_finder_classification._get_scorings(... | [
"def",
"test_model_finder_get_scorings",
"(",
"model_finder_classification",
",",
"scoring",
",",
"expected_result",
")",
":",
"model_finder_classification",
".",
"scoring_functions",
"=",
"[",
"r2_score",
",",
"accuracy_score",
"]",
"actual_result",
"=",
"model_finder_clas... | [
314,
0
] | [
319,
43
] | python | en | ['en', 'en', 'en'] | True |
test_model_finder_score_model | (model_finder_classification, model, expected_results) | Testing if score_model() function properly scores different Models. | Testing if score_model() function properly scores different Models. | def test_model_finder_score_model(model_finder_classification, model, expected_results):
"""Testing if score_model() function properly scores different Models."""
X_train, y_train = model_finder_classification.X_train, model_finder_classification.y_train
model.fit(X_train, y_train)
model_finder_classifi... | [
"def",
"test_model_finder_score_model",
"(",
"model_finder_classification",
",",
"model",
",",
"expected_results",
")",
":",
"X_train",
",",
"y_train",
"=",
"model_finder_classification",
".",
"X_train",
",",
"model_finder_classification",
".",
"y_train",
"model",
".",
... | [
333,
0
] | [
340,
45
] | python | en | ['ca', 'en', 'en'] | True |
test_model_finder_test_target_proportion | (model_finder_classification_fitted) | Testing if proportion of 1s in target (y_test) is calculated correctly (in classification). | Testing if proportion of 1s in target (y_test) is calculated correctly (in classification). | def test_model_finder_test_target_proportion(model_finder_classification_fitted):
"""Testing if proportion of 1s in target (y_test) is calculated correctly (in classification)."""
assert model_finder_classification_fitted.test_target_proportion() == 0.6 | [
"def",
"test_model_finder_test_target_proportion",
"(",
"model_finder_classification_fitted",
")",
":",
"assert",
"model_finder_classification_fitted",
".",
"test_target_proportion",
"(",
")",
"==",
"0.6"
] | [
343,
0
] | [
345,
77
] | python | en | ['en', 'en', 'en'] | True |
parse_distutils_args | (args) | Parse provided arguments, returning an object that has the
matched arguments.
Any unknown arguments are ignored.
| Parse provided arguments, returning an object that has the
matched arguments. | def parse_distutils_args(args):
# type: (List[str]) -> Dict[str, str]
"""Parse provided arguments, returning an object that has the
matched arguments.
Any unknown arguments are ignored.
"""
result = {}
for arg in args:
try:
_, match = _distutils_getopt.getopt(args=[arg])... | [
"def",
"parse_distutils_args",
"(",
"args",
")",
":",
"# type: (List[str]) -> Dict[str, str]",
"result",
"=",
"{",
"}",
"for",
"arg",
"in",
"args",
":",
"try",
":",
"_",
",",
"match",
"=",
"_distutils_getopt",
".",
"getopt",
"(",
"args",
"=",
"[",
"arg",
"... | [
29,
0
] | [
47,
17
] | python | en | ['en', 'en', 'en'] | True |
get_current_request | () | Returns the current HttpRequest object; this should only be used by
logging frameworks, which have no other access to the current
request. All other codepaths should pass through the current
request object, rather than rely on this thread-local global.
| Returns the current HttpRequest object; this should only be used by
logging frameworks, which have no other access to the current
request. All other codepaths should pass through the current
request object, rather than rely on this thread-local global. | def get_current_request() -> Optional[HttpRequest]:
"""Returns the current HttpRequest object; this should only be used by
logging frameworks, which have no other access to the current
request. All other codepaths should pass through the current
request object, rather than rely on this thread-local glo... | [
"def",
"get_current_request",
"(",
")",
"->",
"Optional",
"[",
"HttpRequest",
"]",
":",
"return",
"getattr",
"(",
"local",
",",
"\"request\"",
",",
"None",
")"
] | [
397,
0
] | [
404,
42
] | python | en | ['en', 'en', 'en'] | True |
_REQ.__init__ | (
self,
whence: Optional[str] = None,
*,
converter: Optional[Callable[[str], ResultT]] = None,
default: Union[_NotSpecified, ResultT, None] = NotSpecified,
json_validator: Optional[Validator[ResultT]] = None,
str_validator: Optional[Validator[ResultT]] = None,
... | whence: the name of the request variable that should be used
for this parameter. Defaults to a request variable of the
same name as the parameter.
converter: a function that takes a string and returns a new
value. If specified, this will be called on the request
variable value... | whence: the name of the request variable that should be used
for this parameter. Defaults to a request variable of the
same name as the parameter. | def __init__(
self,
whence: Optional[str] = None,
*,
converter: Optional[Callable[[str], ResultT]] = None,
default: Union[_NotSpecified, ResultT, None] = NotSpecified,
json_validator: Optional[Validator[ResultT]] = None,
str_validator: Optional[Validator[ResultT]]... | [
"def",
"__init__",
"(",
"self",
",",
"whence",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"*",
",",
"converter",
":",
"Optional",
"[",
"Callable",
"[",
"[",
"str",
"]",
",",
"ResultT",
"]",
"]",
"=",
"None",
",",
"default",
":",
"Union",
... | [
79,
4
] | [
138,
68
] | python | en | ['en', 'en', 'en'] | True |
RunnableObject._prepare_result_class | (self) |
Возвращает класс результата работы ранера
|
Возвращает класс результата работы ранера
| def _prepare_result_class(self) -> Type[BaseRunnableResult]:
"""
Возвращает класс результата работы ранера
"""
return BaseRunnableResult | [
"def",
"_prepare_result_class",
"(",
"self",
")",
"->",
"Type",
"[",
"BaseRunnableResult",
"]",
":",
"return",
"BaseRunnableResult"
] | [
45,
4
] | [
49,
33
] | python | en | ['en', 'error', 'th'] | False |
RunnableObject._prepare_result | (self, *args, **kwargs) |
Метод подготовки результата
|
Метод подготовки результата
| def _prepare_result(self, *args, **kwargs):
"""
Метод подготовки результата
"""
result_class = self._prepare_result_class()
if issubclass(result_class, BaseRunnableResult):
result = result_class(*args, **kwargs)
else:
result = BaseRunnableResult(*... | [
"def",
"_prepare_result",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result_class",
"=",
"self",
".",
"_prepare_result_class",
"(",
")",
"if",
"issubclass",
"(",
"result_class",
",",
"BaseRunnableResult",
")",
":",
"result",
"=",
"r... | [
55,
4
] | [
66,
21
] | python | en | ['en', 'error', 'th'] | False |
RunnableObject.run | (self, *args, **kwargs) |
Метод запуска выполняемого объекта
|
Метод запуска выполняемого объекта
| def run(self, *args, **kwargs):
"""
Метод запуска выполняемого объекта
""" | [
"def",
"run",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":"
] | [
69,
4
] | [
72,
11
] | python | en | ['en', 'error', 'th'] | False |
LazySavingRunnableObject.do_on_save | (self, object_) |
Метод добавления объекта в очередь на сохранение
|
Метод добавления объекта в очередь на сохранение
| def do_on_save(self, object_):
"""
Метод добавления объекта в очередь на сохранение
"""
self._queue_to_save.append(object_) | [
"def",
"do_on_save",
"(",
"self",
",",
"object_",
")",
":",
"self",
".",
"_queue_to_save",
".",
"append",
"(",
"object_",
")"
] | [
101,
4
] | [
105,
43
] | python | en | ['en', 'error', 'th'] | False |
LazySavingRunnableObject._do_save_objects_queue | (self) |
Выполенение сохранения объектов из очереди
|
Выполенение сохранения объектов из очереди
| def _do_save_objects_queue(self):
"""
Выполенение сохранения объектов из очереди
""" | [
"def",
"_do_save_objects_queue",
"(",
"self",
")",
":"
] | [
108,
4
] | [
111,
11
] | python | en | ['en', 'error', 'th'] | False |
LazySavingRunnableObject.do_save | (self) |
Выполнение действий сохранения объектов из очереди в транзакции
|
Выполнение действий сохранения объектов из очереди в транзакции
| def do_save(self):
"""
Выполнение действий сохранения объектов из очереди в транзакции
"""
with transaction.atomic(savepoint=False):
self._do_save_objects_queue() | [
"def",
"do_save",
"(",
"self",
")",
":",
"with",
"transaction",
".",
"atomic",
"(",
"savepoint",
"=",
"False",
")",
":",
"self",
".",
"_do_save_objects_queue",
"(",
")"
] | [
113,
4
] | [
118,
41
] | python | en | ['en', 'error', 'th'] | False |
LazySavingActionModelRunnableObject._do_save_objects_queue | (self) |
Выполенение сохранения объектов из очереди
|
Выполенение сохранения объектов из очереди
| def _do_save_objects_queue(self):
"""
Выполенение сохранения объектов из очереди
"""
while self._queue_to_save:
x = self._queue_to_save.popleft()
if callable(x):
x()
else:
if isinstance(x, Model):
re... | [
"def",
"_do_save_objects_queue",
"(",
"self",
")",
":",
"while",
"self",
".",
"_queue_to_save",
":",
"x",
"=",
"self",
".",
"_queue_to_save",
".",
"popleft",
"(",
")",
"if",
"callable",
"(",
"x",
")",
":",
"x",
"(",
")",
"else",
":",
"if",
"isinstance"... | [
129,
4
] | [
141,
28
] | python | en | ['en', 'error', 'th'] | False |
update_realmauditlog_values | (apps: StateApps, schema_editor: DatabaseSchemaEditor) |
This migration fixes two issues with the RealmAuditLog format for certain event types:
* The notifications_stream and signup_notifications_stream fields had the
Stream objects passed into `ujson.dumps()` and thus marshalled as a giant
JSON object, when the intent was to store the stream ID.
* T... |
This migration fixes two issues with the RealmAuditLog format for certain event types:
* The notifications_stream and signup_notifications_stream fields had the
Stream objects passed into `ujson.dumps()` and thus marshalled as a giant
JSON object, when the intent was to store the stream ID.
* T... | def update_realmauditlog_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
"""
This migration fixes two issues with the RealmAuditLog format for certain event types:
* The notifications_stream and signup_notifications_stream fields had the
Stream objects passed into `ujson.dumps()`... | [
"def",
"update_realmauditlog_values",
"(",
"apps",
":",
"StateApps",
",",
"schema_editor",
":",
"DatabaseSchemaEditor",
")",
"->",
"None",
":",
"RealmAuditLog",
"=",
"apps",
".",
"get_model",
"(",
"\"zerver\"",
",",
"\"RealmAuditLog\"",
")",
"# Constants from models.p... | [
9,
0
] | [
105,
45
] | python | en | ['en', 'error', 'th'] | False |
load | (f, _dict=dict, decoder=None) | Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
decoder: The decoder to use
Returns:
Pars... | Parses named file or files as toml and returns a dictionary | def load(f, _dict=dict, decoder=None):
"""Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
decoder:... | [
"def",
"load",
"(",
"f",
",",
"_dict",
"=",
"dict",
",",
"decoder",
"=",
"None",
")",
":",
"if",
"_ispath",
"(",
"f",
")",
":",
"with",
"io",
".",
"open",
"(",
"_getpath",
"(",
"f",
")",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"ffile",
":",... | [
112,
0
] | [
158,
35
] | python | en | ['en', 'en', 'en'] | True |
loads | (s, _dict=dict, decoder=None) | Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
TomlDecodeError: Error while decoding toml
... | Parses string as toml | def loads(s, _dict=dict, decoder=None):
"""Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
... | [
"def",
"loads",
"(",
"s",
",",
"_dict",
"=",
"dict",
",",
"decoder",
"=",
"None",
")",
":",
"implicitgroups",
"=",
"[",
"]",
"if",
"decoder",
"is",
"None",
":",
"decoder",
"=",
"TomlDecoder",
"(",
"_dict",
")",
"retval",
"=",
"decoder",
".",
"get_emp... | [
164,
0
] | [
515,
17
] | python | en | ['en', 'en', 'en'] | True |
_unescape | (v) | Unescape characters in a TOML string. | Unescape characters in a TOML string. | def _unescape(v):
"""Unescape characters in a TOML string."""
i = 0
backslash = False
while i < len(v):
if backslash:
backslash = False
if v[i] in _escapes:
v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:]
elif v[i] == '\\':
... | [
"def",
"_unescape",
"(",
"v",
")",
":",
"i",
"=",
"0",
"backslash",
"=",
"False",
"while",
"i",
"<",
"len",
"(",
"v",
")",
":",
"if",
"backslash",
":",
"backslash",
"=",
"False",
"if",
"v",
"[",
"i",
"]",
"in",
"_escapes",
":",
"v",
"=",
"v",
... | [
607,
0
] | [
626,
12
] | python | en | ['en', 'en', 'en'] | True |
_normalize_name | (name) | Make a name consistent regardless of source (environment or file)
| Make a name consistent regardless of source (environment or file)
| def _normalize_name(name):
# type: (str) -> str
"""Make a name consistent regardless of source (environment or file)
"""
name = name.lower().replace('_', '-')
if name.startswith('--'):
name = name[2:] # only prefer long opts
return name | [
"def",
"_normalize_name",
"(",
"name",
")",
":",
"# type: (str) -> str",
"name",
"=",
"name",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")",
"if",
"name",
".",
"startswith",
"(",
"'--'",
")",
":",
"name",
"=",
"name",
"[",
"2",
... | [
41,
0
] | [
48,
15
] | python | en | ['en', 'en', 'en'] | True |
Configuration.load | (self) | Loads configuration from configuration files and environment
| Loads configuration from configuration files and environment
| def load(self):
# type: () -> None
"""Loads configuration from configuration files and environment
"""
self._load_config_files()
if not self.isolated:
self._load_environment_vars() | [
"def",
"load",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"_load_config_files",
"(",
")",
"if",
"not",
"self",
".",
"isolated",
":",
"self",
".",
"_load_environment_vars",
"(",
")"
] | [
142,
4
] | [
148,
41
] | python | en | ['en', 'en', 'en'] | True |
Configuration.get_file_to_edit | (self) | Returns the file with highest priority in configuration
| Returns the file with highest priority in configuration
| def get_file_to_edit(self):
# type: () -> Optional[str]
"""Returns the file with highest priority in configuration
"""
assert self.load_only is not None, \
"Need to be specified a file to be editing"
try:
return self._get_parser_to_modify()[0]
exc... | [
"def",
"get_file_to_edit",
"(",
"self",
")",
":",
"# type: () -> Optional[str]",
"assert",
"self",
".",
"load_only",
"is",
"not",
"None",
",",
"\"Need to be specified a file to be editing\"",
"try",
":",
"return",
"self",
".",
"_get_parser_to_modify",
"(",
")",
"[",
... | [
150,
4
] | [
160,
23
] | python | en | ['en', 'en', 'en'] | True |
Configuration.items | (self) | Returns key-value pairs like dict.items() representing the loaded
configuration
| Returns key-value pairs like dict.items() representing the loaded
configuration
| def items(self):
# type: () -> Iterable[Tuple[str, Any]]
"""Returns key-value pairs like dict.items() representing the loaded
configuration
"""
return self._dictionary.items() | [
"def",
"items",
"(",
"self",
")",
":",
"# type: () -> Iterable[Tuple[str, Any]]",
"return",
"self",
".",
"_dictionary",
".",
"items",
"(",
")"
] | [
162,
4
] | [
167,
39
] | python | en | ['en', 'en', 'en'] | True |
Configuration.get_value | (self, key) | Get a value from the configuration.
| Get a value from the configuration.
| def get_value(self, key):
# type: (str) -> Any
"""Get a value from the configuration.
"""
try:
return self._dictionary[key]
except KeyError:
raise ConfigurationError("No such key - {}".format(key)) | [
"def",
"get_value",
"(",
"self",
",",
"key",
")",
":",
"# type: (str) -> Any",
"try",
":",
"return",
"self",
".",
"_dictionary",
"[",
"key",
"]",
"except",
"KeyError",
":",
"raise",
"ConfigurationError",
"(",
"\"No such key - {}\"",
".",
"format",
"(",
"key",
... | [
169,
4
] | [
176,
68
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.