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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
build_ext.check_extensions_list | (self, extensions) | Ensure that the list of extensions (presumably provided as a
command option 'extensions') is valid, i.e. it is a list of
Extension objects. We also support the old-style list of 2-tuples,
where the tuples are (ext_name, build_info), which are converted to
Extension instances here.
... | Ensure that the list of extensions (presumably provided as a
command option 'extensions') is valid, i.e. it is a list of
Extension objects. We also support the old-style list of 2-tuples,
where the tuples are (ext_name, build_info), which are converted to
Extension instances here. | def check_extensions_list(self, extensions):
"""Ensure that the list of extensions (presumably provided as a
command option 'extensions') is valid, i.e. it is a list of
Extension objects. We also support the old-style list of 2-tuples,
where the tuples are (ext_name, build_info), which ... | [
"def",
"check_extensions_list",
"(",
"self",
",",
"extensions",
")",
":",
"if",
"not",
"isinstance",
"(",
"extensions",
",",
"list",
")",
":",
"raise",
"DistutilsSetupError",
"(",
"\"'ext_modules' option must be a list of Extension instances\"",
")",
"for",
"i",
",",
... | [
342,
4
] | [
418,
31
] | python | en | ['en', 'en', 'en'] | True |
build_ext.swig_sources | (self, sources, extension) | Walk the list of source files in 'sources', looking for SWIG
interface (.i) files. Run SWIG on all that are found, and
return a modified 'sources' list with SWIG source files replaced
by the generated C (or C++) files.
| Walk the list of source files in 'sources', looking for SWIG
interface (.i) files. Run SWIG on all that are found, and
return a modified 'sources' list with SWIG source files replaced
by the generated C (or C++) files.
| def swig_sources(self, sources, extension):
"""Walk the list of source files in 'sources', looking for SWIG
interface (.i) files. Run SWIG on all that are found, and
return a modified 'sources' list with SWIG source files replaced
by the generated C (or C++) files.
"""
n... | [
"def",
"swig_sources",
"(",
"self",
",",
"sources",
",",
"extension",
")",
":",
"new_sources",
"=",
"[",
"]",
"swig_sources",
"=",
"[",
"]",
"swig_targets",
"=",
"{",
"}",
"# XXX this drops generated C/C++ files into the source tree, which",
"# is fine for developers wh... | [
562,
4
] | [
614,
26
] | python | en | ['en', 'en', 'en'] | True |
build_ext.find_swig | (self) | Return the name of the SWIG executable. On Unix, this is
just "swig" -- it should be in the PATH. Tries a bit harder on
Windows.
| Return the name of the SWIG executable. On Unix, this is
just "swig" -- it should be in the PATH. Tries a bit harder on
Windows.
| def find_swig(self):
"""Return the name of the SWIG executable. On Unix, this is
just "swig" -- it should be in the PATH. Tries a bit harder on
Windows.
"""
if os.name == "posix":
return "swig"
elif os.name == "nt":
# Look for SWIG in its standar... | [
"def",
"find_swig",
"(",
"self",
")",
":",
"if",
"os",
".",
"name",
"==",
"\"posix\"",
":",
"return",
"\"swig\"",
"elif",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"# Look for SWIG in its standard installation directory on",
"# Windows (or so I presume!). If we find it t... | [
616,
4
] | [
636,
47
] | python | en | ['en', 'en', 'en'] | True |
build_ext.get_ext_fullpath | (self, ext_name) | Returns the path of the filename for a given extension.
The file is located in `build_lib` or directly in the package
(inplace option).
| Returns the path of the filename for a given extension. | def get_ext_fullpath(self, ext_name):
"""Returns the path of the filename for a given extension.
The file is located in `build_lib` or directly in the package
(inplace option).
"""
fullname = self.get_ext_fullname(ext_name)
modpath = fullname.split('.')
filename ... | [
"def",
"get_ext_fullpath",
"(",
"self",
",",
"ext_name",
")",
":",
"fullname",
"=",
"self",
".",
"get_ext_fullname",
"(",
"ext_name",
")",
"modpath",
"=",
"fullname",
".",
"split",
"(",
"'.'",
")",
"filename",
"=",
"self",
".",
"get_ext_filename",
"(",
"mo... | [
640,
4
] | [
665,
50
] | python | en | ['en', 'en', 'en'] | True |
build_ext.get_ext_fullname | (self, ext_name) | Returns the fullname of a given extension name.
Adds the `package.` prefix | Returns the fullname of a given extension name. | def get_ext_fullname(self, ext_name):
"""Returns the fullname of a given extension name.
Adds the `package.` prefix"""
if self.package is None:
return ext_name
else:
return self.package + '.' + ext_name | [
"def",
"get_ext_fullname",
"(",
"self",
",",
"ext_name",
")",
":",
"if",
"self",
".",
"package",
"is",
"None",
":",
"return",
"ext_name",
"else",
":",
"return",
"self",
".",
"package",
"+",
"'.'",
"+",
"ext_name"
] | [
667,
4
] | [
674,
48
] | python | en | ['en', 'en', 'en'] | True |
build_ext.get_ext_filename | (self, ext_name) | r"""Convert the name of an extension (eg. "foo.bar") into the name
of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd").
| r"""Convert the name of an extension (eg. "foo.bar") into the name
of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd").
| def get_ext_filename(self, ext_name):
r"""Convert the name of an extension (eg. "foo.bar") into the name
of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd").
"""
from distutils.sysconfig import get_config_var
ext_path = ext_name.split('.')
... | [
"def",
"get_ext_filename",
"(",
"self",
",",
"ext_name",
")",
":",
"from",
"distutils",
".",
"sysconfig",
"import",
"get_config_var",
"ext_path",
"=",
"ext_name",
".",
"split",
"(",
"'.'",
")",
"ext_suffix",
"=",
"get_config_var",
"(",
"'EXT_SUFFIX'",
")",
"re... | [
676,
4
] | [
684,
51
] | python | en | ['en', 'en', 'en'] | True |
build_ext.get_export_symbols | (self, ext) | Return the list of symbols that a shared extension has to
export. This either uses 'ext.export_symbols' or, if it's not
provided, "PyInit_" + module_name. Only relevant on Windows, where
the .pyd file (DLL) must export the module "PyInit_" function.
| Return the list of symbols that a shared extension has to
export. This either uses 'ext.export_symbols' or, if it's not
provided, "PyInit_" + module_name. Only relevant on Windows, where
the .pyd file (DLL) must export the module "PyInit_" function.
| def get_export_symbols(self, ext):
"""Return the list of symbols that a shared extension has to
export. This either uses 'ext.export_symbols' or, if it's not
provided, "PyInit_" + module_name. Only relevant on Windows, where
the .pyd file (DLL) must export the module "PyInit_" function... | [
"def",
"get_export_symbols",
"(",
"self",
",",
"ext",
")",
":",
"suffix",
"=",
"'_'",
"+",
"ext",
".",
"name",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"try",
":",
"# Unicode module name support as defined in PEP-489",
"# https://www.python.org/dev/pep... | [
686,
4
] | [
703,
33
] | python | en | ['en', 'en', 'en'] | True |
build_ext.get_libraries | (self, ext) | Return the list of libraries to link against when building a
shared extension. On most platforms, this is just 'ext.libraries';
on Windows, we add the Python library (eg. python20.dll).
| Return the list of libraries to link against when building a
shared extension. On most platforms, this is just 'ext.libraries';
on Windows, we add the Python library (eg. python20.dll).
| def get_libraries(self, ext):
"""Return the list of libraries to link against when building a
shared extension. On most platforms, this is just 'ext.libraries';
on Windows, we add the Python library (eg. python20.dll).
"""
# The python library is always needed on Windows. For M... | [
"def",
"get_libraries",
"(",
"self",
",",
"ext",
")",
":",
"# The python library is always needed on Windows. For MSVC, this",
"# is redundant, since the library is mentioned in a pragma in",
"# pyconfig.h that MSVC groks. The other Windows compilers all seem",
"# to need it mentioned explic... | [
705,
4
] | [
754,
53
] | python | en | ['en', 'en', 'en'] | True |
is_mm_32_format | (msg_string: Optional[str]) |
Missed message strings are formatted with a little "mm" prefix
followed by a randomly generated 32-character string.
|
Missed message strings are formatted with a little "mm" prefix
followed by a randomly generated 32-character string.
| def is_mm_32_format(msg_string: Optional[str]) -> bool:
"""
Missed message strings are formatted with a little "mm" prefix
followed by a randomly generated 32-character string.
"""
return msg_string is not None and msg_string.startswith("mm") and len(msg_string) == 34 | [
"def",
"is_mm_32_format",
"(",
"msg_string",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"bool",
":",
"return",
"msg_string",
"is",
"not",
"None",
"and",
"msg_string",
".",
"startswith",
"(",
"\"mm\"",
")",
"and",
"len",
"(",
"msg_string",
")",
"==",
"3... | [
120,
0
] | [
125,
91
] | python | en | ['en', 'error', 'th'] | False |
Completer.__init__ | (self, namespace = None) | Create a new completer for the command line.
Completer([namespace]) -> completer instance.
If unspecified, the default namespace where completions are performed
is __main__ (technically, __main__.__dict__). Namespaces should be
given as dictionaries.
Completer instances should... | Create a new completer for the command line. | def __init__(self, namespace = None):
"""Create a new completer for the command line.
Completer([namespace]) -> completer instance.
If unspecified, the default namespace where completions are performed
is __main__ (technically, __main__.__dict__). Namespaces should be
given as ... | [
"def",
"__init__",
"(",
"self",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"namespace",
"and",
"not",
"isinstance",
"(",
"namespace",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"'namespace must be a dictionary'",
")",
"# Don't bind to namespace quite ye... | [
38,
4
] | [
63,
38
] | python | en | ['en', 'en', 'en'] | True |
Completer.complete | (self, text, state) | Return the next possible completion for 'text'.
This is called successively with state == 0, 1, 2, ... until it
returns None. The completion should begin with 'text'.
| Return the next possible completion for 'text'. | def complete(self, text, state):
"""Return the next possible completion for 'text'.
This is called successively with state == 0, 1, 2, ... until it
returns None. The completion should begin with 'text'.
"""
if self.use_main_ns:
self.namespace = __main__.__dict__
... | [
"def",
"complete",
"(",
"self",
",",
"text",
",",
"state",
")",
":",
"if",
"self",
".",
"use_main_ns",
":",
"self",
".",
"namespace",
"=",
"__main__",
".",
"__dict__",
"if",
"not",
"text",
".",
"strip",
"(",
")",
":",
"if",
"state",
"==",
"0",
":",... | [
65,
4
] | [
94,
23
] | python | en | ['en', 'en', 'en'] | True |
Completer.global_matches | (self, text) | Compute matches when text is a simple name.
Return a list of all keywords, built-in functions and names currently
defined in self.namespace that match.
| Compute matches when text is a simple name. | def global_matches(self, text):
"""Compute matches when text is a simple name.
Return a list of all keywords, built-in functions and names currently
defined in self.namespace that match.
"""
import keyword
matches = []
seen = {"__builtins__"}
n = len(tex... | [
"def",
"global_matches",
"(",
"self",
",",
"text",
")",
":",
"import",
"keyword",
"matches",
"=",
"[",
"]",
"seen",
"=",
"{",
"\"__builtins__\"",
"}",
"n",
"=",
"len",
"(",
"text",
")",
"for",
"word",
"in",
"keyword",
".",
"kwlist",
":",
"if",
"word"... | [
101,
4
] | [
127,
22
] | python | en | ['en', 'en', 'en'] | True |
Completer.attr_matches | (self, text) | Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is
evaluable in self.namespace, it will be evaluated and its attributes
(as revealed by dir()) are used as possible completions. (For class
instances, class members are also considered.)... | Compute matches when text contains a dot. | def attr_matches(self, text):
"""Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is
evaluable in self.namespace, it will be evaluated and its attributes
(as revealed by dir()) are used as possible completions. (For class
insta... | [
"def",
"attr_matches",
"(",
"self",
",",
"text",
")",
":",
"import",
"re",
"m",
"=",
"re",
".",
"match",
"(",
"r\"(\\w+(\\.\\w+)*)\\.(\\w*)\"",
",",
"text",
")",
"if",
"not",
"m",
":",
"return",
"[",
"]",
"expr",
",",
"attr",
"=",
"m",
".",
"group",
... | [
129,
4
] | [
185,
22
] | python | en | ['en', 'en', 'en'] | True |
RelativeLinksHelpExtension.extendMarkdown | (self, md: Markdown) | Add RelativeLinksHelpExtension to the Markdown instance. | Add RelativeLinksHelpExtension to the Markdown instance. | def extendMarkdown(self, md: Markdown) -> None:
"""Add RelativeLinksHelpExtension to the Markdown instance."""
md.registerExtension(self)
md.preprocessors.register(RelativeLinks(), "help_relative_links", 520) | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
":",
"Markdown",
")",
"->",
"None",
":",
"md",
".",
"registerExtension",
"(",
"self",
")",
"md",
".",
"preprocessors",
".",
"register",
"(",
"RelativeLinks",
"(",
")",
",",
"\"help_relative_links\"",
",",
"5... | [
72,
4
] | [
75,
78
] | python | en | ['en', 'en', 'en'] | True |
get_int_or_uuid | (value) | Check if a value is valid as UUID or an integer.
This method is mainly used to convert floating IP id to the
appropriate type. For floating IP id, integer is used in Nova's
original implementation, but UUID is used in Neutron based one.
| Check if a value is valid as UUID or an integer. | def get_int_or_uuid(value):
"""Check if a value is valid as UUID or an integer.
This method is mainly used to convert floating IP id to the
appropriate type. For floating IP id, integer is used in Nova's
original implementation, but UUID is used in Neutron based one.
"""
try:
uuid.UUID(... | [
"def",
"get_int_or_uuid",
"(",
"value",
")",
":",
"try",
":",
"uuid",
".",
"UUID",
"(",
"value",
")",
"return",
"value",
"except",
"(",
"ValueError",
",",
"AttributeError",
")",
":",
"return",
"int",
"(",
"value",
")"
] | [
17,
0
] | [
28,
25
] | python | en | ['en', 'en', 'en'] | True |
get_display_label | (choices, status) | Get a display label for resource status.
This method is used in places where a resource's status or
admin state labels need to assigned before they are sent to the
view template.
| Get a display label for resource status. | def get_display_label(choices, status):
"""Get a display label for resource status.
This method is used in places where a resource's status or
admin state labels need to assigned before they are sent to the
view template.
"""
for (value, label) in choices:
if value == (status or '').lo... | [
"def",
"get_display_label",
"(",
"choices",
",",
"status",
")",
":",
"for",
"(",
"value",
",",
"label",
")",
"in",
"choices",
":",
"if",
"value",
"==",
"(",
"status",
"or",
"''",
")",
".",
"lower",
"(",
")",
":",
"display_label",
"=",
"label",
"break... | [
31,
0
] | [
46,
24
] | python | en | ['en', 'en', 'en'] | True |
copyfileobj | (fsrc, fdst, length=16*1024) | copy data from file-like object fsrc to file-like object fdst | copy data from file-like object fsrc to file-like object fdst | def copyfileobj(fsrc, fdst, length=16*1024):
"""copy data from file-like object fsrc to file-like object fdst"""
while 1:
buf = fsrc.read(length)
if not buf:
break
fdst.write(buf) | [
"def",
"copyfileobj",
"(",
"fsrc",
",",
"fdst",
",",
"length",
"=",
"16",
"*",
"1024",
")",
":",
"while",
"1",
":",
"buf",
"=",
"fsrc",
".",
"read",
"(",
"length",
")",
"if",
"not",
"buf",
":",
"break",
"fdst",
".",
"write",
"(",
"buf",
")"
] | [
75,
0
] | [
81,
23
] | python | en | ['en', 'en', 'en'] | True |
copyfile | (src, dst, *, follow_symlinks=True) | Copy data from src to dst.
If follow_symlinks is not set and src is a symbolic link, a new
symlink will be created instead of copying the file it points to.
| Copy data from src to dst. | def copyfile(src, dst, *, follow_symlinks=True):
"""Copy data from src to dst.
If follow_symlinks is not set and src is a symbolic link, a new
symlink will be created instead of copying the file it points to.
"""
if _samefile(src, dst):
raise SameFileError("{!r} and {!r} are the same file"... | [
"def",
"copyfile",
"(",
"src",
",",
"dst",
",",
"*",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"if",
"_samefile",
"(",
"src",
",",
"dst",
")",
":",
"raise",
"SameFileError",
"(",
"\"{!r} and {!r} are the same file\"",
".",
"format",
"(",
"src",
",",
... | [
95,
0
] | [
122,
14
] | python | en | ['en', 'en', 'en'] | True |
copymode | (src, dst, *, follow_symlinks=True) | Copy mode bits from src to dst.
If follow_symlinks is not set, symlinks aren't followed if and only
if both `src` and `dst` are symlinks. If `lchmod` isn't available
(e.g. Linux) this method does nothing.
| Copy mode bits from src to dst. | def copymode(src, dst, *, follow_symlinks=True):
"""Copy mode bits from src to dst.
If follow_symlinks is not set, symlinks aren't followed if and only
if both `src` and `dst` are symlinks. If `lchmod` isn't available
(e.g. Linux) this method does nothing.
"""
if not follow_symlinks and os.pa... | [
"def",
"copymode",
"(",
"src",
",",
"dst",
",",
"*",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"if",
"not",
"follow_symlinks",
"and",
"os",
".",
"path",
".",
"islink",
"(",
"src",
")",
"and",
"os",
".",
"path",
".",
"islink",
"(",
"dst",
")",
... | [
124,
0
] | [
143,
45
] | python | en | ['en', 'en', 'en'] | True |
copystat | (src, dst, *, follow_symlinks=True) | Copy all stat info (mode bits, atime, mtime, flags) from src to dst.
If the optional flag `follow_symlinks` is not set, symlinks aren't followed if and
only if both `src` and `dst` are symlinks.
| Copy all stat info (mode bits, atime, mtime, flags) from src to dst. | def copystat(src, dst, *, follow_symlinks=True):
"""Copy all stat info (mode bits, atime, mtime, flags) from src to dst.
If the optional flag `follow_symlinks` is not set, symlinks aren't followed if and
only if both `src` and `dst` are symlinks.
"""
def _nop(*args, ns=None, follow_symlinks=None):... | [
"def",
"copystat",
"(",
"src",
",",
"dst",
",",
"*",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"def",
"_nop",
"(",
"*",
"args",
",",
"ns",
"=",
"None",
",",
"follow_symlinks",
"=",
"None",
")",
":",
"pass",
"# follow symlinks (aka don't not follow sym... | [
172,
0
] | [
224,
48
] | python | en | ['en', 'en', 'en'] | True |
copy | (src, dst, *, follow_symlinks=True) | Copy data and mode bits ("cp src dst"). Return the file's destination.
The destination may be a directory.
If follow_symlinks is false, symlinks won't be followed. This
resembles GNU's "cp -P src dst".
If source and destination are the same file, a SameFileError will be
raised.
| Copy data and mode bits ("cp src dst"). Return the file's destination. | def copy(src, dst, *, follow_symlinks=True):
"""Copy data and mode bits ("cp src dst"). Return the file's destination.
The destination may be a directory.
If follow_symlinks is false, symlinks won't be followed. This
resembles GNU's "cp -P src dst".
If source and destination are the same file, a ... | [
"def",
"copy",
"(",
"src",
",",
"dst",
",",
"*",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"dst",
")",
":",
"dst",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dst",
",",
"os",
".",
"path",
".",
... | [
226,
0
] | [
242,
14
] | python | en | ['en', 'fr', 'en'] | True |
copy2 | (src, dst, *, follow_symlinks=True) | Copy data and all stat info ("cp -p src dst"). Return the file's
destination."
The destination may be a directory.
If follow_symlinks is false, symlinks won't be followed. This
resembles GNU's "cp -P src dst".
| Copy data and all stat info ("cp -p src dst"). Return the file's
destination." | def copy2(src, dst, *, follow_symlinks=True):
"""Copy data and all stat info ("cp -p src dst"). Return the file's
destination."
The destination may be a directory.
If follow_symlinks is false, symlinks won't be followed. This
resembles GNU's "cp -P src dst".
"""
if os.path.isdir(dst):
... | [
"def",
"copy2",
"(",
"src",
",",
"dst",
",",
"*",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"dst",
")",
":",
"dst",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dst",
",",
"os",
".",
"path",
".",... | [
244,
0
] | [
258,
14
] | python | en | ['en', 'en', 'en'] | True |
ignore_patterns | (*patterns) | Function that can be used as copytree() ignore parameter.
Patterns is a sequence of glob-style patterns
that are used to exclude files | Function that can be used as copytree() ignore parameter. | def ignore_patterns(*patterns):
"""Function that can be used as copytree() ignore parameter.
Patterns is a sequence of glob-style patterns
that are used to exclude files"""
def _ignore_patterns(path, names):
ignored_names = []
for pattern in patterns:
ignored_names.extend(fn... | [
"def",
"ignore_patterns",
"(",
"*",
"patterns",
")",
":",
"def",
"_ignore_patterns",
"(",
"path",
",",
"names",
")",
":",
"ignored_names",
"=",
"[",
"]",
"for",
"pattern",
"in",
"patterns",
":",
"ignored_names",
".",
"extend",
"(",
"fnmatch",
".",
"filter"... | [
260,
0
] | [
270,
27
] | python | en | ['en', 'en', 'en'] | True |
copytree | (src, dst, symlinks=False, ignore=None, copy_function=copy2,
ignore_dangling_symlinks=False) | Recursively copy a directory tree.
The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.
If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is false, the cont... | Recursively copy a directory tree. | def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
ignore_dangling_symlinks=False):
"""Recursively copy a directory tree.
The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.
If the optional symlinks flag... | [
"def",
"copytree",
"(",
"src",
",",
"dst",
",",
"symlinks",
"=",
"False",
",",
"ignore",
"=",
"None",
",",
"copy_function",
"=",
"copy2",
",",
"ignore_dangling_symlinks",
"=",
"False",
")",
":",
"names",
"=",
"os",
".",
"listdir",
"(",
"src",
")",
"if"... | [
272,
0
] | [
359,
14
] | python | en | ['en', 'en', 'en'] | True |
rmtree | (path, ignore_errors=False, onerror=None) | Recursively delete a directory tree.
If ignore_errors is set, errors are ignored; otherwise, if onerror
is set, it is called to handle the error with arguments (func,
path, exc_info) where func is platform and implementation dependent;
path is the argument to that function that caused it to fail; and
... | Recursively delete a directory tree. | def rmtree(path, ignore_errors=False, onerror=None):
"""Recursively delete a directory tree.
If ignore_errors is set, errors are ignored; otherwise, if onerror
is set, it is called to handle the error with arguments (func,
path, exc_info) where func is platform and implementation dependent;
path is... | [
"def",
"rmtree",
"(",
"path",
",",
"ignore_errors",
"=",
"False",
",",
"onerror",
"=",
"None",
")",
":",
"if",
"ignore_errors",
":",
"def",
"onerror",
"(",
"*",
"args",
")",
":",
"pass",
"elif",
"onerror",
"is",
"None",
":",
"def",
"onerror",
"(",
"*... | [
444,
0
] | [
493,
44
] | python | en | ['en', 'en', 'en'] | True |
move | (src, dst, copy_function=copy2) | Recursively move a file or directory to another location. This is
similar to the Unix "mv" command. Return the file or directory's
destination.
If the destination is a directory or a symlink to a directory, the source
is moved inside the directory. The destination path must not already
exist.
... | Recursively move a file or directory to another location. This is
similar to the Unix "mv" command. Return the file or directory's
destination. | def move(src, dst, copy_function=copy2):
"""Recursively move a file or directory to another location. This is
similar to the Unix "mv" command. Return the file or directory's
destination.
If the destination is a directory or a symlink to a directory, the source
is moved inside the directory. The de... | [
"def",
"move",
"(",
"src",
",",
"dst",
",",
"copy_function",
"=",
"copy2",
")",
":",
"real_dst",
"=",
"dst",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"dst",
")",
":",
"if",
"_samefile",
"(",
"src",
",",
"dst",
")",
":",
"# We might be on a case in... | [
505,
0
] | [
559,
19
] | python | en | ['en', 'en', 'en'] | True |
_get_gid | (name) | Returns a gid, given a group name. | Returns a gid, given a group name. | def _get_gid(name):
"""Returns a gid, given a group name."""
if getgrnam is None or name is None:
return None
try:
result = getgrnam(name)
except KeyError:
result = None
if result is not None:
return result[2]
return None | [
"def",
"_get_gid",
"(",
"name",
")",
":",
"if",
"getgrnam",
"is",
"None",
"or",
"name",
"is",
"None",
":",
"return",
"None",
"try",
":",
"result",
"=",
"getgrnam",
"(",
"name",
")",
"except",
"KeyError",
":",
"result",
"=",
"None",
"if",
"result",
"i... | [
570,
0
] | [
580,
15
] | python | en | ['en', 'en', 'en'] | True |
_get_uid | (name) | Returns an uid, given a user name. | Returns an uid, given a user name. | def _get_uid(name):
"""Returns an uid, given a user name."""
if getpwnam is None or name is None:
return None
try:
result = getpwnam(name)
except KeyError:
result = None
if result is not None:
return result[2]
return None | [
"def",
"_get_uid",
"(",
"name",
")",
":",
"if",
"getpwnam",
"is",
"None",
"or",
"name",
"is",
"None",
":",
"return",
"None",
"try",
":",
"result",
"=",
"getpwnam",
"(",
"name",
")",
"except",
"KeyError",
":",
"result",
"=",
"None",
"if",
"result",
"i... | [
582,
0
] | [
592,
15
] | python | en | ['en', 'en', 'en'] | True |
_make_tarball | (base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
owner=None, group=None, logger=None) | Create a (possibly compressed) tar file from all the files under
'base_dir'.
'compress' must be "gzip" (the default), "bzip2", "xz", or None.
'owner' and 'group' can be used to define an owner and a group for the
archive that is being built. If not provided, the current owner and group
will be use... | Create a (possibly compressed) tar file from all the files under
'base_dir'. | def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
owner=None, group=None, logger=None):
"""Create a (possibly compressed) tar file from all the files under
'base_dir'.
'compress' must be "gzip" (the default), "bzip2", "xz", or None.
'owner' and 'group' can... | [
"def",
"_make_tarball",
"(",
"base_name",
",",
"base_dir",
",",
"compress",
"=",
"\"gzip\"",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
",",
"owner",
"=",
"None",
",",
"group",
"=",
"None",
",",
"logger",
"=",
"None",
")",
":",
"if",
"compre... | [
594,
0
] | [
657,
23
] | python | en | ['en', 'en', 'en'] | True |
_make_zipfile | (base_name, base_dir, verbose=0, dry_run=0, logger=None) | Create a zip file from all the files under 'base_dir'.
The output zip file will be named 'base_name' + ".zip". Returns the
name of the output zip file.
| Create a zip file from all the files under 'base_dir'. | def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
"""Create a zip file from all the files under 'base_dir'.
The output zip file will be named 'base_name' + ".zip". Returns the
name of the output zip file.
"""
import zipfile # late import for breaking circular dependency
... | [
"def",
"_make_zipfile",
"(",
"base_name",
",",
"base_dir",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
",",
"logger",
"=",
"None",
")",
":",
"import",
"zipfile",
"# late import for breaking circular dependency",
"zip_filename",
"=",
"base_name",
"+",
"\"... | [
659,
0
] | [
701,
23
] | python | en | ['en', 'en', 'en'] | True |
get_archive_formats | () | Returns a list of supported formats for archiving and unarchiving.
Each element of the returned sequence is a tuple (name, description)
| Returns a list of supported formats for archiving and unarchiving. | def get_archive_formats():
"""Returns a list of supported formats for archiving and unarchiving.
Each element of the returned sequence is a tuple (name, description)
"""
formats = [(name, registry[2]) for name, registry in
_ARCHIVE_FORMATS.items()]
formats.sort()
return formats | [
"def",
"get_archive_formats",
"(",
")",
":",
"formats",
"=",
"[",
"(",
"name",
",",
"registry",
"[",
"2",
"]",
")",
"for",
"name",
",",
"registry",
"in",
"_ARCHIVE_FORMATS",
".",
"items",
"(",
")",
"]",
"formats",
".",
"sort",
"(",
")",
"return",
"fo... | [
720,
0
] | [
728,
18
] | python | en | ['en', 'en', 'en'] | True |
register_archive_format | (name, function, extra_args=None, description='') | Registers an archive format.
name is the name of the format. function is the callable that will be
used to create archives. If provided, extra_args is a sequence of
(name, value) tuples that will be passed as arguments to the callable.
description can be provided to describe the format, and will be ret... | Registers an archive format. | def register_archive_format(name, function, extra_args=None, description=''):
"""Registers an archive format.
name is the name of the format. function is the callable that will be
used to create archives. If provided, extra_args is a sequence of
(name, value) tuples that will be passed as arguments to ... | [
"def",
"register_archive_format",
"(",
"name",
",",
"function",
",",
"extra_args",
"=",
"None",
",",
"description",
"=",
"''",
")",
":",
"if",
"extra_args",
"is",
"None",
":",
"extra_args",
"=",
"[",
"]",
"if",
"not",
"callable",
"(",
"function",
")",
":... | [
730,
0
] | [
749,
64
] | python | en | ['en', 'en', 'en'] | True |
make_archive | (base_name, format, root_dir=None, base_dir=None, verbose=0,
dry_run=0, owner=None, group=None, logger=None) | Create an archive file (eg. zip or tar).
'base_name' is the name of the file to create, minus any format-specific
extension; 'format' is the archive format: one of "zip", "tar", "gztar",
"bztar", or "xztar". Or any other registered format.
'root_dir' is a directory that will be the root directory of ... | Create an archive file (eg. zip or tar). | def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
dry_run=0, owner=None, group=None, logger=None):
"""Create an archive file (eg. zip or tar).
'base_name' is the name of the file to create, minus any format-specific
extension; 'format' is the archive format: one ... | [
"def",
"make_archive",
"(",
"base_name",
",",
"format",
",",
"root_dir",
"=",
"None",
",",
"base_dir",
"=",
"None",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
",",
"owner",
"=",
"None",
",",
"group",
"=",
"None",
",",
"logger",
"=",
"None",
... | [
754,
0
] | [
806,
19
] | python | en | ['en', 'gd', 'en'] | True |
get_unpack_formats | () | Returns a list of supported formats for unpacking.
Each element of the returned sequence is a tuple
(name, extensions, description)
| Returns a list of supported formats for unpacking. | def get_unpack_formats():
"""Returns a list of supported formats for unpacking.
Each element of the returned sequence is a tuple
(name, extensions, description)
"""
formats = [(name, info[0], info[3]) for name, info in
_UNPACK_FORMATS.items()]
formats.sort()
return formats | [
"def",
"get_unpack_formats",
"(",
")",
":",
"formats",
"=",
"[",
"(",
"name",
",",
"info",
"[",
"0",
"]",
",",
"info",
"[",
"3",
"]",
")",
"for",
"name",
",",
"info",
"in",
"_UNPACK_FORMATS",
".",
"items",
"(",
")",
"]",
"formats",
".",
"sort",
"... | [
809,
0
] | [
818,
18
] | python | en | ['en', 'en', 'en'] | True |
_check_unpack_options | (extensions, function, extra_args) | Checks what gets registered as an unpacker. | Checks what gets registered as an unpacker. | def _check_unpack_options(extensions, function, extra_args):
"""Checks what gets registered as an unpacker."""
# first make sure no other unpacker is registered for this extension
existing_extensions = {}
for name, info in _UNPACK_FORMATS.items():
for ext in info[0]:
existing_extensi... | [
"def",
"_check_unpack_options",
"(",
"extensions",
",",
"function",
",",
"extra_args",
")",
":",
"# first make sure no other unpacker is registered for this extension",
"existing_extensions",
"=",
"{",
"}",
"for",
"name",
",",
"info",
"in",
"_UNPACK_FORMATS",
".",
"items"... | [
820,
0
] | [
835,
69
] | python | en | ['en', 'en', 'en'] | True |
register_unpack_format | (name, extensions, function, extra_args=None,
description='') | Registers an unpack format.
`name` is the name of the format. `extensions` is a list of extensions
corresponding to the format.
`function` is the callable that will be
used to unpack archives. The callable will receive archives to unpack.
If it's unable to handle an archive, it needs to raise a Re... | Registers an unpack format. | def register_unpack_format(name, extensions, function, extra_args=None,
description=''):
"""Registers an unpack format.
`name` is the name of the format. `extensions` is a list of extensions
corresponding to the format.
`function` is the callable that will be
used to unp... | [
"def",
"register_unpack_format",
"(",
"name",
",",
"extensions",
",",
"function",
",",
"extra_args",
"=",
"None",
",",
"description",
"=",
"''",
")",
":",
"if",
"extra_args",
"is",
"None",
":",
"extra_args",
"=",
"[",
"]",
"_check_unpack_options",
"(",
"exte... | [
838,
0
] | [
858,
73
] | python | en | ['en', 'fr', 'en'] | True |
unregister_unpack_format | (name) | Removes the pack format from the registry. | Removes the pack format from the registry. | def unregister_unpack_format(name):
"""Removes the pack format from the registry."""
del _UNPACK_FORMATS[name] | [
"def",
"unregister_unpack_format",
"(",
"name",
")",
":",
"del",
"_UNPACK_FORMATS",
"[",
"name",
"]"
] | [
860,
0
] | [
862,
29
] | python | en | ['en', 'en', 'en'] | True |
_ensure_directory | (path) | Ensure that the parent directory of `path` exists | Ensure that the parent directory of `path` exists | def _ensure_directory(path):
"""Ensure that the parent directory of `path` exists"""
dirname = os.path.dirname(path)
if not os.path.isdir(dirname):
os.makedirs(dirname) | [
"def",
"_ensure_directory",
"(",
"path",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"dirname",
")",
":",
"os",
".",
"makedirs",
"(",
"dirname",
")"
] | [
864,
0
] | [
868,
28
] | python | en | ['en', 'en', 'en'] | True |
_unpack_zipfile | (filename, extract_dir) | Unpack zip `filename` to `extract_dir`
| Unpack zip `filename` to `extract_dir`
| def _unpack_zipfile(filename, extract_dir):
"""Unpack zip `filename` to `extract_dir`
"""
import zipfile # late import for breaking circular dependency
if not zipfile.is_zipfile(filename):
raise ReadError("%s is not a zip file" % filename)
zip = zipfile.ZipFile(filename)
try:
... | [
"def",
"_unpack_zipfile",
"(",
"filename",
",",
"extract_dir",
")",
":",
"import",
"zipfile",
"# late import for breaking circular dependency",
"if",
"not",
"zipfile",
".",
"is_zipfile",
"(",
"filename",
")",
":",
"raise",
"ReadError",
"(",
"\"%s is not a zip file\"",
... | [
870,
0
] | [
902,
19
] | python | en | ['en', 'nl', 'ur'] | False |
_unpack_tarfile | (filename, extract_dir) | Unpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir`
| Unpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir`
| def _unpack_tarfile(filename, extract_dir):
"""Unpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir`
"""
import tarfile # late import for breaking circular dependency
try:
tarobj = tarfile.open(filename)
except tarfile.TarError:
raise ReadError(
"%s is not a compr... | [
"def",
"_unpack_tarfile",
"(",
"filename",
",",
"extract_dir",
")",
":",
"import",
"tarfile",
"# late import for breaking circular dependency",
"try",
":",
"tarobj",
"=",
"tarfile",
".",
"open",
"(",
"filename",
")",
"except",
"tarfile",
".",
"TarError",
":",
"rai... | [
904,
0
] | [
916,
22
] | python | az | ['en', 'az', 'hi'] | False |
unpack_archive | (filename, extract_dir=None, format=None) | Unpack an archive.
`filename` is the name of the archive.
`extract_dir` is the name of the target directory, where the archive
is unpacked. If not provided, the current working directory is used.
`format` is the archive format: one of "zip", "tar", "gztar", "bztar",
or "xztar". Or any other regi... | Unpack an archive. | def unpack_archive(filename, extract_dir=None, format=None):
"""Unpack an archive.
`filename` is the name of the archive.
`extract_dir` is the name of the target directory, where the archive
is unpacked. If not provided, the current working directory is used.
`format` is the archive format: one o... | [
"def",
"unpack_archive",
"(",
"filename",
",",
"extract_dir",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"if",
"extract_dir",
"is",
"None",
":",
"extract_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"if",
"format",
"is",
"not",
"None",
":",
"try",... | [
942,
0
] | [
976,
45
] | python | de | ['en', 'fr', 'de'] | False |
chown | (path, user=None, group=None) | Change owner user and group of the given path.
user and group can be the uid/gid or the user/group names, and in that case,
they are converted to their respective uid/gid.
| Change owner user and group of the given path. | def chown(path, user=None, group=None):
"""Change owner user and group of the given path.
user and group can be the uid/gid or the user/group names, and in that case,
they are converted to their respective uid/gid.
"""
if user is None and group is None:
raise ValueError("user and/or group ... | [
"def",
"chown",
"(",
"path",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
")",
":",
"if",
"user",
"is",
"None",
"and",
"group",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"user and/or group must be set\"",
")",
"_user",
"=",
"user",
"_group... | [
1016,
0
] | [
1045,
33
] | python | en | ['en', 'en', 'en'] | True |
get_terminal_size | (fallback=(80, 24)) | Get the size of the terminal window.
For each of the two dimensions, the environment variable, COLUMNS
and LINES respectively, is checked. If the variable is defined and
the value is a positive integer, it is used.
When COLUMNS or LINES is not defined, which is the common case,
the terminal connec... | Get the size of the terminal window. | def get_terminal_size(fallback=(80, 24)):
"""Get the size of the terminal window.
For each of the two dimensions, the environment variable, COLUMNS
and LINES respectively, is checked. If the variable is defined and
the value is a positive integer, it is used.
When COLUMNS or LINES is not defined, ... | [
"def",
"get_terminal_size",
"(",
"fallback",
"=",
"(",
"80",
",",
"24",
")",
")",
":",
"# columns, lines are the working values",
"try",
":",
"columns",
"=",
"int",
"(",
"os",
".",
"environ",
"[",
"'COLUMNS'",
"]",
")",
"except",
"(",
"KeyError",
",",
"Val... | [
1047,
0
] | [
1090,
45
] | python | en | ['en', 'en', 'en'] | True |
which | (cmd, mode=os.F_OK | os.X_OK, path=None) | Given a command, mode, and a PATH string, return the path which
conforms to the given mode on the PATH, or None if there is no such
file.
`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
of os.environ.get("PATH"), or can be overridden with a custom search
path.
| Given a command, mode, and a PATH string, return the path which
conforms to the given mode on the PATH, or None if there is no such
file. | def which(cmd, mode=os.F_OK | os.X_OK, path=None):
"""Given a command, mode, and a PATH string, return the path which
conforms to the given mode on the PATH, or None if there is no such
file.
`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
of os.environ.get("PATH"), or can be ov... | [
"def",
"which",
"(",
"cmd",
",",
"mode",
"=",
"os",
".",
"F_OK",
"|",
"os",
".",
"X_OK",
",",
"path",
"=",
"None",
")",
":",
"# Check that a given file can be accessed with the correct mode.",
"# Additionally check that `file` is not a directory, as on Windows",
"# direct... | [
1092,
0
] | [
1152,
15
] | python | en | ['en', 'en', 'en'] | True |
message | (level, text) | A wrapper method for logging debug messages. | A wrapper method for logging debug messages. | def message(level, text):
""" A wrapper method for logging debug messages. """
logger = logging.getLogger('MARKDOWN')
if logger.handlers:
# The logger is configured
logger.log(level, text)
if level > WARN:
sys.exit(0)
elif level > WARN:
raise MarkdownExceptio... | [
"def",
"message",
"(",
"level",
",",
"text",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'MARKDOWN'",
")",
"if",
"logger",
".",
"handlers",
":",
"# The logger is configured",
"logger",
".",
"log",
"(",
"level",
",",
"text",
")",
"if",
"le... | [
102,
0
] | [
113,
44
] | python | en | ['en', 'da', 'en'] | True |
isBlockLevel | (tag) | Check if the tag is a block level HTML tag. | Check if the tag is a block level HTML tag. | def isBlockLevel(tag):
"""Check if the tag is a block level HTML tag."""
return BLOCK_LEVEL_ELEMENTS.match(tag) | [
"def",
"isBlockLevel",
"(",
"tag",
")",
":",
"return",
"BLOCK_LEVEL_ELEMENTS",
".",
"match",
"(",
"tag",
")"
] | [
116,
0
] | [
118,
42
] | python | en | ['en', 'en', 'en'] | True |
load_extension | (ext_name, configs = []) | Load extension by name, then return the module.
The extension name may contain arguments as part of the string in the
following format: "extname(key1=value1,key2=value2)"
| Load extension by name, then return the module. | def load_extension(ext_name, configs = []):
"""Load extension by name, then return the module.
The extension name may contain arguments as part of the string in the
following format: "extname(key1=value1,key2=value2)"
"""
# Parse extensions config params (ignore the order)
configs = dict(conf... | [
"def",
"load_extension",
"(",
"ext_name",
",",
"configs",
"=",
"[",
"]",
")",
":",
"# Parse extensions config params (ignore the order)",
"configs",
"=",
"dict",
"(",
"configs",
")",
"pos",
"=",
"ext_name",
".",
"find",
"(",
"\"(\"",
")",
"# find the first \"(\"",... | [
507,
0
] | [
546,
73
] | python | en | ['en', 'en', 'en'] | True |
load_extensions | (ext_names) | Loads multiple extensions | Loads multiple extensions | def load_extensions(ext_names):
"""Loads multiple extensions"""
extensions = []
for ext_name in ext_names:
extension = load_extension(ext_name)
if extension:
extensions.append(extension)
return extensions | [
"def",
"load_extensions",
"(",
"ext_names",
")",
":",
"extensions",
"=",
"[",
"]",
"for",
"ext_name",
"in",
"ext_names",
":",
"extension",
"=",
"load_extension",
"(",
"ext_name",
")",
"if",
"extension",
":",
"extensions",
".",
"append",
"(",
"extension",
")"... | [
549,
0
] | [
556,
21
] | python | en | ['en', 'en', 'en'] | True |
markdown | (text,
extensions = [],
safe_mode = False,
output_format = DEFAULT_OUTPUT_FORMAT) | Convert a markdown string to HTML and return HTML as a unicode string.
This is a shortcut function for `Markdown` class to cover the most
basic use case. It initializes an instance of Markdown, loads the
necessary extensions and runs the parser on the given text.
Keyword arguments:
* text: Markd... | Convert a markdown string to HTML and return HTML as a unicode string. | def markdown(text,
extensions = [],
safe_mode = False,
output_format = DEFAULT_OUTPUT_FORMAT):
"""Convert a markdown string to HTML and return HTML as a unicode string.
This is a shortcut function for `Markdown` class to cover the most
basic use case. It initializes ... | [
"def",
"markdown",
"(",
"text",
",",
"extensions",
"=",
"[",
"]",
",",
"safe_mode",
"=",
"False",
",",
"output_format",
"=",
"DEFAULT_OUTPUT_FORMAT",
")",
":",
"md",
"=",
"Markdown",
"(",
"extensions",
"=",
"load_extensions",
"(",
"extensions",
")",
",",
"... | [
567,
0
] | [
597,
27
] | python | en | ['en', 'en', 'en'] | True |
markdownFromFile | (input = None,
output = None,
extensions = [],
encoding = None,
safe_mode = False,
output_format = DEFAULT_OUTPUT_FORMAT) | Read markdown code from a file and write it to a file or a stream. | Read markdown code from a file and write it to a file or a stream. | def markdownFromFile(input = None,
output = None,
extensions = [],
encoding = None,
safe_mode = False,
output_format = DEFAULT_OUTPUT_FORMAT):
"""Read markdown code from a file and write it to a file or a stream... | [
"def",
"markdownFromFile",
"(",
"input",
"=",
"None",
",",
"output",
"=",
"None",
",",
"extensions",
"=",
"[",
"]",
",",
"encoding",
"=",
"None",
",",
"safe_mode",
"=",
"False",
",",
"output_format",
"=",
"DEFAULT_OUTPUT_FORMAT",
")",
":",
"md",
"=",
"Ma... | [
600,
0
] | [
610,
43
] | python | en | ['en', 'en', 'en'] | True |
Markdown.__init__ | (self,
extensions=[],
extension_configs={},
safe_mode = False,
output_format=DEFAULT_OUTPUT_FORMAT) |
Creates a new Markdown instance.
Keyword arguments:
* extensions: A list of extensions.
If they are of type string, the module mdx_name.py will be loaded.
If they are a subclass of markdown.Extension, they will be used
as-is.
* extension-configs: Confi... |
Creates a new Markdown instance. | def __init__(self,
extensions=[],
extension_configs={},
safe_mode = False,
output_format=DEFAULT_OUTPUT_FORMAT):
"""
Creates a new Markdown instance.
Keyword arguments:
* extensions: A list of extensions.
I... | [
"def",
"__init__",
"(",
"self",
",",
"extensions",
"=",
"[",
"]",
",",
"extension_configs",
"=",
"{",
"}",
",",
"safe_mode",
"=",
"False",
",",
"output_format",
"=",
"DEFAULT_OUTPUT_FORMAT",
")",
":",
"self",
".",
"safeMode",
"=",
"safe_mode",
"self",
".",... | [
181,
4
] | [
313,
20
] | python | en | ['en', 'error', 'th'] | False |
Markdown.registerExtensions | (self, extensions, configs) |
Register extensions with this instance of Markdown.
Keyword aurguments:
* extensions: A list of extensions, which can either
be strings or objects. See the docstring on Markdown.
* configs: A dictionary mapping module names to config options.
|
Register extensions with this instance of Markdown. | def registerExtensions(self, extensions, configs):
"""
Register extensions with this instance of Markdown.
Keyword aurguments:
* extensions: A list of extensions, which can either
be strings or objects. See the docstring on Markdown.
* configs: A dictionary mapping ... | [
"def",
"registerExtensions",
"(",
"self",
",",
"extensions",
",",
"configs",
")",
":",
"for",
"ext",
"in",
"extensions",
":",
"if",
"isinstance",
"(",
"ext",
",",
"basestring",
")",
":",
"ext",
"=",
"load_extension",
"(",
"ext",
",",
"configs",
".",
"get... | [
315,
4
] | [
336,
73
] | python | en | ['en', 'error', 'th'] | False |
Markdown.registerExtension | (self, extension) | This gets called by the extension | This gets called by the extension | def registerExtension(self, extension):
""" This gets called by the extension """
self.registeredExtensions.append(extension) | [
"def",
"registerExtension",
"(",
"self",
",",
"extension",
")",
":",
"self",
".",
"registeredExtensions",
".",
"append",
"(",
"extension",
")"
] | [
338,
4
] | [
340,
51
] | python | en | ['en', 'en', 'en'] | True |
Markdown.reset | (self) |
Resets all state variables so that we can start with a new text.
|
Resets all state variables so that we can start with a new text.
| def reset(self):
"""
Resets all state variables so that we can start with a new text.
"""
self.htmlStash.reset()
self.references.clear()
for extension in self.registeredExtensions:
extension.reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"htmlStash",
".",
"reset",
"(",
")",
"self",
".",
"references",
".",
"clear",
"(",
")",
"for",
"extension",
"in",
"self",
".",
"registeredExtensions",
":",
"extension",
".",
"reset",
"(",
")"
] | [
342,
4
] | [
350,
29
] | python | en | ['en', 'error', 'th'] | False |
Markdown.set_output_format | (self, format) | Set the output format for the class instance. | Set the output format for the class instance. | def set_output_format(self, format):
""" Set the output format for the class instance. """
try:
self.serializer = self.output_formats[format.lower()]
except KeyError:
message(CRITICAL, 'Invalid Output Format: "%s". Use one of %s.' \
% (forma... | [
"def",
"set_output_format",
"(",
"self",
",",
"format",
")",
":",
"try",
":",
"self",
".",
"serializer",
"=",
"self",
".",
"output_formats",
"[",
"format",
".",
"lower",
"(",
")",
"]",
"except",
"KeyError",
":",
"message",
"(",
"CRITICAL",
",",
"'Invalid... | [
352,
4
] | [
358,
70
] | python | en | ['en', 'en', 'en'] | True |
Markdown.convert | (self, source) |
Convert markdown to serialized XHTML or HTML.
Keyword arguments:
* source: Source text as a Unicode string.
|
Convert markdown to serialized XHTML or HTML. | def convert(self, source):
"""
Convert markdown to serialized XHTML or HTML.
Keyword arguments:
* source: Source text as a Unicode string.
"""
# Fixup the source text
if not source.strip():
return u"" # a blank unicode string
try:
... | [
"def",
"convert",
"(",
"self",
",",
"source",
")",
":",
"# Fixup the source text",
"if",
"not",
"source",
".",
"strip",
"(",
")",
":",
"return",
"u\"\"",
"# a blank unicode string",
"try",
":",
"source",
"=",
"unicode",
"(",
"source",
")",
"except",
"Unicode... | [
360,
4
] | [
417,
29
] | python | en | ['en', 'error', 'th'] | False |
Markdown.convertFile | (self, input=None, output=None, encoding=None) | Converts a markdown file and returns the HTML as a unicode string.
Decodes the file using the provided encoding (defaults to utf-8),
passes the file content to markdown, and outputs the html to either
the provided stream or the file with provided name, using the same
encoding as the sou... | Converts a markdown file and returns the HTML as a unicode string. | def convertFile(self, input=None, output=None, encoding=None):
"""Converts a markdown file and returns the HTML as a unicode string.
Decodes the file using the provided encoding (defaults to utf-8),
passes the file content to markdown, and outputs the html to either
the provided stream ... | [
"def",
"convertFile",
"(",
"self",
",",
"input",
"=",
"None",
",",
"output",
"=",
"None",
",",
"encoding",
"=",
"None",
")",
":",
"encoding",
"=",
"encoding",
"or",
"\"utf-8\"",
"# Read the source",
"input_file",
"=",
"codecs",
".",
"open",
"(",
"input",
... | [
419,
4
] | [
456,
47
] | python | en | ['en', 'en', 'en'] | True |
Extension.__init__ | (self, configs = {}) | Create an instance of an Extention.
Keyword arguments:
* configs: A dict of configuration setting used by an Extension.
| Create an instance of an Extention. | def __init__(self, configs = {}):
"""Create an instance of an Extention.
Keyword arguments:
* configs: A dict of configuration setting used by an Extension.
"""
self.config = configs | [
"def",
"__init__",
"(",
"self",
",",
"configs",
"=",
"{",
"}",
")",
":",
"self",
".",
"config",
"=",
"configs"
] | [
466,
4
] | [
473,
29
] | python | en | ['en', 'lb', 'en'] | True |
Extension.getConfig | (self, key) | Return a setting for the given key or an empty string. | Return a setting for the given key or an empty string. | def getConfig(self, key):
""" Return a setting for the given key or an empty string. """
if key in self.config:
return self.config[key][0]
else:
return "" | [
"def",
"getConfig",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"config",
":",
"return",
"self",
".",
"config",
"[",
"key",
"]",
"[",
"0",
"]",
"else",
":",
"return",
"\"\""
] | [
475,
4
] | [
480,
21
] | python | en | ['en', 'en', 'en'] | True |
Extension.getConfigInfo | (self) | Return all config settings as a list of tuples. | Return all config settings as a list of tuples. | def getConfigInfo(self):
""" Return all config settings as a list of tuples. """
return [(key, self.config[key][1]) for key in self.config.keys()] | [
"def",
"getConfigInfo",
"(",
"self",
")",
":",
"return",
"[",
"(",
"key",
",",
"self",
".",
"config",
"[",
"key",
"]",
"[",
"1",
"]",
")",
"for",
"key",
"in",
"self",
".",
"config",
".",
"keys",
"(",
")",
"]"
] | [
482,
4
] | [
484,
73
] | python | en | ['en', 'en', 'en'] | True |
Extension.setConfig | (self, key, value) | Set a config setting for `key` with the given `value`. | Set a config setting for `key` with the given `value`. | def setConfig(self, key, value):
""" Set a config setting for `key` with the given `value`. """
self.config[key][0] = value | [
"def",
"setConfig",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"config",
"[",
"key",
"]",
"[",
"0",
"]",
"=",
"value"
] | [
486,
4
] | [
488,
35
] | python | en | ['en', 'en', 'en'] | True |
Extension.extendMarkdown | (self, md, md_globals) |
Add the various proccesors and patterns to the Markdown Instance.
This method must be overriden by every extension.
Keyword arguments:
* md: The Markdown instance.
* md_globals: Global variables in the markdown module namespace.
|
Add the various proccesors and patterns to the Markdown Instance. | def extendMarkdown(self, md, md_globals):
"""
Add the various proccesors and patterns to the Markdown Instance.
This method must be overriden by every extension.
Keyword arguments:
* md: The Markdown instance.
* md_globals: Global variables in the markdown module name... | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
",",
"md_globals",
")",
":",
"raise",
"NotImplementedError",
",",
"'Extension \"%s.%s\" must define an \"extendMarkdown\"'",
"'method.'",
"%",
"(",
"self",
".",
"__class__",
".",
"__module__",
",",
"self",
".",
"__cla... | [
490,
4
] | [
504,
76
] | python | en | ['en', 'error', 'th'] | False |
SelfHandlingForm.api_error | (self, message) | Adds an error to the form's error dictionary.
It can be used after validation based on problems reported via the API.
This is useful when you wish for API errors to appear as errors on the
form rather than using the messages framework.
| Adds an error to the form's error dictionary. | def api_error(self, message):
"""Adds an error to the form's error dictionary.
It can be used after validation based on problems reported via the API.
This is useful when you wish for API errors to appear as errors on the
form rather than using the messages framework.
"""
... | [
"def",
"api_error",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"add_error",
"(",
"NON_FIELD_ERRORS",
",",
"message",
")"
] | [
35,
4
] | [
42,
49
] | python | en | ['en', 'en', 'en'] | True |
SelfHandlingForm.set_warning | (self, message) | Sets a warning on the form.
Unlike NON_FIELD_ERRORS, this doesn't fail form validation.
| Sets a warning on the form. | def set_warning(self, message):
"""Sets a warning on the form.
Unlike NON_FIELD_ERRORS, this doesn't fail form validation.
"""
self.warnings = self.error_class([message]) | [
"def",
"set_warning",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"warnings",
"=",
"self",
".",
"error_class",
"(",
"[",
"message",
"]",
")"
] | [
44,
4
] | [
49,
51
] | python | en | ['en', 'en', 'en'] | True |
discover_files | (base_path, sub_path='', ext='', trim_base_path=False) | Discovers all files with certain extension in given paths. | Discovers all files with certain extension in given paths. | def discover_files(base_path, sub_path='', ext='', trim_base_path=False):
"""Discovers all files with certain extension in given paths."""
file_list = []
for root, dirs, files in walk(path.join(base_path, sub_path)):
if trim_base_path:
root = path.relpath(root, base_path)
file_li... | [
"def",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"''",
",",
"ext",
"=",
"''",
",",
"trim_base_path",
"=",
"False",
")",
":",
"file_list",
"=",
"[",
"]",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"walk",
"(",
"path",
".",
"join",... | [
24,
0
] | [
33,
28
] | python | en | ['en', 'en', 'en'] | True |
sort_js_files | (js_files) | Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be listed in the below order:
-... | Sorts JavaScript files in `js_files`. | def sort_js_files(js_files):
"""Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be... | [
"def",
"sort_js_files",
"(",
"js_files",
")",
":",
"modules",
"=",
"[",
"f",
"for",
"f",
"in",
"js_files",
"if",
"f",
".",
"endswith",
"(",
"MODULE_EXT",
")",
"]",
"mocks",
"=",
"[",
"f",
"for",
"f",
"in",
"js_files",
"if",
"f",
".",
"endswith",
"(... | [
36,
0
] | [
71,
32
] | python | en | ['en', 'id', 'nl'] | False |
discover_static_files | (base_path, sub_path='') | Discovers static files in given paths.
It returns JavaScript sources, mocks, specs and HTML templates,
all grouped in lists.
| Discovers static files in given paths. | def discover_static_files(base_path, sub_path=''):
"""Discovers static files in given paths.
It returns JavaScript sources, mocks, specs and HTML templates,
all grouped in lists.
"""
js_files = discover_files(base_path, sub_path=sub_path,
ext='.js', trim_base_path=True... | [
"def",
"discover_static_files",
"(",
"base_path",
",",
"sub_path",
"=",
"''",
")",
":",
"js_files",
"=",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"sub_path",
",",
"ext",
"=",
"'.js'",
",",
"trim_base_path",
"=",
"True",
")",
"sources",
",",
... | [
74,
0
] | [
92,
44
] | python | en | ['en', 'en', 'en'] | True |
_log | (file_list, list_name, in_path) | Logs result at debug level | Logs result at debug level | def _log(file_list, list_name, in_path):
"""Logs result at debug level"""
file_names = '\n'.join(file_list)
LOG.debug("\nDiscovered %(size)d %(name)s file(s) in %(path)s:\n"
"%(files)s\n",
{'size': len(file_list), 'name': list_name, 'path': in_path,
'files': file_n... | [
"def",
"_log",
"(",
"file_list",
",",
"list_name",
",",
"in_path",
")",
":",
"file_names",
"=",
"'\\n'",
".",
"join",
"(",
"file_list",
")",
"LOG",
".",
"debug",
"(",
"\"\\nDiscovered %(size)d %(name)s file(s) in %(path)s:\\n\"",
"\"%(files)s\\n\"",
",",
"{",
"'si... | [
109,
0
] | [
115,
36
] | python | da | ['da', 'da', 'en'] | True |
get_safe_phrase | (phrase: str) |
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
|
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
| def get_safe_phrase(phrase: str) -> str:
"""
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
"""
phrase = SPLIT_BOUNDARY_REGEX.sub("_", phrase)
return phrase.lower() | [
"def",
"get_safe_phrase",
"(",
"phrase",
":",
"str",
")",
"->",
"str",
":",
"phrase",
"=",
"SPLIT_BOUNDARY_REGEX",
".",
"sub",
"(",
"\"_\"",
",",
"phrase",
")",
"return",
"phrase",
".",
"lower",
"(",
")"
] | [
190,
0
] | [
197,
25
] | python | en | ['en', 'error', 'th'] | False |
replace_with_safe_phrase | (matchobj: Match[str]) |
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of the phrase
to upper case.
|
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of the phrase
to upper case.
| def replace_with_safe_phrase(matchobj: Match[str]) -> str:
"""
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of ... | [
"def",
"replace_with_safe_phrase",
"(",
"matchobj",
":",
"Match",
"[",
"str",
"]",
")",
"->",
"str",
":",
"ignored_phrase",
"=",
"matchobj",
".",
"group",
"(",
"0",
")",
"safe_string",
"=",
"get_safe_phrase",
"(",
"ignored_phrase",
")",
"start_index",
"=",
"... | [
200,
0
] | [
222,
22
] | python | en | ['en', 'error', 'th'] | False |
get_safe_text | (text: str) |
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
|
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
| def get_safe_text(text: str) -> str:
"""
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
"""
soup = BeautifulSoup(text, "lxml")
text = " ".join(soup.text.split()) # Remove extra whitespaces.
for phrase_r... | [
"def",
"get_safe_text",
"(",
"text",
":",
"str",
")",
"->",
"str",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"text",
",",
"\"lxml\"",
")",
"text",
"=",
"\" \"",
".",
"join",
"(",
"soup",
".",
"text",
".",
"split",
"(",
")",
")",
"# Remove extra whitespac... | [
225,
0
] | [
235,
15
] | python | en | ['en', 'error', 'th'] | False |
aws_credentials | () | Mocked AWS Credentials for moto. | Mocked AWS Credentials for moto. | def aws_credentials():
"""Mocked AWS Credentials for moto."""
os.environ['AWS_ACCESS_KEY_ID'] = 'testing'
os.environ['AWS_SECRET_ACCESS_KEY'] = 'testing'
os.environ['AWS_SECURITY_TOKEN'] = 'testing'
os.environ['AWS_SESSION_TOKEN'] = 'testing' | [
"def",
"aws_credentials",
"(",
")",
":",
"os",
".",
"environ",
"[",
"'AWS_ACCESS_KEY_ID'",
"]",
"=",
"'testing'",
"os",
".",
"environ",
"[",
"'AWS_SECRET_ACCESS_KEY'",
"]",
"=",
"'testing'",
"os",
".",
"environ",
"[",
"'AWS_SECURITY_TOKEN'",
"]",
"=",
"'testin... | [
7,
0
] | [
12,
47
] | python | en | ['en', 'en', 'en'] | True |
test_create_cloudwatch_log_group | (cloudwatch_logs) | Create Cloudwatch log group | Create Cloudwatch log group | def test_create_cloudwatch_log_group(cloudwatch_logs):
"""Create Cloudwatch log group"""
cloudwatch_logs.create_log_group(
logGroupName='/ecs/mongo/change-stream',
tags={'env': 'test'}
)
result = cloudwatch_logs.describe_log_groups()
assert len(result['logGroups']) == 1
assert r... | [
"def",
"test_create_cloudwatch_log_group",
"(",
"cloudwatch_logs",
")",
":",
"cloudwatch_logs",
".",
"create_log_group",
"(",
"logGroupName",
"=",
"'/ecs/mongo/change-stream'",
",",
"tags",
"=",
"{",
"'env'",
":",
"'test'",
"}",
")",
"result",
"=",
"cloudwatch_logs",
... | [
21,
0
] | [
30,
79
] | python | en | ['en', 'tg', 'en'] | True |
_wrapper | (args=None) | Central wrapper for all old entrypoints.
Historically pip has had several entrypoints defined. Because of issues
arising from PATH, sys.path, multiple Pythons, their interactions, and most
of them having a pip installed, users suffer every time an entrypoint gets
moved.
To alleviate this pain, and... | Central wrapper for all old entrypoints. | def _wrapper(args=None):
# type: (Optional[List[str]]) -> int
"""Central wrapper for all old entrypoints.
Historically pip has had several entrypoints defined. Because of issues
arising from PATH, sys.path, multiple Pythons, their interactions, and most
of them having a pip installed, users suffer ... | [
"def",
"_wrapper",
"(",
"args",
"=",
"None",
")",
":",
"# type: (Optional[List[str]]) -> int",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"WARNING: pip is being invoked by an old script wrapper. This will \"",
"\"fail in a future version of pip.\\n\"",
"\"Please see https://github.... | [
9,
0
] | [
30,
21
] | python | en | ['en', 'en', 'en'] | True |
WheelDistribution.get_pkg_resources_distribution | (self) | Loads the metadata from the wheel file into memory and returns a
Distribution that uses it, not relying on the wheel file or
requirement.
| Loads the metadata from the wheel file into memory and returns a
Distribution that uses it, not relying on the wheel file or
requirement.
| def get_pkg_resources_distribution(self):
# type: () -> Distribution
"""Loads the metadata from the wheel file into memory and returns a
Distribution that uses it, not relying on the wheel file or
requirement.
"""
# Set as part of preparation during download.
asse... | [
"def",
"get_pkg_resources_distribution",
"(",
"self",
")",
":",
"# type: () -> Distribution",
"# Set as part of preparation during download.",
"assert",
"self",
".",
"req",
".",
"local_file_path",
"# Wheels are never unnamed.",
"assert",
"self",
".",
"req",
".",
"name",
"wi... | [
17,
4
] | [
31,
13
] | python | en | ['en', 'en', 'en'] | True |
OrderedDict.value_for_index | (self, index) | Return the value of the item at the given zero-based index. | Return the value of the item at the given zero-based index. | def value_for_index(self, index):
"""Return the value of the item at the given zero-based index."""
return self[self.keyOrder[index]] | [
"def",
"value_for_index",
"(",
"self",
",",
"index",
")",
":",
"return",
"self",
"[",
"self",
".",
"keyOrder",
"[",
"index",
"]",
"]"
] | [
85,
4
] | [
87,
41
] | python | en | ['en', 'en', 'en'] | True |
OrderedDict.insert | (self, index, key, value) | Insert the key, value pair before the item with the given index. | Insert the key, value pair before the item with the given index. | def insert(self, index, key, value):
"""Insert the key, value pair before the item with the given index."""
if key in self.keyOrder:
n = self.keyOrder.index(key)
del self.keyOrder[n]
if n < index:
index -= 1
self.keyOrder.insert(index, key)
... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"in",
"self",
".",
"keyOrder",
":",
"n",
"=",
"self",
".",
"keyOrder",
".",
"index",
"(",
"key",
")",
"del",
"self",
".",
"keyOrder",
"[",
"n",
"]",
"i... | [
89,
4
] | [
97,
56
] | python | en | ['en', 'en', 'en'] | True |
OrderedDict.copy | (self) | Return a copy of this object. | Return a copy of this object. | def copy(self):
"""Return a copy of this object."""
# This way of initializing the copy means it works for subclasses, too.
obj = self.__class__(self)
obj.keyOrder = self.keyOrder[:]
return obj | [
"def",
"copy",
"(",
"self",
")",
":",
"# This way of initializing the copy means it works for subclasses, too.",
"obj",
"=",
"self",
".",
"__class__",
"(",
"self",
")",
"obj",
".",
"keyOrder",
"=",
"self",
".",
"keyOrder",
"[",
":",
"]",
"return",
"obj"
] | [
99,
4
] | [
104,
18
] | python | en | ['en', 'en', 'en'] | True |
OrderedDict.__repr__ | (self) |
Replace the normal dict.__repr__ with a version that returns the keys
in their sorted order.
|
Replace the normal dict.__repr__ with a version that returns the keys
in their sorted order.
| def __repr__(self):
"""
Replace the normal dict.__repr__ with a version that returns the keys
in their sorted order.
"""
return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()]) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"'{%s}'",
"%",
"', '",
".",
"join",
"(",
"[",
"'%r: %r'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
"]",
")"
] | [
106,
4
] | [
111,
79
] | python | en | ['en', 'error', 'th'] | False |
OrderedDict.index | (self, key) | Return the index of a given key. | Return the index of a given key. | def index(self, key):
""" Return the index of a given key. """
return self.keyOrder.index(key) | [
"def",
"index",
"(",
"self",
",",
"key",
")",
":",
"return",
"self",
".",
"keyOrder",
".",
"index",
"(",
"key",
")"
] | [
117,
4
] | [
119,
39
] | python | en | ['en', 'en', 'en'] | True |
OrderedDict.index_for_location | (self, location) | Return index or None for a given location. | Return index or None for a given location. | def index_for_location(self, location):
""" Return index or None for a given location. """
if location == '_begin':
i = 0
elif location == '_end':
i = None
elif location.startswith('<') or location.startswith('>'):
i = self.index(location[1:])
... | [
"def",
"index_for_location",
"(",
"self",
",",
"location",
")",
":",
"if",
"location",
"==",
"'_begin'",
":",
"i",
"=",
"0",
"elif",
"location",
"==",
"'_end'",
":",
"i",
"=",
"None",
"elif",
"location",
".",
"startswith",
"(",
"'<'",
")",
"or",
"locat... | [
121,
4
] | [
138,
16
] | python | en | ['en', 'en', 'en'] | True |
OrderedDict.add | (self, key, value, location) | Insert by key location. | Insert by key location. | def add(self, key, value, location):
""" Insert by key location. """
i = self.index_for_location(location)
if i is not None:
self.insert(i, key, value)
else:
self.__setitem__(key, value) | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"value",
",",
"location",
")",
":",
"i",
"=",
"self",
".",
"index_for_location",
"(",
"location",
")",
"if",
"i",
"is",
"not",
"None",
":",
"self",
".",
"insert",
"(",
"i",
",",
"key",
",",
"value",
")"... | [
140,
4
] | [
146,
40
] | python | en | ['en', 'ru-Latn', 'en'] | True |
OrderedDict.link | (self, key, location) | Change location of an existing item. | Change location of an existing item. | def link(self, key, location):
""" Change location of an existing item. """
n = self.keyOrder.index(key)
del self.keyOrder[n]
i = self.index_for_location(location)
try:
if i is not None:
self.keyOrder.insert(i, key)
else:
se... | [
"def",
"link",
"(",
"self",
",",
"key",
",",
"location",
")",
":",
"n",
"=",
"self",
".",
"keyOrder",
".",
"index",
"(",
"key",
")",
"del",
"self",
".",
"keyOrder",
"[",
"n",
"]",
"i",
"=",
"self",
".",
"index_for_location",
"(",
"location",
")",
... | [
148,
4
] | [
161,
23
] | python | en | ['en', 'en', 'en'] | True |
single_line | (text) | Quick utility to make comparing template output easier. | Quick utility to make comparing template output easier. | def single_line(text):
"""Quick utility to make comparing template output easier."""
return re.sub(' +',
' ',
normalize_newlines(text).replace('\n', '')).strip() | [
"def",
"single_line",
"(",
"text",
")",
":",
"return",
"re",
".",
"sub",
"(",
"' +'",
",",
"' '",
",",
"normalize_newlines",
"(",
"text",
")",
".",
"replace",
"(",
"'\\n'",
",",
"''",
")",
")",
".",
"strip",
"(",
")"
] | [
33,
0
] | [
37,
69
] | python | en | ['en', 'en', 'en'] | True |
TemplateTagTests.render_template | (self, template_text, tag_require='', context=None) | Render a Custom Template to string. | Render a Custom Template to string. | def render_template(self, template_text, tag_require='', context=None):
"""Render a Custom Template to string."""
context = context or {}
template = Template("{%% load %s %%} %s"
% (tag_require, template_text))
return template.render(Context(context)) | [
"def",
"render_template",
"(",
"self",
",",
"template_text",
",",
"tag_require",
"=",
"''",
",",
"context",
"=",
"None",
")",
":",
"context",
"=",
"context",
"or",
"{",
"}",
"template",
"=",
"Template",
"(",
"\"{%% load %s %%} %s\"",
"%",
"(",
"tag_require",... | [
46,
4
] | [
51,
48
] | python | en | ['en', 'en', 'en'] | True |
TemplateTagTests.test_site_branding_tag | (self) | Test if site_branding tag renders the correct setting. | Test if site_branding tag renders the correct setting. | def test_site_branding_tag(self):
"""Test if site_branding tag renders the correct setting."""
rendered_str = self.render_template_tag("site_branding", "branding")
self.assertEqual(settings.SITE_BRANDING, rendered_str.strip(),
"tag site_branding renders %s" % rendered_st... | [
"def",
"test_site_branding_tag",
"(",
"self",
")",
":",
"rendered_str",
"=",
"self",
".",
"render_template_tag",
"(",
"\"site_branding\"",
",",
"\"branding\"",
")",
"self",
".",
"assertEqual",
"(",
"settings",
".",
"SITE_BRANDING",
",",
"rendered_str",
".",
"strip... | [
53,
4
] | [
57,
79
] | python | en | ['en', 'en', 'en'] | True |
message_cache_items | (items_for_remote_cache: Dict[str, Tuple[bytes]], message: Message) |
Note: this code is untested, and the caller has been
commented out for a while.
|
Note: this code is untested, and the caller has been
commented out for a while.
| def message_cache_items(items_for_remote_cache: Dict[str, Tuple[bytes]], message: Message) -> None:
"""
Note: this code is untested, and the caller has been
commented out for a while.
"""
key = to_dict_cache_key_id(message.id)
value = MessageDict.to_dict_uncached([message])[message.id]
items... | [
"def",
"message_cache_items",
"(",
"items_for_remote_cache",
":",
"Dict",
"[",
"str",
",",
"Tuple",
"[",
"bytes",
"]",
"]",
",",
"message",
":",
"Message",
")",
"->",
"None",
":",
"key",
"=",
"to_dict_cache_key_id",
"(",
"message",
".",
"id",
")",
"value",... | [
49,
0
] | [
56,
42
] | python | en | ['en', 'error', 'th'] | False |
get_active_realm_ids | () | For installations like Zulip Cloud hosting a lot of realms, it only makes
sense to do cache-filling work for realms that have any currently
active users/clients. Otherwise, we end up with every single-user
trial organization that has ever been created costing us N streams
worth of cache work (where N i... | For installations like Zulip Cloud hosting a lot of realms, it only makes
sense to do cache-filling work for realms that have any currently
active users/clients. Otherwise, we end up with every single-user
trial organization that has ever been created costing us N streams
worth of cache work (where N i... | def get_active_realm_ids() -> List[int]:
"""For installations like Zulip Cloud hosting a lot of realms, it only makes
sense to do cache-filling work for realms that have any currently
active users/clients. Otherwise, we end up with every single-user
trial organization that has ever been created costing... | [
"def",
"get_active_realm_ids",
"(",
")",
"->",
"List",
"[",
"int",
"]",
":",
"date",
"=",
"timezone_now",
"(",
")",
"-",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"2",
")",
"return",
"(",
"RealmCount",
".",
"objects",
".",
"filter",
"(",
"end_tim... | [
93,
0
] | [
106,
5
] | python | en | ['en', 'en', 'en'] | True |
CharDistributionAnalysis.reset | (self) | reset analyser, clear any state | reset analyser, clear any state | def reset(self):
"""reset analyser, clear any state"""
# If this flag is set to True, detection is done and conclusion has
# been made
self._done = False
self._total_chars = 0 # Total characters encountered
# The number of characters whose frequency order is less than 51... | [
"def",
"reset",
"(",
"self",
")",
":",
"# If this flag is set to True, detection is done and conclusion has",
"# been made",
"self",
".",
"_done",
"=",
"False",
"self",
".",
"_total_chars",
"=",
"0",
"# Total characters encountered",
"# The number of characters whose frequency ... | [
60,
4
] | [
67,
28
] | python | en | ['en', 'en', 'en'] | True |
CharDistributionAnalysis.feed | (self, char, char_len) | feed a character with known length | feed a character with known length | def feed(self, char, char_len):
"""feed a character with known length"""
if char_len == 2:
# we only care about 2-bytes character in our distribution analysis
order = self.get_order(char)
else:
order = -1
if order >= 0:
self._total_chars +=... | [
"def",
"feed",
"(",
"self",
",",
"char",
",",
"char_len",
")",
":",
"if",
"char_len",
"==",
"2",
":",
"# we only care about 2-bytes character in our distribution analysis",
"order",
"=",
"self",
".",
"get_order",
"(",
"char",
")",
"else",
":",
"order",
"=",
"-... | [
69,
4
] | [
81,
41
] | python | en | ['en', 'en', 'en'] | True |
CharDistributionAnalysis.get_confidence | (self) | return confidence based on existing data | return confidence based on existing data | def get_confidence(self):
"""return confidence based on existing data"""
# if we didn't receive any character in our consideration range,
# return negative answer
if self._total_chars <= 0 or self._freq_chars <= self.MINIMUM_DATA_THRESHOLD:
return self.SURE_NO
if sel... | [
"def",
"get_confidence",
"(",
"self",
")",
":",
"# if we didn't receive any character in our consideration range,",
"# return negative answer",
"if",
"self",
".",
"_total_chars",
"<=",
"0",
"or",
"self",
".",
"_freq_chars",
"<=",
"self",
".",
"MINIMUM_DATA_THRESHOLD",
":"... | [
83,
4
] | [
97,
28
] | python | en | ['en', 'zu', 'en'] | True |
Link.__init__ | (
self,
url, # type: str
comes_from=None, # type: Optional[Union[str, HTMLPage]]
requires_python=None, # type: Optional[str]
yanked_reason=None, # type: Optional[Text]
cache_link_parsing=True, # type: bool
) |
:param url: url of the resource pointed to (href of the link)
:param comes_from: instance of HTMLPage where the link was found,
or string.
:param requires_python: String containing the `Requires-Python`
metadata field, specified in PEP 345. This may be specified by
... |
:param url: url of the resource pointed to (href of the link)
:param comes_from: instance of HTMLPage where the link was found,
or string.
:param requires_python: String containing the `Requires-Python`
metadata field, specified in PEP 345. This may be specified by
... | def __init__(
self,
url, # type: str
comes_from=None, # type: Optional[Union[str, HTMLPage]]
requires_python=None, # type: Optional[str]
yanked_reason=None, # type: Optional[Text]
cache_link_parsing=True, # type: bool
):
# type: (.... | [
"def",
"__init__",
"(",
"self",
",",
"url",
",",
"# type: str",
"comes_from",
"=",
"None",
",",
"# type: Optional[Union[str, HTMLPage]]",
"requires_python",
"=",
"None",
",",
"# type: Optional[str]",
"yanked_reason",
"=",
"None",
",",
"# type: Optional[Text]",
"cache_li... | [
35,
4
] | [
80,
52
] | python | en | ['en', 'error', 'th'] | False |
Link.netloc | (self) |
This can contain auth information.
|
This can contain auth information.
| def netloc(self):
# type: () -> str
"""
This can contain auth information.
"""
return self._parsed_url.netloc | [
"def",
"netloc",
"(",
"self",
")",
":",
"# type: () -> str",
"return",
"self",
".",
"_parsed_url",
".",
"netloc"
] | [
130,
4
] | [
135,
38
] | python | en | ['en', 'error', 'th'] | False |
Link.is_hash_allowed | (self, hashes) |
Return True if the link has a hash and it is allowed.
|
Return True if the link has a hash and it is allowed.
| def is_hash_allowed(self, hashes):
# type: (Optional[Hashes]) -> bool
"""
Return True if the link has a hash and it is allowed.
"""
if hashes is None or not self.has_hash:
return False
# Assert non-None so mypy knows self.hash_name and self.hash are str.
... | [
"def",
"is_hash_allowed",
"(",
"self",
",",
"hashes",
")",
":",
"# type: (Optional[Hashes]) -> bool",
"if",
"hashes",
"is",
"None",
"or",
"not",
"self",
".",
"has_hash",
":",
"return",
"False",
"# Assert non-None so mypy knows self.hash_name and self.hash are str.",
"asse... | [
233,
4
] | [
244,
75
] | python | en | ['en', 'error', 'th'] | False |
HelperMixin.helper | (self) |
Возвращает помощника
|
Возвращает помощника
| def helper(self):
"""
Возвращает помощника
"""
return self._helper | [
"def",
"helper",
"(",
"self",
")",
":",
"return",
"self",
".",
"_helper"
] | [
27,
4
] | [
31,
27
] | python | en | ['en', 'error', 'th'] | False |
HelperMixin._prepare_helper_class | (self) |
Возвращает класс помощника
|
Возвращает класс помощника
| def _prepare_helper_class(self) -> Union[Type[BaseHelper], Type[BaseFunctionHelper]]:
"""
Возвращает класс помощника
"""
return BaseHelper | [
"def",
"_prepare_helper_class",
"(",
"self",
")",
"->",
"Union",
"[",
"Type",
"[",
"BaseHelper",
"]",
",",
"Type",
"[",
"BaseFunctionHelper",
"]",
"]",
":",
"return",
"BaseHelper"
] | [
33,
4
] | [
37,
25
] | python | en | ['en', 'error', 'th'] | False |
HelperMixin._prepare_helper | (self, *args, **kwargs) |
Точка расширения для создания помощника.
|
Точка расширения для создания помощника.
| def _prepare_helper(self, *args, **kwargs):
"""
Точка расширения для создания помощника.
"""
helper_class = self._prepare_helper_class()
if issubclass(helper_class, (BaseHelper, BaseFunctionHelper)):
helper = helper_class(*args, **kwargs)
else:
he... | [
"def",
"_prepare_helper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"helper_class",
"=",
"self",
".",
"_prepare_helper_class",
"(",
")",
"if",
"issubclass",
"(",
"helper_class",
",",
"(",
"BaseHelper",
",",
"BaseFunctionHelper",
")",
... | [
39,
4
] | [
50,
21
] | python | en | ['en', 'error', 'th'] | False |
ValidatorMixin._prepare_validator_class | (self) |
Возвращает класс валидатор
|
Возвращает класс валидатор
| def _prepare_validator_class(self) -> Type[BaseValidator]:
"""
Возвращает класс валидатор
"""
return BaseValidator | [
"def",
"_prepare_validator_class",
"(",
"self",
")",
"->",
"Type",
"[",
"BaseValidator",
"]",
":",
"return",
"BaseValidator"
] | [
64,
4
] | [
68,
28
] | python | en | ['en', 'error', 'th'] | False |
ValidatorMixin._prepare_validator | (self, *args, **kwargs) |
Точка расширения для создания валидатора
|
Точка расширения для создания валидатора
| def _prepare_validator(self, *args, **kwargs):
"""
Точка расширения для создания валидатора
"""
validator_class = self._prepare_validator_class()
if issubclass(validator_class, BaseValidator):
validator = validator_class(*args, **kwargs)
else:
val... | [
"def",
"_prepare_validator",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"validator_class",
"=",
"self",
".",
"_prepare_validator_class",
"(",
")",
"if",
"issubclass",
"(",
"validator_class",
",",
"BaseValidator",
")",
":",
"validator",
... | [
70,
4
] | [
81,
24
] | python | en | ['en', 'error', 'th'] | False |
ValidatorMixin.before_validate | (self) |
Расширение поведения запускаемого объекта перед запуском проверок
|
Расширение поведения запускаемого объекта перед запуском проверок
| def before_validate(self):
"""
Расширение поведения запускаемого объекта перед запуском проверок
""" | [
"def",
"before_validate",
"(",
"self",
")",
":"
] | [
83,
4
] | [
86,
11
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.