partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | get_members | Return the members of mod of the given type
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param mod: the module with members
:type mod: module
:param typ: the typ, ``'class'``, ``'function'``, ``'exception'``, ``'data'``, ``'members'``
:type typ: str
:param inclu... | src/jinjaapidoc/gendoc.py | def get_members(app, mod, typ, include_public=None):
"""Return the members of mod of the given type
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param mod: the module with members
:type mod: module
:param typ: the typ, ``'class'``, ``'function'``, ``'exception'``, `... | def get_members(app, mod, typ, include_public=None):
"""Return the members of mod of the given type
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param mod: the module with members
:type mod: module
:param typ: the typ, ``'class'``, ``'function'``, ``'exception'``, `... | [
"Return",
"the",
"members",
"of",
"mod",
"of",
"the",
"given",
"type"
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L170-L218 | [
"def",
"get_members",
"(",
"app",
",",
"mod",
",",
"typ",
",",
"include_public",
"=",
"None",
")",
":",
"def",
"include_here",
"(",
"x",
")",
":",
"\"\"\"Return true if the member should be included in mod.\n\n A member will be included if it is declared in this module... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | _get_submodules | Get all submodules for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of module names and boolean whether its a package
:rtype: list
:raises: TypeEr... | src/jinjaapidoc/gendoc.py | def _get_submodules(app, module):
"""Get all submodules for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of module names and boolean whether its a pac... | def _get_submodules(app, module):
"""Get all submodules for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of module names and boolean whether its a pac... | [
"Get",
"all",
"submodules",
"for",
"the",
"given",
"module",
"/",
"package"
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L221-L244 | [
"def",
"_get_submodules",
"(",
"app",
",",
"module",
")",
":",
"if",
"inspect",
".",
"ismodule",
"(",
"module",
")",
":",
"if",
"hasattr",
"(",
"module",
",",
"'__path__'",
")",
":",
"p",
"=",
"module",
".",
"__path__",
"else",
":",
"return",
"[",
"]... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | get_submodules | Get all submodules without packages for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of module names excluding packages
:rtype: list
:raises: Type... | src/jinjaapidoc/gendoc.py | def get_submodules(app, module):
"""Get all submodules without packages for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of module names excluding pac... | def get_submodules(app, module):
"""Get all submodules without packages for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of module names excluding pac... | [
"Get",
"all",
"submodules",
"without",
"packages",
"for",
"the",
"given",
"module",
"/",
"package"
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L247-L259 | [
"def",
"get_submodules",
"(",
"app",
",",
"module",
")",
":",
"submodules",
"=",
"_get_submodules",
"(",
"app",
",",
"module",
")",
"return",
"[",
"name",
"for",
"name",
",",
"ispkg",
"in",
"submodules",
"if",
"not",
"ispkg",
"]"
] | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | get_subpackages | Get all subpackages for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of packages names
:rtype: list
:raises: TypeError | src/jinjaapidoc/gendoc.py | def get_subpackages(app, module):
"""Get all subpackages for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of packages names
:rtype: list
:rais... | def get_subpackages(app, module):
"""Get all subpackages for the given module/package
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module to query or module path
:type module: module | str
:returns: list of packages names
:rtype: list
:rais... | [
"Get",
"all",
"subpackages",
"for",
"the",
"given",
"module",
"/",
"package"
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L262-L274 | [
"def",
"get_subpackages",
"(",
"app",
",",
"module",
")",
":",
"submodules",
"=",
"_get_submodules",
"(",
"app",
",",
"module",
")",
"return",
"[",
"name",
"for",
"name",
",",
"ispkg",
"in",
"submodules",
"if",
"ispkg",
"]"
] | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | get_context | Return a dict for template rendering
Variables:
* :package: The top package
* :module: the module
* :fullname: package.module
* :subpkgs: packages beneath module
* :submods: modules beneath module
* :classes: public classes in module
* :allclasses: public and private clas... | src/jinjaapidoc/gendoc.py | def get_context(app, package, module, fullname):
"""Return a dict for template rendering
Variables:
* :package: The top package
* :module: the module
* :fullname: package.module
* :subpkgs: packages beneath module
* :submods: modules beneath module
* :classes: public classe... | def get_context(app, package, module, fullname):
"""Return a dict for template rendering
Variables:
* :package: The top package
* :module: the module
* :fullname: package.module
* :subpkgs: packages beneath module
* :submods: modules beneath module
* :classes: public classe... | [
"Return",
"a",
"dict",
"for",
"template",
"rendering"
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L277-L330 | [
"def",
"get_context",
"(",
"app",
",",
"package",
",",
"module",
",",
"fullname",
")",
":",
"var",
"=",
"{",
"'package'",
":",
"package",
",",
"'module'",
":",
"module",
",",
"'fullname'",
":",
"fullname",
"}",
"logger",
".",
"debug",
"(",
"'Creating con... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | create_module_file | Build the text of the file and write the file.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment for the templates
:type env: :class:`jinja2.Environment`
:param package: the package name
:type package: :class:`str`
:param module: the ... | src/jinjaapidoc/gendoc.py | def create_module_file(app, env, package, module, dest, suffix, dryrun, force):
"""Build the text of the file and write the file.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment for the templates
:type env: :class:`jinja2.Environment`
:... | def create_module_file(app, env, package, module, dest, suffix, dryrun, force):
"""Build the text of the file and write the file.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment for the templates
:type env: :class:`jinja2.Environment`
:... | [
"Build",
"the",
"text",
"of",
"the",
"file",
"and",
"write",
"the",
"file",
"."
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L333-L362 | [
"def",
"create_module_file",
"(",
"app",
",",
"env",
",",
"package",
",",
"module",
",",
"dest",
",",
"suffix",
",",
"dryrun",
",",
"force",
")",
":",
"logger",
".",
"debug",
"(",
"'Create module file: package %s, module %s'",
",",
"package",
",",
"module",
... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | create_package_file | Build the text of the file and write the file.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment for the templates
:type env: :class:`jinja2.Environment`
:param root_package: the parent package
:type root_package: :class:`str`
:param ... | src/jinjaapidoc/gendoc.py | def create_package_file(app, env, root_package, sub_package, private,
dest, suffix, dryrun, force):
"""Build the text of the file and write the file.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment for the templates
... | def create_package_file(app, env, root_package, sub_package, private,
dest, suffix, dryrun, force):
"""Build the text of the file and write the file.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment for the templates
... | [
"Build",
"the",
"text",
"of",
"the",
"file",
"and",
"write",
"the",
"file",
"."
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L365-L401 | [
"def",
"create_package_file",
"(",
"app",
",",
"env",
",",
"root_package",
",",
"sub_package",
",",
"private",
",",
"dest",
",",
"suffix",
",",
"dryrun",
",",
"force",
")",
":",
"logger",
".",
"debug",
"(",
"'Create package file: rootpackage %s, sub_package %s'",
... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | shall_skip | Check if we want to skip this module.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module name
:type module: :class:`str`
:param private: True, if privates are allowed
:type private: :class:`bool` | src/jinjaapidoc/gendoc.py | def shall_skip(app, module, private):
"""Check if we want to skip this module.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module name
:type module: :class:`str`
:param private: True, if privates are allowed
:type private: :class:`bool`
""... | def shall_skip(app, module, private):
"""Check if we want to skip this module.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param module: the module name
:type module: :class:`str`
:param private: True, if privates are allowed
:type private: :class:`bool`
""... | [
"Check",
"if",
"we",
"want",
"to",
"skip",
"this",
"module",
"."
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L404-L421 | [
"def",
"shall_skip",
"(",
"app",
",",
"module",
",",
"private",
")",
":",
"logger",
".",
"debug",
"(",
"'Testing if %s should be skipped.'",
",",
"module",
")",
"# skip if it has a \"private\" name and this is selected",
"if",
"module",
"!=",
"'__init__.py'",
"and",
"... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | recurse_tree | Look for every file in the directory tree and create the corresponding
ReST files.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment
:type env: :class:`jinja2.Environment`
:param src: the path to the python source files
:type src: :cl... | src/jinjaapidoc/gendoc.py | def recurse_tree(app, env, src, dest, excludes, followlinks, force, dryrun, private, suffix):
"""Look for every file in the directory tree and create the corresponding
ReST files.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment
:type en... | def recurse_tree(app, env, src, dest, excludes, followlinks, force, dryrun, private, suffix):
"""Look for every file in the directory tree and create the corresponding
ReST files.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param env: the jinja environment
:type en... | [
"Look",
"for",
"every",
"file",
"in",
"the",
"directory",
"tree",
"and",
"create",
"the",
"corresponding",
"ReST",
"files",
"."
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L424-L495 | [
"def",
"recurse_tree",
"(",
"app",
",",
"env",
",",
"src",
",",
"dest",
",",
"excludes",
",",
"followlinks",
",",
"force",
",",
"dryrun",
",",
"private",
",",
"suffix",
")",
":",
"# check if the base directory is a package and get its name",
"if",
"INITPY",
"in"... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | normalize_excludes | Normalize the excluded directory list. | src/jinjaapidoc/gendoc.py | def normalize_excludes(excludes):
"""Normalize the excluded directory list."""
return [os.path.normpath(os.path.abspath(exclude)) for exclude in excludes] | def normalize_excludes(excludes):
"""Normalize the excluded directory list."""
return [os.path.normpath(os.path.abspath(exclude)) for exclude in excludes] | [
"Normalize",
"the",
"excluded",
"directory",
"list",
"."
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L498-L500 | [
"def",
"normalize_excludes",
"(",
"excludes",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"exclude",
")",
")",
"for",
"exclude",
"in",
"excludes",
"]"
] | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | is_excluded | Check if the directory is in the exclude list.
Note: by having trailing slashes, we avoid common prefix issues, like
e.g. an exlude "foo" also accidentally excluding "foobar". | src/jinjaapidoc/gendoc.py | def is_excluded(root, excludes):
"""Check if the directory is in the exclude list.
Note: by having trailing slashes, we avoid common prefix issues, like
e.g. an exlude "foo" also accidentally excluding "foobar".
"""
root = os.path.normpath(root)
for exclude in excludes:
if root ==... | def is_excluded(root, excludes):
"""Check if the directory is in the exclude list.
Note: by having trailing slashes, we avoid common prefix issues, like
e.g. an exlude "foo" also accidentally excluding "foobar".
"""
root = os.path.normpath(root)
for exclude in excludes:
if root ==... | [
"Check",
"if",
"the",
"directory",
"is",
"in",
"the",
"exclude",
"list",
"."
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L503-L513 | [
"def",
"is_excluded",
"(",
"root",
",",
"excludes",
")",
":",
"root",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"root",
")",
"for",
"exclude",
"in",
"excludes",
":",
"if",
"root",
"==",
"exclude",
":",
"return",
"True",
"return",
"False"
] | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | generate | Generage the rst files
Raises an :class:`OSError` if the source path is not a directory.
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:param src: path to python source files
:type src: :class:`str`
:param dest: output directory
:type dest: :class:`str`
:para... | src/jinjaapidoc/gendoc.py | def generate(app, src, dest, exclude=[], followlinks=False,
force=False, dryrun=False, private=False, suffix='rst',
template_dirs=None):
"""Generage the rst files
Raises an :class:`OSError` if the source path is not a directory.
:param app: the sphinx app
:type app: :class:`s... | def generate(app, src, dest, exclude=[], followlinks=False,
force=False, dryrun=False, private=False, suffix='rst',
template_dirs=None):
"""Generage the rst files
Raises an :class:`OSError` if the source path is not a directory.
:param app: the sphinx app
:type app: :class:`s... | [
"Generage",
"the",
"rst",
"files"
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L516-L556 | [
"def",
"generate",
"(",
"app",
",",
"src",
",",
"dest",
",",
"exclude",
"=",
"[",
"]",
",",
"followlinks",
"=",
"False",
",",
"force",
"=",
"False",
",",
"dryrun",
"=",
"False",
",",
"private",
"=",
"False",
",",
"suffix",
"=",
"'rst'",
",",
"templ... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | main | Parse the config of the app and initiate the generation process
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:returns: None
:rtype: None
:raises: None | src/jinjaapidoc/gendoc.py | def main(app):
"""Parse the config of the app and initiate the generation process
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:returns: None
:rtype: None
:raises: None
"""
c = app.config
src = c.jinjaapi_srcdir
if not src:
return
suffix... | def main(app):
"""Parse the config of the app and initiate the generation process
:param app: the sphinx app
:type app: :class:`sphinx.application.Sphinx`
:returns: None
:rtype: None
:raises: None
"""
c = app.config
src = c.jinjaapi_srcdir
if not src:
return
suffix... | [
"Parse",
"the",
"config",
"of",
"the",
"app",
"and",
"initiate",
"the",
"generation",
"process"
] | storax/jinjaapidoc | python | https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/gendoc.py#L559-L593 | [
"def",
"main",
"(",
"app",
")",
":",
"c",
"=",
"app",
".",
"config",
"src",
"=",
"c",
".",
"jinjaapi_srcdir",
"if",
"not",
"src",
":",
"return",
"suffix",
"=",
"\"rst\"",
"out",
"=",
"c",
".",
"jinjaapi_outputdir",
"or",
"app",
".",
"env",
".",
"sr... | f1eeb6ab5bd1a96c4130306718c6423f37c76856 |
train | _isclose | Return floating point equality. | pmisc/number.py | def _isclose(obja, objb, rtol=1e-05, atol=1e-08):
"""Return floating point equality."""
return abs(obja - objb) <= (atol + rtol * abs(objb)) | def _isclose(obja, objb, rtol=1e-05, atol=1e-08):
"""Return floating point equality."""
return abs(obja - objb) <= (atol + rtol * abs(objb)) | [
"Return",
"floating",
"point",
"equality",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/number.py#L19-L21 | [
"def",
"_isclose",
"(",
"obja",
",",
"objb",
",",
"rtol",
"=",
"1e-05",
",",
"atol",
"=",
"1e-08",
")",
":",
"return",
"abs",
"(",
"obja",
"-",
"objb",
")",
"<=",
"(",
"atol",
"+",
"rtol",
"*",
"abs",
"(",
"objb",
")",
")"
] | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | _isreal | Determine if an object is a real number.
Both Python standard data types and Numpy data types are supported.
:param obj: Object
:type obj: any
:rtype: boolean | pmisc/number.py | def _isreal(obj):
"""
Determine if an object is a real number.
Both Python standard data types and Numpy data types are supported.
:param obj: Object
:type obj: any
:rtype: boolean
"""
# pylint: disable=W0702
if (obj is None) or isinstance(obj, bool):
return False
try... | def _isreal(obj):
"""
Determine if an object is a real number.
Both Python standard data types and Numpy data types are supported.
:param obj: Object
:type obj: any
:rtype: boolean
"""
# pylint: disable=W0702
if (obj is None) or isinstance(obj, bool):
return False
try... | [
"Determine",
"if",
"an",
"object",
"is",
"a",
"real",
"number",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/number.py#L24-L42 | [
"def",
"_isreal",
"(",
"obj",
")",
":",
"# pylint: disable=W0702",
"if",
"(",
"obj",
"is",
"None",
")",
"or",
"isinstance",
"(",
"obj",
",",
"bool",
")",
":",
"return",
"False",
"try",
":",
"cond",
"=",
"(",
"int",
"(",
"obj",
")",
"==",
"obj",
")"... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | _no_exp | r"""
Convert a number to a string without using scientific notation.
:param number: Number to convert
:type number: integer or float
:rtype: string
:raises: RuntimeError (Argument \`number\` is not valid) | pmisc/number.py | def _no_exp(number):
r"""
Convert a number to a string without using scientific notation.
:param number: Number to convert
:type number: integer or float
:rtype: string
:raises: RuntimeError (Argument \`number\` is not valid)
"""
if isinstance(number, bool) or (not isinstance(number,... | def _no_exp(number):
r"""
Convert a number to a string without using scientific notation.
:param number: Number to convert
:type number: integer or float
:rtype: string
:raises: RuntimeError (Argument \`number\` is not valid)
"""
if isinstance(number, bool) or (not isinstance(number,... | [
"r",
"Convert",
"a",
"number",
"to",
"a",
"string",
"without",
"using",
"scientific",
"notation",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/number.py#L45-L70 | [
"def",
"_no_exp",
"(",
"number",
")",
":",
"if",
"isinstance",
"(",
"number",
",",
"bool",
")",
"or",
"(",
"not",
"isinstance",
"(",
"number",
",",
"(",
"int",
",",
"float",
")",
")",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `number` is not va... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | _to_scientific_tuple | r"""
Return mantissa and exponent of a number expressed in scientific notation.
Full precision is maintained if the number is represented as a string.
:param number: Number
:type number: integer, float or string
:rtype: Tuple whose first item is the mantissa (*string*) and the second
... | pmisc/number.py | def _to_scientific_tuple(number):
r"""
Return mantissa and exponent of a number expressed in scientific notation.
Full precision is maintained if the number is represented as a string.
:param number: Number
:type number: integer, float or string
:rtype: Tuple whose first item is the mantissa... | def _to_scientific_tuple(number):
r"""
Return mantissa and exponent of a number expressed in scientific notation.
Full precision is maintained if the number is represented as a string.
:param number: Number
:type number: integer, float or string
:rtype: Tuple whose first item is the mantissa... | [
"r",
"Return",
"mantissa",
"and",
"exponent",
"of",
"a",
"number",
"expressed",
"in",
"scientific",
"notation",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/number.py#L73-L113 | [
"def",
"_to_scientific_tuple",
"(",
"number",
")",
":",
"# pylint: disable=W0632",
"if",
"isinstance",
"(",
"number",
",",
"bool",
")",
"or",
"(",
"not",
"isinstance",
"(",
"number",
",",
"(",
"int",
",",
"float",
",",
"str",
")",
")",
")",
":",
"raise",... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | gcd | Calculate the greatest common divisor (GCD) of a sequence of numbers.
The sequence can be a list of numbers or a Numpy vector of numbers. The
computations are carried out with a precision of 1E-12 if the objects are
not `fractions <https://docs.python.org/3/library/fractions.html>`_. When
possible it i... | pmisc/number.py | def gcd(vector):
"""
Calculate the greatest common divisor (GCD) of a sequence of numbers.
The sequence can be a list of numbers or a Numpy vector of numbers. The
computations are carried out with a precision of 1E-12 if the objects are
not `fractions <https://docs.python.org/3/library/fractions.ht... | def gcd(vector):
"""
Calculate the greatest common divisor (GCD) of a sequence of numbers.
The sequence can be a list of numbers or a Numpy vector of numbers. The
computations are carried out with a precision of 1E-12 if the objects are
not `fractions <https://docs.python.org/3/library/fractions.ht... | [
"Calculate",
"the",
"greatest",
"common",
"divisor",
"(",
"GCD",
")",
"of",
"a",
"sequence",
"of",
"numbers",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/number.py#L116-L141 | [
"def",
"gcd",
"(",
"vector",
")",
":",
"# pylint: disable=C1801",
"if",
"not",
"len",
"(",
"vector",
")",
":",
"return",
"None",
"if",
"len",
"(",
"vector",
")",
"==",
"1",
":",
"return",
"vector",
"[",
"0",
"]",
"if",
"len",
"(",
"vector",
")",
"=... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | normalize | r"""
Scale a value to the range defined by a series.
:param value: Value to normalize
:type value: number
:param series: List of numbers that defines the normalization range
:type series: list
:param offset: Normalization offset, i.e. the returned value will be in
the ran... | pmisc/number.py | def normalize(value, series, offset=0):
r"""
Scale a value to the range defined by a series.
:param value: Value to normalize
:type value: number
:param series: List of numbers that defines the normalization range
:type series: list
:param offset: Normalization offset, i.e. the returned... | def normalize(value, series, offset=0):
r"""
Scale a value to the range defined by a series.
:param value: Value to normalize
:type value: number
:param series: List of numbers that defines the normalization range
:type series: list
:param offset: Normalization offset, i.e. the returned... | [
"r",
"Scale",
"a",
"value",
"to",
"the",
"range",
"defined",
"by",
"a",
"series",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/number.py#L144-L197 | [
"def",
"normalize",
"(",
"value",
",",
"series",
",",
"offset",
"=",
"0",
")",
":",
"if",
"not",
"_isreal",
"(",
"value",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `value` is not valid\"",
")",
"if",
"not",
"_isreal",
"(",
"offset",
")",
":",
"... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | per | r"""
Calculate percentage difference between numbers.
If only two numbers are given, the percentage difference between them is
computed. If two sequences of numbers are given (either two lists of
numbers or Numpy vectors), the element-wise percentage difference is
computed. If any of the numbers in... | pmisc/number.py | def per(arga, argb, prec=10):
r"""
Calculate percentage difference between numbers.
If only two numbers are given, the percentage difference between them is
computed. If two sequences of numbers are given (either two lists of
numbers or Numpy vectors), the element-wise percentage difference is
... | def per(arga, argb, prec=10):
r"""
Calculate percentage difference between numbers.
If only two numbers are given, the percentage difference between them is
computed. If two sequences of numbers are given (either two lists of
numbers or Numpy vectors), the element-wise percentage difference is
... | [
"r",
"Calculate",
"percentage",
"difference",
"between",
"numbers",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/number.py#L200-L274 | [
"def",
"per",
"(",
"arga",
",",
"argb",
",",
"prec",
"=",
"10",
")",
":",
"# pylint: disable=C0103,C0200,E1101,R0204",
"if",
"not",
"isinstance",
"(",
"prec",
",",
"int",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `prec` is not valid\"",
")",
"a_type",
... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | pgcd | Calculate the greatest common divisor (GCD) of two numbers.
:param numa: First number
:type numa: number
:param numb: Second number
:type numb: number
:rtype: number
For example:
>>> import pmisc, fractions
>>> pmisc.pgcd(10, 15)
5
>>> str(pmisc.pgcd(0.05, ... | pmisc/number.py | def pgcd(numa, numb):
"""
Calculate the greatest common divisor (GCD) of two numbers.
:param numa: First number
:type numa: number
:param numb: Second number
:type numb: number
:rtype: number
For example:
>>> import pmisc, fractions
>>> pmisc.pgcd(10, 15)
5... | def pgcd(numa, numb):
"""
Calculate the greatest common divisor (GCD) of two numbers.
:param numa: First number
:type numa: number
:param numb: Second number
:type numb: number
:rtype: number
For example:
>>> import pmisc, fractions
>>> pmisc.pgcd(10, 15)
5... | [
"Calculate",
"the",
"greatest",
"common",
"divisor",
"(",
"GCD",
")",
"of",
"two",
"numbers",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/number.py#L277-L329 | [
"def",
"pgcd",
"(",
"numa",
",",
"numb",
")",
":",
"# Test for integers this way to be valid also for Numpy data types without",
"# actually importing (and package depending on) Numpy",
"int_args",
"=",
"(",
"int",
"(",
"numa",
")",
"==",
"numa",
")",
"and",
"(",
"int",
... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | SockMixin.connect_ws | Connect to a websocket
:channels: List of SockChannel instances | bors/api/websock.py | def connect_ws(self, post_connect_callback, channels, reconnect=False):
"""
Connect to a websocket
:channels: List of SockChannel instances
"""
self.post_conn_cb = post_connect_callback
self.channels = channels
self.wsendpoint = self.context["conf"]["endpoints"].... | def connect_ws(self, post_connect_callback, channels, reconnect=False):
"""
Connect to a websocket
:channels: List of SockChannel instances
"""
self.post_conn_cb = post_connect_callback
self.channels = channels
self.wsendpoint = self.context["conf"]["endpoints"].... | [
"Connect",
"to",
"a",
"websocket",
":",
"channels",
":",
"List",
"of",
"SockChannel",
"instances"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/websock.py#L10-L29 | [
"def",
"connect_ws",
"(",
"self",
",",
"post_connect_callback",
",",
"channels",
",",
"reconnect",
"=",
"False",
")",
":",
"self",
".",
"post_conn_cb",
"=",
"post_connect_callback",
"self",
".",
"channels",
"=",
"channels",
"self",
".",
"wsendpoint",
"=",
"sel... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | SockMixin.wscall | Submit a request on the websocket | bors/api/websock.py | def wscall(self, method, query=None, callback=None):
"""Submit a request on the websocket"""
if callback is None:
self.sock.emit(method, query)
else:
self.sock.emitack(method, query, callback) | def wscall(self, method, query=None, callback=None):
"""Submit a request on the websocket"""
if callback is None:
self.sock.emit(method, query)
else:
self.sock.emitack(method, query, callback) | [
"Submit",
"a",
"request",
"on",
"the",
"websocket"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/websock.py#L38-L43 | [
"def",
"wscall",
"(",
"self",
",",
"method",
",",
"query",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"if",
"callback",
"is",
"None",
":",
"self",
".",
"sock",
".",
"emit",
"(",
"method",
",",
"query",
")",
"else",
":",
"self",
".",
"so... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | SockMixin.connect_channels | Connect the provided channels | bors/api/websock.py | def connect_channels(self, channels):
"""Connect the provided channels"""
self.log.info(f"Connecting to channels...")
for chan in channels:
chan.connect(self.sock)
self.log.info(f"\t{chan.channel}") | def connect_channels(self, channels):
"""Connect the provided channels"""
self.log.info(f"Connecting to channels...")
for chan in channels:
chan.connect(self.sock)
self.log.info(f"\t{chan.channel}") | [
"Connect",
"the",
"provided",
"channels"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/websock.py#L45-L50 | [
"def",
"connect_channels",
"(",
"self",
",",
"channels",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"f\"Connecting to channels...\"",
")",
"for",
"chan",
"in",
"channels",
":",
"chan",
".",
"connect",
"(",
"self",
".",
"sock",
")",
"self",
".",
"log... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | SockMixin._on_set_auth | Set Auth request received from websocket | bors/api/websock.py | def _on_set_auth(self, sock, token):
"""Set Auth request received from websocket"""
self.log.info(f"Token received: {token}")
sock.setAuthtoken(token) | def _on_set_auth(self, sock, token):
"""Set Auth request received from websocket"""
self.log.info(f"Token received: {token}")
sock.setAuthtoken(token) | [
"Set",
"Auth",
"request",
"received",
"from",
"websocket"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/websock.py#L54-L57 | [
"def",
"_on_set_auth",
"(",
"self",
",",
"sock",
",",
"token",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"f\"Token received: {token}\"",
")",
"sock",
".",
"setAuthtoken",
"(",
"token",
")"
] | 38bf338fc6905d90819faa56bd832140116720f0 |
train | SockMixin._on_auth | Message received from websocket | bors/api/websock.py | def _on_auth(self, sock, authenticated): # pylint: disable=unused-argument
"""Message received from websocket"""
def ack(eventname, error, data): # pylint: disable=unused-argument
"""Ack"""
if error:
self.log.error(f"""OnAuth: {error}""")
else:
... | def _on_auth(self, sock, authenticated): # pylint: disable=unused-argument
"""Message received from websocket"""
def ack(eventname, error, data): # pylint: disable=unused-argument
"""Ack"""
if error:
self.log.error(f"""OnAuth: {error}""")
else:
... | [
"Message",
"received",
"from",
"websocket"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/websock.py#L59-L69 | [
"def",
"_on_auth",
"(",
"self",
",",
"sock",
",",
"authenticated",
")",
":",
"# pylint: disable=unused-argument",
"def",
"ack",
"(",
"eventname",
",",
"error",
",",
"data",
")",
":",
"# pylint: disable=unused-argument",
"\"\"\"Ack\"\"\"",
"if",
"error",
":",
"self... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | SockMixin._on_connect_error | Error received from websocket | bors/api/websock.py | def _on_connect_error(self, sock, err): # pylint: disable=unused-argument
"""Error received from websocket"""
if isinstance(err, SystemExit):
self.log.error(f"Shutting down websocket connection")
else:
self.log.error(f"Websocket error: {err}") | def _on_connect_error(self, sock, err): # pylint: disable=unused-argument
"""Error received from websocket"""
if isinstance(err, SystemExit):
self.log.error(f"Shutting down websocket connection")
else:
self.log.error(f"Websocket error: {err}") | [
"Error",
"received",
"from",
"websocket"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/websock.py#L75-L80 | [
"def",
"_on_connect_error",
"(",
"self",
",",
"sock",
",",
"err",
")",
":",
"# pylint: disable=unused-argument",
"if",
"isinstance",
"(",
"err",
",",
"SystemExit",
")",
":",
"self",
".",
"log",
".",
"error",
"(",
"f\"Shutting down websocket connection\"",
")",
"... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | SockChannel.connect | Attach a given socket to a channel | bors/api/websock.py | def connect(self, sock):
"""Attach a given socket to a channel"""
def cbwrap(*args, **kwargs):
"""Callback wrapper; passes in response_type"""
self.callback(self.response_type, *args, **kwargs)
self.sock = sock
self.sock.subscribe(self.channel)
self.sock.... | def connect(self, sock):
"""Attach a given socket to a channel"""
def cbwrap(*args, **kwargs):
"""Callback wrapper; passes in response_type"""
self.callback(self.response_type, *args, **kwargs)
self.sock = sock
self.sock.subscribe(self.channel)
self.sock.... | [
"Attach",
"a",
"given",
"socket",
"to",
"a",
"channel"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/websock.py#L96-L104 | [
"def",
"connect",
"(",
"self",
",",
"sock",
")",
":",
"def",
"cbwrap",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Callback wrapper; passes in response_type\"\"\"",
"self",
".",
"callback",
"(",
"self",
".",
"response_type",
",",
"*",
"args",... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | run_cmd | Run command `cmd`.
It's like that, and that's the way it is. | utlz/cmd.py | def run_cmd(cmd, input=None, timeout=30, max_try=3, num_try=1):
'''Run command `cmd`.
It's like that, and that's the way it is.
'''
if type(cmd) == str:
cmd = cmd.split()
process = subprocess.Popen(cmd,
stdin=open('/dev/null', 'r'),
... | def run_cmd(cmd, input=None, timeout=30, max_try=3, num_try=1):
'''Run command `cmd`.
It's like that, and that's the way it is.
'''
if type(cmd) == str:
cmd = cmd.split()
process = subprocess.Popen(cmd,
stdin=open('/dev/null', 'r'),
... | [
"Run",
"command",
"cmd",
"."
] | theno/utlz | python | https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/cmd.py#L22-L72 | [
"def",
"run_cmd",
"(",
"cmd",
",",
"input",
"=",
"None",
",",
"timeout",
"=",
"30",
",",
"max_try",
"=",
"3",
",",
"num_try",
"=",
"1",
")",
":",
"if",
"type",
"(",
"cmd",
")",
"==",
"str",
":",
"cmd",
"=",
"cmd",
".",
"split",
"(",
")",
"pro... | bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389 |
train | pop_first_arg | find first positional arg (does not start with -), take it out of array and return it separately
returns (arg, array) | facsimile/cli.py | def pop_first_arg(argv):
"""
find first positional arg (does not start with -), take it out of array and return it separately
returns (arg, array)
"""
for arg in argv:
if not arg.startswith('-'):
argv.remove(arg)
return (arg, argv)
return (None, argv) | def pop_first_arg(argv):
"""
find first positional arg (does not start with -), take it out of array and return it separately
returns (arg, array)
"""
for arg in argv:
if not arg.startswith('-'):
argv.remove(arg)
return (arg, argv)
return (None, argv) | [
"find",
"first",
"positional",
"arg",
"(",
"does",
"not",
"start",
"with",
"-",
")",
"take",
"it",
"out",
"of",
"array",
"and",
"return",
"it",
"separately",
"returns",
"(",
"arg",
"array",
")"
] | 20c/facsimile | python | https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/cli.py#L110-L120 | [
"def",
"pop_first_arg",
"(",
"argv",
")",
":",
"for",
"arg",
"in",
"argv",
":",
"if",
"not",
"arg",
".",
"startswith",
"(",
"'-'",
")",
":",
"argv",
".",
"remove",
"(",
"arg",
")",
"return",
"(",
"arg",
",",
"argv",
")",
"return",
"(",
"None",
",... | 570e28568475d5be1b1a2c95b8e941fbfbc167eb |
train | check_options | check options requirements, print and return exit value | facsimile/cli.py | def check_options(options, parser):
"""
check options requirements, print and return exit value
"""
if not options.get('release_environment', None):
print("release environment is required")
parser.print_help()
return os.EX_USAGE
return 0 | def check_options(options, parser):
"""
check options requirements, print and return exit value
"""
if not options.get('release_environment', None):
print("release environment is required")
parser.print_help()
return os.EX_USAGE
return 0 | [
"check",
"options",
"requirements",
"print",
"and",
"return",
"exit",
"value"
] | 20c/facsimile | python | https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/cli.py#L122-L131 | [
"def",
"check_options",
"(",
"options",
",",
"parser",
")",
":",
"if",
"not",
"options",
".",
"get",
"(",
"'release_environment'",
",",
"None",
")",
":",
"print",
"(",
"\"release environment is required\"",
")",
"parser",
".",
"print_help",
"(",
")",
"return",... | 570e28568475d5be1b1a2c95b8e941fbfbc167eb |
train | State.write | write all needed state info to filesystem | facsimile/state.py | def write(self):
""" write all needed state info to filesystem """
dumped = self._fax.codec.dump(self.__state, open(self.state_file, 'w')) | def write(self):
""" write all needed state info to filesystem """
dumped = self._fax.codec.dump(self.__state, open(self.state_file, 'w')) | [
"write",
"all",
"needed",
"state",
"info",
"to",
"filesystem"
] | 20c/facsimile | python | https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/state.py#L200-L202 | [
"def",
"write",
"(",
"self",
")",
":",
"dumped",
"=",
"self",
".",
"_fax",
".",
"codec",
".",
"dump",
"(",
"self",
".",
"__state",
",",
"open",
"(",
"self",
".",
"state_file",
",",
"'w'",
")",
")"
] | 570e28568475d5be1b1a2c95b8e941fbfbc167eb |
train | package_config | configure the module at the given path with a config template and file.
path = the filesystem path to the given module
template = the config template filename within that path
config_name = the config filename within that path
params = a dict containing config params, ... | bl/config.py | def package_config(path, template='__config__.ini.TEMPLATE', config_name='__config__.ini', **params):
"""configure the module at the given path with a config template and file.
path = the filesystem path to the given module
template = the config template filename within that path
... | def package_config(path, template='__config__.ini.TEMPLATE', config_name='__config__.ini', **params):
"""configure the module at the given path with a config template and file.
path = the filesystem path to the given module
template = the config template filename within that path
... | [
"configure",
"the",
"module",
"at",
"the",
"given",
"path",
"with",
"a",
"config",
"template",
"and",
"file",
".",
"path",
"=",
"the",
"filesystem",
"path",
"to",
"the",
"given",
"module",
"template",
"=",
"the",
"config",
"template",
"filename",
"within",
... | BlackEarth/bl | python | https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/config.py#L154-L171 | [
"def",
"package_config",
"(",
"path",
",",
"template",
"=",
"'__config__.ini.TEMPLATE'",
",",
"config_name",
"=",
"'__config__.ini'",
",",
"*",
"*",
"params",
")",
":",
"config_fns",
"=",
"[",
"]",
"template_fns",
"=",
"rglob",
"(",
"path",
",",
"template",
... | edf6f37dac718987260b90ad0e7f7fe084a7c1a3 |
train | Config.write | write the contents of this config to fn or its __filename__. | bl/config.py | def write(self, fn=None, sorted=False, wait=0):
"""write the contents of this config to fn or its __filename__.
"""
config = ConfigParser(interpolation=None)
if sorted==True: keys.sort()
for key in self.__dict__.get('ordered_keys') or self.keys():
config[key] = ... | def write(self, fn=None, sorted=False, wait=0):
"""write the contents of this config to fn or its __filename__.
"""
config = ConfigParser(interpolation=None)
if sorted==True: keys.sort()
for key in self.__dict__.get('ordered_keys') or self.keys():
config[key] = ... | [
"write",
"the",
"contents",
"of",
"this",
"config",
"to",
"fn",
"or",
"its",
"__filename__",
"."
] | BlackEarth/bl | python | https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/config.py#L76-L103 | [
"def",
"write",
"(",
"self",
",",
"fn",
"=",
"None",
",",
"sorted",
"=",
"False",
",",
"wait",
"=",
"0",
")",
":",
"config",
"=",
"ConfigParser",
"(",
"interpolation",
"=",
"None",
")",
"if",
"sorted",
"==",
"True",
":",
"keys",
".",
"sort",
"(",
... | edf6f37dac718987260b90ad0e7f7fe084a7c1a3 |
train | ConfigTemplate.expected_param_keys | returns a list of params that this ConfigTemplate expects to receive | bl/config.py | def expected_param_keys(self):
"""returns a list of params that this ConfigTemplate expects to receive"""
expected_keys = []
r = re.compile('%\(([^\)]+)\)s')
for block in self.keys():
for key in self[block].keys():
s = self[block][key]
i... | def expected_param_keys(self):
"""returns a list of params that this ConfigTemplate expects to receive"""
expected_keys = []
r = re.compile('%\(([^\)]+)\)s')
for block in self.keys():
for key in self[block].keys():
s = self[block][key]
i... | [
"returns",
"a",
"list",
"of",
"params",
"that",
"this",
"ConfigTemplate",
"expects",
"to",
"receive"
] | BlackEarth/bl | python | https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/config.py#L109-L124 | [
"def",
"expected_param_keys",
"(",
"self",
")",
":",
"expected_keys",
"=",
"[",
"]",
"r",
"=",
"re",
".",
"compile",
"(",
"'%\\(([^\\)]+)\\)s'",
")",
"for",
"block",
"in",
"self",
".",
"keys",
"(",
")",
":",
"for",
"key",
"in",
"self",
"[",
"block",
... | edf6f37dac718987260b90ad0e7f7fe084a7c1a3 |
train | ConfigTemplate.render | return a Config with the given params formatted via ``str.format(**params)``.
fn=None : If given, will assign this filename to the rendered Config.
prompt=False : If True, will prompt for any param that is None. | bl/config.py | def render(self, fn=None, prompt=False, **params):
"""return a Config with the given params formatted via ``str.format(**params)``.
fn=None : If given, will assign this filename to the rendered Config.
prompt=False : If True, will prompt for any param that is None.
"""
... | def render(self, fn=None, prompt=False, **params):
"""return a Config with the given params formatted via ``str.format(**params)``.
fn=None : If given, will assign this filename to the rendered Config.
prompt=False : If True, will prompt for any param that is None.
"""
... | [
"return",
"a",
"Config",
"with",
"the",
"given",
"params",
"formatted",
"via",
"str",
".",
"format",
"(",
"**",
"params",
")",
".",
"fn",
"=",
"None",
":",
"If",
"given",
"will",
"assign",
"this",
"filename",
"to",
"the",
"rendered",
"Config",
".",
"pr... | BlackEarth/bl | python | https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/config.py#L126-L152 | [
"def",
"render",
"(",
"self",
",",
"fn",
"=",
"None",
",",
"prompt",
"=",
"False",
",",
"*",
"*",
"params",
")",
":",
"from",
"getpass",
"import",
"getpass",
"expected_keys",
"=",
"self",
".",
"expected_param_keys",
"(",
")",
"compiled_params",
"=",
"Dic... | edf6f37dac718987260b90ad0e7f7fe084a7c1a3 |
train | main | Takes a crash id, pulls down data from Socorro, generates signature data | siggen/cmd_fetch_data.py | def main():
"""Takes a crash id, pulls down data from Socorro, generates signature data"""
parser = argparse.ArgumentParser(
formatter_class=WrappedTextHelpFormatter,
description=DESCRIPTION
)
parser.add_argument(
'-v', '--verbose', help='increase output verbosity', action='store... | def main():
"""Takes a crash id, pulls down data from Socorro, generates signature data"""
parser = argparse.ArgumentParser(
formatter_class=WrappedTextHelpFormatter,
description=DESCRIPTION
)
parser.add_argument(
'-v', '--verbose', help='increase output verbosity', action='store... | [
"Takes",
"a",
"crash",
"id",
"pulls",
"down",
"data",
"from",
"Socorro",
"generates",
"signature",
"data"
] | willkg/socorro-siggen | python | https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/cmd_fetch_data.py#L73-L136 | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"formatter_class",
"=",
"WrappedTextHelpFormatter",
",",
"description",
"=",
"DESCRIPTION",
")",
"parser",
".",
"add_argument",
"(",
"'-v'",
",",
"'--verbose'",
",",
"help",
"... | db7e3233e665a458a961c48da22e93a69b1d08d6 |
train | WrappedTextHelpFormatter._fill_text | Wraps text like HelpFormatter, but doesn't squash lines
This makes it easier to do lists and paragraphs. | siggen/cmd_fetch_data.py | def _fill_text(self, text, width, indent):
"""Wraps text like HelpFormatter, but doesn't squash lines
This makes it easier to do lists and paragraphs.
"""
parts = text.split('\n\n')
for i, part in enumerate(parts):
# Check to see if it's a bulleted list--if so, then... | def _fill_text(self, text, width, indent):
"""Wraps text like HelpFormatter, but doesn't squash lines
This makes it easier to do lists and paragraphs.
"""
parts = text.split('\n\n')
for i, part in enumerate(parts):
# Check to see if it's a bulleted list--if so, then... | [
"Wraps",
"text",
"like",
"HelpFormatter",
"but",
"doesn",
"t",
"squash",
"lines"
] | willkg/socorro-siggen | python | https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/cmd_fetch_data.py#L20-L39 | [
"def",
"_fill_text",
"(",
"self",
",",
"text",
",",
"width",
",",
"indent",
")",
":",
"parts",
"=",
"text",
".",
"split",
"(",
"'\\n\\n'",
")",
"for",
"i",
",",
"part",
"in",
"enumerate",
"(",
"parts",
")",
":",
"# Check to see if it's a bulleted list--if ... | db7e3233e665a458a961c48da22e93a69b1d08d6 |
train | AppConf.get_api_services_by_name | Return a dict of services by name | bors/app/config.py | def get_api_services_by_name(self):
"""Return a dict of services by name"""
if not self.services_by_name:
self.services_by_name = dict({s.get('name'): s for s in self.conf
.get("api")
.get("services")})
... | def get_api_services_by_name(self):
"""Return a dict of services by name"""
if not self.services_by_name:
self.services_by_name = dict({s.get('name'): s for s in self.conf
.get("api")
.get("services")})
... | [
"Return",
"a",
"dict",
"of",
"services",
"by",
"name"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/config.py#L37-L43 | [
"def",
"get_api_services_by_name",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"services_by_name",
":",
"self",
".",
"services_by_name",
"=",
"dict",
"(",
"{",
"s",
".",
"get",
"(",
"'name'",
")",
":",
"s",
"for",
"s",
"in",
"self",
".",
"conf",
... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | AppConf.get_api_endpoints | Returns the API endpoints | bors/app/config.py | def get_api_endpoints(self, apiname):
"""Returns the API endpoints"""
try:
return self.services_by_name\
.get(apiname)\
.get("endpoints")\
.copy()
except AttributeError:
raise Exception(f"Couldn't find the API en... | def get_api_endpoints(self, apiname):
"""Returns the API endpoints"""
try:
return self.services_by_name\
.get(apiname)\
.get("endpoints")\
.copy()
except AttributeError:
raise Exception(f"Couldn't find the API en... | [
"Returns",
"the",
"API",
"endpoints"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/config.py#L49-L57 | [
"def",
"get_api_endpoints",
"(",
"self",
",",
"apiname",
")",
":",
"try",
":",
"return",
"self",
".",
"services_by_name",
".",
"get",
"(",
"apiname",
")",
".",
"get",
"(",
"\"endpoints\"",
")",
".",
"copy",
"(",
")",
"except",
"AttributeError",
":",
"rai... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | AppConf.get_ws_subscriptions | Returns the websocket subscriptions | bors/app/config.py | def get_ws_subscriptions(self, apiname):
"""Returns the websocket subscriptions"""
try:
return self.services_by_name\
.get(apiname)\
.get("subscriptions")\
.copy()
except AttributeError:
raise Exception(f"Couldn'... | def get_ws_subscriptions(self, apiname):
"""Returns the websocket subscriptions"""
try:
return self.services_by_name\
.get(apiname)\
.get("subscriptions")\
.copy()
except AttributeError:
raise Exception(f"Couldn'... | [
"Returns",
"the",
"websocket",
"subscriptions"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/config.py#L59-L67 | [
"def",
"get_ws_subscriptions",
"(",
"self",
",",
"apiname",
")",
":",
"try",
":",
"return",
"self",
".",
"services_by_name",
".",
"get",
"(",
"apiname",
")",
".",
"get",
"(",
"\"subscriptions\"",
")",
".",
"copy",
"(",
")",
"except",
"AttributeError",
":",... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | AppConf.get_api | Returns the API configuration | bors/app/config.py | def get_api(self, name=None):
"""Returns the API configuration"""
if name is None:
try:
return self.conf.get("api").copy()
except: # NOQA
raise Exception(f"Couldn't find the API configuration") | def get_api(self, name=None):
"""Returns the API configuration"""
if name is None:
try:
return self.conf.get("api").copy()
except: # NOQA
raise Exception(f"Couldn't find the API configuration") | [
"Returns",
"the",
"API",
"configuration"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/config.py#L76-L82 | [
"def",
"get_api",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"try",
":",
"return",
"self",
".",
"conf",
".",
"get",
"(",
"\"api\"",
")",
".",
"copy",
"(",
")",
"except",
":",
"# NOQA",
"raise",
"Exception",
... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | AppConf.get_api_service | Returns the specific service config definition | bors/app/config.py | def get_api_service(self, name=None):
"""Returns the specific service config definition"""
try:
svc = self.services_by_name.get(name, None)
if svc is None:
raise ValueError(f"Couldn't find the API service configuration")
return svc
except: # N... | def get_api_service(self, name=None):
"""Returns the specific service config definition"""
try:
svc = self.services_by_name.get(name, None)
if svc is None:
raise ValueError(f"Couldn't find the API service configuration")
return svc
except: # N... | [
"Returns",
"the",
"specific",
"service",
"config",
"definition"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/config.py#L84-L92 | [
"def",
"get_api_service",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"try",
":",
"svc",
"=",
"self",
".",
"services_by_name",
".",
"get",
"(",
"name",
",",
"None",
")",
"if",
"svc",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"f\"Couldn't find... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | _ex_type_str | Return a string corresponding to the exception type. | pmisc/compat2.py | def _ex_type_str(exobj):
"""Return a string corresponding to the exception type."""
regexp = re.compile(r"<(?:\bclass\b|\btype\b)\s+'?([\w|\.]+)'?>")
exc_type = str(exobj)
if regexp.match(exc_type):
exc_type = regexp.match(exc_type).groups()[0]
exc_type = exc_type[11:] if exc_type.starts... | def _ex_type_str(exobj):
"""Return a string corresponding to the exception type."""
regexp = re.compile(r"<(?:\bclass\b|\btype\b)\s+'?([\w|\.]+)'?>")
exc_type = str(exobj)
if regexp.match(exc_type):
exc_type = regexp.match(exc_type).groups()[0]
exc_type = exc_type[11:] if exc_type.starts... | [
"Return",
"a",
"string",
"corresponding",
"to",
"the",
"exception",
"type",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/compat2.py#L13-L22 | [
"def",
"_ex_type_str",
"(",
"exobj",
")",
":",
"regexp",
"=",
"re",
".",
"compile",
"(",
"r\"<(?:\\bclass\\b|\\btype\\b)\\s+'?([\\w|\\.]+)'?>\"",
")",
"exc_type",
"=",
"str",
"(",
"exobj",
")",
"if",
"regexp",
".",
"match",
"(",
"exc_type",
")",
":",
"exc_type... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | _unicode_to_ascii | Convert to ASCII. | pmisc/compat2.py | def _unicode_to_ascii(obj): # pragma: no cover
"""Convert to ASCII."""
# pylint: disable=E0602,R1717
if isinstance(obj, dict):
return dict(
[
(_unicode_to_ascii(key), _unicode_to_ascii(value))
for key, value in obj.items()
]
)
if i... | def _unicode_to_ascii(obj): # pragma: no cover
"""Convert to ASCII."""
# pylint: disable=E0602,R1717
if isinstance(obj, dict):
return dict(
[
(_unicode_to_ascii(key), _unicode_to_ascii(value))
for key, value in obj.items()
]
)
if i... | [
"Convert",
"to",
"ASCII",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/compat2.py#L39-L53 | [
"def",
"_unicode_to_ascii",
"(",
"obj",
")",
":",
"# pragma: no cover",
"# pylint: disable=E0602,R1717",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"_unicode_to_ascii",
"(",
"key",
")",
",",
"_unicode_to_ascii",
"(",
... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | Nsca.send_result | Send results | monitoring_agent/outputs/nsca.py | def send_result(self, return_code, output, service_description='', specific_servers=None):
'''
Send results
'''
if specific_servers == None:
specific_servers = self.servers
else:
specific_servers = set(self.servers).intersection(specific_servers)
... | def send_result(self, return_code, output, service_description='', specific_servers=None):
'''
Send results
'''
if specific_servers == None:
specific_servers = self.servers
else:
specific_servers = set(self.servers).intersection(specific_servers)
... | [
"Send",
"results"
] | Eyepea/tanto | python | https://github.com/Eyepea/tanto/blob/ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9/monitoring_agent/outputs/nsca.py#L37-L58 | [
"def",
"send_result",
"(",
"self",
",",
"return_code",
",",
"output",
",",
"service_description",
"=",
"''",
",",
"specific_servers",
"=",
"None",
")",
":",
"if",
"specific_servers",
"==",
"None",
":",
"specific_servers",
"=",
"self",
".",
"servers",
"else",
... | ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9 |
train | SeleniumHatch.get_remote_executors | Get remote hosts from Selenium Grid Hub Console
@param hub_ip: hub ip of selenium grid hub
@param port: hub port of selenium grid hub | webuidriver/remote/SeleniumHatch.py | def get_remote_executors(hub_ip, port = 4444):
''' Get remote hosts from Selenium Grid Hub Console
@param hub_ip: hub ip of selenium grid hub
@param port: hub port of selenium grid hub
'''
resp = requests.get("http://%s:%s/grid/console" %(hub_ip, port))
re... | def get_remote_executors(hub_ip, port = 4444):
''' Get remote hosts from Selenium Grid Hub Console
@param hub_ip: hub ip of selenium grid hub
@param port: hub port of selenium grid hub
'''
resp = requests.get("http://%s:%s/grid/console" %(hub_ip, port))
re... | [
"Get",
"remote",
"hosts",
"from",
"Selenium",
"Grid",
"Hub",
"Console"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/remote/SeleniumHatch.py#L30-L40 | [
"def",
"get_remote_executors",
"(",
"hub_ip",
",",
"port",
"=",
"4444",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"\"http://%s:%s/grid/console\"",
"%",
"(",
"hub_ip",
",",
"port",
")",
")",
"remote_hosts",
"=",
"(",
")",
"if",
"resp",
".",
"sta... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | SeleniumHatch.gen_remote_driver | Generate remote drivers with desired capabilities(self.__caps) and command_executor
@param executor: command executor for selenium remote driver
@param capabilities: A dictionary of capabilities to request when starting the browser session.
@return: remote driver | webuidriver/remote/SeleniumHatch.py | def gen_remote_driver(executor, capabilities):
''' Generate remote drivers with desired capabilities(self.__caps) and command_executor
@param executor: command executor for selenium remote driver
@param capabilities: A dictionary of capabilities to request when starting the browser session.
... | def gen_remote_driver(executor, capabilities):
''' Generate remote drivers with desired capabilities(self.__caps) and command_executor
@param executor: command executor for selenium remote driver
@param capabilities: A dictionary of capabilities to request when starting the browser session.
... | [
"Generate",
"remote",
"drivers",
"with",
"desired",
"capabilities",
"(",
"self",
".",
"__caps",
")",
"and",
"command_executor"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/remote/SeleniumHatch.py#L74-L82 | [
"def",
"gen_remote_driver",
"(",
"executor",
",",
"capabilities",
")",
":",
"# selenium requires browser's driver and PATH env. Firefox's driver is required for selenium3.0 \r",
"firefox_profile",
"=",
"capabilities",
".",
"pop",
"(",
"\"firefox_profile\"",
",",
"None",
... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | SeleniumHatch.gen_local_driver | Generate localhost drivers with desired capabilities(self.__caps)
@param browser: firefox or chrome
@param capabilities: A dictionary of capabilities to request when starting the browser session.
@return: localhost driver | webuidriver/remote/SeleniumHatch.py | def gen_local_driver(browser, capabilities):
''' Generate localhost drivers with desired capabilities(self.__caps)
@param browser: firefox or chrome
@param capabilities: A dictionary of capabilities to request when starting the browser session.
@return: localhost driver
'... | def gen_local_driver(browser, capabilities):
''' Generate localhost drivers with desired capabilities(self.__caps)
@param browser: firefox or chrome
@param capabilities: A dictionary of capabilities to request when starting the browser session.
@return: localhost driver
'... | [
"Generate",
"localhost",
"drivers",
"with",
"desired",
"capabilities",
"(",
"self",
".",
"__caps",
")"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/remote/SeleniumHatch.py#L85-L99 | [
"def",
"gen_local_driver",
"(",
"browser",
",",
"capabilities",
")",
":",
"if",
"browser",
"==",
"\"firefox\"",
":",
"fp",
"=",
"capabilities",
".",
"pop",
"(",
"\"firefox_profile\"",
",",
"None",
")",
"return",
"webdriver",
".",
"Firefox",
"(",
"desired_capab... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | Response._production | Calculate total energy production. Not rounded | ree/response/response.py | def _production(self):
"""Calculate total energy production. Not rounded"""
return self._nuclear + self._diesel + self._gas + self._wind + self._combined + self._vapor + self._solar + self._hydraulic + self._carbon + self._waste + self._other | def _production(self):
"""Calculate total energy production. Not rounded"""
return self._nuclear + self._diesel + self._gas + self._wind + self._combined + self._vapor + self._solar + self._hydraulic + self._carbon + self._waste + self._other | [
"Calculate",
"total",
"energy",
"production",
".",
"Not",
"rounded"
] | blackleg/ree | python | https://github.com/blackleg/ree/blob/94142571db0b5a39affe974184ff266135423645/ree/response/response.py#L137-L139 | [
"def",
"_production",
"(",
"self",
")",
":",
"return",
"self",
".",
"_nuclear",
"+",
"self",
".",
"_diesel",
"+",
"self",
".",
"_gas",
"+",
"self",
".",
"_wind",
"+",
"self",
".",
"_combined",
"+",
"self",
".",
"_vapor",
"+",
"self",
".",
"_solar",
... | 94142571db0b5a39affe974184ff266135423645 |
train | Response._links | Calculate total energy production. Not Rounded | ree/response/response.py | def _links(self):
"""Calculate total energy production. Not Rounded"""
total = 0.0
for value in self.link.values():
total += value
return total | def _links(self):
"""Calculate total energy production. Not Rounded"""
total = 0.0
for value in self.link.values():
total += value
return total | [
"Calculate",
"total",
"energy",
"production",
".",
"Not",
"Rounded"
] | blackleg/ree | python | https://github.com/blackleg/ree/blob/94142571db0b5a39affe974184ff266135423645/ree/response/response.py#L145-L150 | [
"def",
"_links",
"(",
"self",
")",
":",
"total",
"=",
"0.0",
"for",
"value",
"in",
"self",
".",
"link",
".",
"values",
"(",
")",
":",
"total",
"+=",
"value",
"return",
"total"
] | 94142571db0b5a39affe974184ff266135423645 |
train | query_yes_no | Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the user).
The "answer" return v... | thomas/__main__.py | def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer i... | def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer i... | [
"Ask",
"a",
"yes",
"/",
"no",
"question",
"via",
"raw_input",
"()",
"and",
"return",
"their",
"answer",
".",
"question",
"is",
"a",
"string",
"that",
"is",
"presented",
"to",
"the",
"user",
".",
"default",
"is",
"the",
"presumed",
"answer",
"if",
"the",
... | JohnDoee/thomas | python | https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/__main__.py#L15-L42 | [
"def",
"query_yes_no",
"(",
"question",
",",
"default",
"=",
"\"yes\"",
")",
":",
"valid",
"=",
"{",
"\"yes\"",
":",
"True",
",",
"\"y\"",
":",
"True",
",",
"\"ye\"",
":",
"True",
",",
"\"no\"",
":",
"False",
",",
"\"n\"",
":",
"False",
"}",
"if",
... | 51916dd110098b189a1c2fbcb71794fd9ec94832 |
train | Gene.wall_of_name | Appends identifiers for the different databases (such as Entrez id's)
and returns them. Uses the CrossRef class below. | genes/models.py | def wall_of_name(self):
'''
Appends identifiers for the different databases (such as Entrez id's)
and returns them. Uses the CrossRef class below.
'''
names = []
if self.standard_name:
names.append(self.standard_name)
if self.systematic_name:
... | def wall_of_name(self):
'''
Appends identifiers for the different databases (such as Entrez id's)
and returns them. Uses the CrossRef class below.
'''
names = []
if self.standard_name:
names.append(self.standard_name)
if self.systematic_name:
... | [
"Appends",
"identifiers",
"for",
"the",
"different",
"databases",
"(",
"such",
"as",
"Entrez",
"id",
"s",
")",
"and",
"returns",
"them",
".",
"Uses",
"the",
"CrossRef",
"class",
"below",
"."
] | greenelab/django-genes | python | https://github.com/greenelab/django-genes/blob/298939adcb115031acfc11cfcef60ea0b596fae5/genes/models.py#L51-L68 | [
"def",
"wall_of_name",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"if",
"self",
".",
"standard_name",
":",
"names",
".",
"append",
"(",
"self",
".",
"standard_name",
")",
"if",
"self",
".",
"systematic_name",
":",
"names",
".",
"append",
"(",
"self... | 298939adcb115031acfc11cfcef60ea0b596fae5 |
train | Gene.save | Override save() method to make sure that standard_name and
systematic_name won't be null or empty, or consist of only space
characters (such as space, tab, new line, etc). | genes/models.py | def save(self, *args, **kwargs):
"""
Override save() method to make sure that standard_name and
systematic_name won't be null or empty, or consist of only space
characters (such as space, tab, new line, etc).
"""
empty_std_name = False
if not self.standard_name or... | def save(self, *args, **kwargs):
"""
Override save() method to make sure that standard_name and
systematic_name won't be null or empty, or consist of only space
characters (such as space, tab, new line, etc).
"""
empty_std_name = False
if not self.standard_name or... | [
"Override",
"save",
"()",
"method",
"to",
"make",
"sure",
"that",
"standard_name",
"and",
"systematic_name",
"won",
"t",
"be",
"null",
"or",
"empty",
"or",
"consist",
"of",
"only",
"space",
"characters",
"(",
"such",
"as",
"space",
"tab",
"new",
"line",
"e... | greenelab/django-genes | python | https://github.com/greenelab/django-genes/blob/298939adcb115031acfc11cfcef60ea0b596fae5/genes/models.py#L70-L88 | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"empty_std_name",
"=",
"False",
"if",
"not",
"self",
".",
"standard_name",
"or",
"self",
".",
"standard_name",
".",
"isspace",
"(",
")",
":",
"empty_std_name",
"=",
"True"... | 298939adcb115031acfc11cfcef60ea0b596fae5 |
train | CrossRefDB.save | Extends save() method of Django models to check that the database name
is not left blank.
Note: 'blank=False' is only checked at a form-validation-stage. A test
using Fixtureless that tries to randomly create a CrossRefDB with an
empty string name would unintentionally break the test. | genes/models.py | def save(self, *args, **kwargs):
"""
Extends save() method of Django models to check that the database name
is not left blank.
Note: 'blank=False' is only checked at a form-validation-stage. A test
using Fixtureless that tries to randomly create a CrossRefDB with an
empty... | def save(self, *args, **kwargs):
"""
Extends save() method of Django models to check that the database name
is not left blank.
Note: 'blank=False' is only checked at a form-validation-stage. A test
using Fixtureless that tries to randomly create a CrossRefDB with an
empty... | [
"Extends",
"save",
"()",
"method",
"of",
"Django",
"models",
"to",
"check",
"that",
"the",
"database",
"name",
"is",
"not",
"left",
"blank",
".",
"Note",
":",
"blank",
"=",
"False",
"is",
"only",
"checked",
"at",
"a",
"form",
"-",
"validation",
"-",
"s... | greenelab/django-genes | python | https://github.com/greenelab/django-genes/blob/298939adcb115031acfc11cfcef60ea0b596fae5/genes/models.py#L96-L107 | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"name",
"==",
"''",
":",
"raise",
"FieldError",
"else",
":",
"return",
"super",
"(",
"CrossRefDB",
",",
"self",
")",
".",
"save",
"(",
"*",
"args"... | 298939adcb115031acfc11cfcef60ea0b596fae5 |
train | FilelikeObjectResource.makeProducer | Make a L{StaticProducer} that will produce the body of this response.
This method will also set the response code and Content-* headers.
@param request: The L{Request} object.
@param fileForReading: The file object containing the resource.
@return: A L{StaticProducer}. Calling C{.star... | thomas/outputs/http.py | def makeProducer(self, request, fileForReading):
"""
Make a L{StaticProducer} that will produce the body of this response.
This method will also set the response code and Content-* headers.
@param request: The L{Request} object.
@param fileForReading: The file object containing... | def makeProducer(self, request, fileForReading):
"""
Make a L{StaticProducer} that will produce the body of this response.
This method will also set the response code and Content-* headers.
@param request: The L{Request} object.
@param fileForReading: The file object containing... | [
"Make",
"a",
"L",
"{",
"StaticProducer",
"}",
"that",
"will",
"produce",
"the",
"body",
"of",
"this",
"response",
"."
] | JohnDoee/thomas | python | https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/outputs/http.py#L278-L311 | [
"def",
"makeProducer",
"(",
"self",
",",
"request",
",",
"fileForReading",
")",
":",
"byteRange",
"=",
"request",
".",
"getHeader",
"(",
"b'range'",
")",
"if",
"byteRange",
"is",
"None",
"or",
"not",
"self",
".",
"getFileSize",
"(",
")",
":",
"self",
"."... | 51916dd110098b189a1c2fbcb71794fd9ec94832 |
train | FilelikeObjectResource.render_GET | Begin sending the contents of this L{File} (or a subset of the
contents, based on the 'range' header) to the given request. | thomas/outputs/http.py | def render_GET(self, request):
"""
Begin sending the contents of this L{File} (or a subset of the
contents, based on the 'range' header) to the given request.
"""
request.setHeader(b'accept-ranges', b'bytes')
producer = self.makeProducer(request, self.fileObject)
... | def render_GET(self, request):
"""
Begin sending the contents of this L{File} (or a subset of the
contents, based on the 'range' header) to the given request.
"""
request.setHeader(b'accept-ranges', b'bytes')
producer = self.makeProducer(request, self.fileObject)
... | [
"Begin",
"sending",
"the",
"contents",
"of",
"this",
"L",
"{",
"File",
"}",
"(",
"or",
"a",
"subset",
"of",
"the",
"contents",
"based",
"on",
"the",
"range",
"header",
")",
"to",
"the",
"given",
"request",
"."
] | JohnDoee/thomas | python | https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/outputs/http.py#L316-L334 | [
"def",
"render_GET",
"(",
"self",
",",
"request",
")",
":",
"request",
".",
"setHeader",
"(",
"b'accept-ranges'",
",",
"b'bytes'",
")",
"producer",
"=",
"self",
".",
"makeProducer",
"(",
"request",
",",
"self",
".",
"fileObject",
")",
"if",
"request",
".",... | 51916dd110098b189a1c2fbcb71794fd9ec94832 |
train | ApiProduct.interface | Implement the interface for the adapter object | bors/api/product.py | def interface(self, context):
"""Implement the interface for the adapter object"""
self.context = context
self.callback = self.context.get("callback") | def interface(self, context):
"""Implement the interface for the adapter object"""
self.context = context
self.callback = self.context.get("callback") | [
"Implement",
"the",
"interface",
"for",
"the",
"adapter",
"object"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/product.py#L18-L21 | [
"def",
"interface",
"(",
"self",
",",
"context",
")",
":",
"self",
".",
"context",
"=",
"context",
"self",
".",
"callback",
"=",
"self",
".",
"context",
".",
"get",
"(",
"\"callback\"",
")"
] | 38bf338fc6905d90819faa56bd832140116720f0 |
train | ApiProduct.shutdown | Executed on shutdown of application | bors/api/product.py | def shutdown(self):
"""Executed on shutdown of application"""
self.stopped.set()
if hasattr(self.api, "shutdown"):
self.api.shutdown()
for thread in self.thread.values():
thread.join() | def shutdown(self):
"""Executed on shutdown of application"""
self.stopped.set()
if hasattr(self.api, "shutdown"):
self.api.shutdown()
for thread in self.thread.values():
thread.join() | [
"Executed",
"on",
"shutdown",
"of",
"application"
] | RobotStudio/bors | python | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/product.py#L23-L31 | [
"def",
"shutdown",
"(",
"self",
")",
":",
"self",
".",
"stopped",
".",
"set",
"(",
")",
"if",
"hasattr",
"(",
"self",
".",
"api",
",",
"\"shutdown\"",
")",
":",
"self",
".",
"api",
".",
"shutdown",
"(",
")",
"for",
"thread",
"in",
"self",
".",
"t... | 38bf338fc6905d90819faa56bd832140116720f0 |
train | Web.SwitchToAlert | <input value="Test" type="button" onClick="alert('OK')" > | webuidriver/actions.py | def SwitchToAlert():
''' <input value="Test" type="button" onClick="alert('OK')" > '''
try:
alert = WebDriverWait(Web.driver, 10).until(lambda driver: driver.switch_to_alert())
return alert
except:
print("Waring: Time... | def SwitchToAlert():
''' <input value="Test" type="button" onClick="alert('OK')" > '''
try:
alert = WebDriverWait(Web.driver, 10).until(lambda driver: driver.switch_to_alert())
return alert
except:
print("Waring: Time... | [
"<input",
"value",
"=",
"Test",
"type",
"=",
"button",
"onClick",
"=",
"alert",
"(",
"OK",
")",
">"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L118-L125 | [
"def",
"SwitchToAlert",
"(",
")",
":",
"try",
":",
"alert",
"=",
"WebDriverWait",
"(",
"Web",
".",
"driver",
",",
"10",
")",
".",
"until",
"(",
"lambda",
"driver",
":",
"driver",
".",
"switch_to_alert",
"(",
")",
")",
"return",
"alert",
"except",
":",
... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebElement._element | find the element with controls | webuidriver/actions.py | def _element(cls):
''' find the element with controls '''
if not cls.__is_selector():
raise Exception("Invalid selector[%s]." %cls.__control["by"])
driver = Web.driver
try:
elements = WebDriverWait(driver, cls.__control["timeout"]).un... | def _element(cls):
''' find the element with controls '''
if not cls.__is_selector():
raise Exception("Invalid selector[%s]." %cls.__control["by"])
driver = Web.driver
try:
elements = WebDriverWait(driver, cls.__control["timeout"]).un... | [
"find",
"the",
"element",
"with",
"controls"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L199-L218 | [
"def",
"_element",
"(",
"cls",
")",
":",
"if",
"not",
"cls",
".",
"__is_selector",
"(",
")",
":",
"raise",
"Exception",
"(",
"\"Invalid selector[%s].\"",
"%",
"cls",
".",
"__control",
"[",
"\"by\"",
"]",
")",
"driver",
"=",
"Web",
".",
"driver",
"try",
... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebElement._elements | find the elements with controls | webuidriver/actions.py | def _elements(cls):
''' find the elements with controls '''
if not cls.__is_selector():
raise Exception("Invalid selector[%s]." %cls.__control["by"])
driver = Web.driver
try:
elements = WebDriverWait(driver, cls.__control["timeout"]).... | def _elements(cls):
''' find the elements with controls '''
if not cls.__is_selector():
raise Exception("Invalid selector[%s]." %cls.__control["by"])
driver = Web.driver
try:
elements = WebDriverWait(driver, cls.__control["timeout"]).... | [
"find",
"the",
"elements",
"with",
"controls"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L221-L232 | [
"def",
"_elements",
"(",
"cls",
")",
":",
"if",
"not",
"cls",
".",
"__is_selector",
"(",
")",
":",
"raise",
"Exception",
"(",
"\"Invalid selector[%s].\"",
"%",
"cls",
".",
"__control",
"[",
"\"by\"",
"]",
")",
"driver",
"=",
"Web",
".",
"driver",
"try",
... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebContext.DyStrData | set dynamic value from the string data of response
@param name: glob parameter name
@param regx: re._pattern_type
e.g.
DyStrData("a",re.compile('123')) | webuidriver/actions.py | def DyStrData(cls, name, regx, index = 0):
''' set dynamic value from the string data of response
@param name: glob parameter name
@param regx: re._pattern_type
e.g.
DyStrData("a",re.compile('123'))
'''
text = Web.PageSource()
if not text... | def DyStrData(cls, name, regx, index = 0):
''' set dynamic value from the string data of response
@param name: glob parameter name
@param regx: re._pattern_type
e.g.
DyStrData("a",re.compile('123'))
'''
text = Web.PageSource()
if not text... | [
"set",
"dynamic",
"value",
"from",
"the",
"string",
"data",
"of",
"response"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L262-L279 | [
"def",
"DyStrData",
"(",
"cls",
",",
"name",
",",
"regx",
",",
"index",
"=",
"0",
")",
":",
"text",
"=",
"Web",
".",
"PageSource",
"(",
")",
"if",
"not",
"text",
":",
"return",
"if",
"not",
"isinstance",
"(",
"regx",
",",
"re",
".",
"_pattern_type"... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebContext.DyJsonData | set dynamic value from the json data of response
@note: 获取innerHTML json的数据 如, <html><body>{ "code": 1,"desc": "成功"}</body></html>
@param name: glob parameter name
@param sequence: sequence for the json
e.g.
result={"a":1,
"b":[1,2,3,4],
... | webuidriver/actions.py | def DyJsonData(cls,name, sequence):
''' set dynamic value from the json data of response
@note: 获取innerHTML json的数据 如, <html><body>{ "code": 1,"desc": "成功"}</body></html>
@param name: glob parameter name
@param sequence: sequence for the json
e.g.
result=... | def DyJsonData(cls,name, sequence):
''' set dynamic value from the json data of response
@note: 获取innerHTML json的数据 如, <html><body>{ "code": 1,"desc": "成功"}</body></html>
@param name: glob parameter name
@param sequence: sequence for the json
e.g.
result=... | [
"set",
"dynamic",
"value",
"from",
"the",
"json",
"data",
"of",
"response"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L282-L318 | [
"def",
"DyJsonData",
"(",
"cls",
",",
"name",
",",
"sequence",
")",
":",
"cls",
".",
"SetControl",
"(",
"by",
"=",
"\"tag name\"",
",",
"value",
"=",
"\"body\"",
")",
"json_body",
"=",
"cls",
".",
"_element",
"(",
")",
".",
"get_attribute",
"(",
"'inne... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebVerify.VerifyURL | 获取当前页面的url | webuidriver/actions.py | def VerifyURL(cls, url):
""" 获取当前页面的url """
if Web.driver.current_url == url:
return True
else:
print("VerifyURL: %s" % Web.driver.current_url)
return False | def VerifyURL(cls, url):
""" 获取当前页面的url """
if Web.driver.current_url == url:
return True
else:
print("VerifyURL: %s" % Web.driver.current_url)
return False | [
"获取当前页面的url"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L375-L382 | [
"def",
"VerifyURL",
"(",
"cls",
",",
"url",
")",
":",
"if",
"Web",
".",
"driver",
".",
"current_url",
"==",
"url",
":",
"return",
"True",
"else",
":",
"print",
"(",
"\"VerifyURL: %s\"",
"%",
"Web",
".",
"driver",
".",
"current_url",
")",
"return",
"Fal... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.SelectByIndex | 通过索引,选择下拉框选项,
@param index: 下拉框 索引 | webuidriver/actions.py | def SelectByIndex(cls, index):
''' 通过索引,选择下拉框选项,
@param index: 下拉框 索引
'''
try:
Select(cls._element()).select_by_index(int(index))
except:
return False | def SelectByIndex(cls, index):
''' 通过索引,选择下拉框选项,
@param index: 下拉框 索引
'''
try:
Select(cls._element()).select_by_index(int(index))
except:
return False | [
"通过索引,选择下拉框选项,"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L506-L513 | [
"def",
"SelectByIndex",
"(",
"cls",
",",
"index",
")",
":",
"try",
":",
"Select",
"(",
"cls",
".",
"_element",
"(",
")",
")",
".",
"select_by_index",
"(",
"int",
"(",
"index",
")",
")",
"except",
":",
"return",
"False"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.DeSelectByIndex | 通过索引,取消选择下拉框选项,
@param index: 下拉框 索引 | webuidriver/actions.py | def DeSelectByIndex(cls, index):
''' 通过索引,取消选择下拉框选项,
@param index: 下拉框 索引
'''
try:
Select(cls._element()).deselect_by_index(int(index))
except:
return False | def DeSelectByIndex(cls, index):
''' 通过索引,取消选择下拉框选项,
@param index: 下拉框 索引
'''
try:
Select(cls._element()).deselect_by_index(int(index))
except:
return False | [
"通过索引,取消选择下拉框选项,"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L516-L523 | [
"def",
"DeSelectByIndex",
"(",
"cls",
",",
"index",
")",
":",
"try",
":",
"Select",
"(",
"cls",
".",
"_element",
"(",
")",
")",
".",
"deselect_by_index",
"(",
"int",
"(",
"index",
")",
")",
"except",
":",
"return",
"False"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.MouseOver | 鼠标悬浮 | webuidriver/actions.py | def MouseOver(cls):
''' 鼠标悬浮 '''
element = cls._element()
action = ActionChains(Web.driver)
action.move_to_element(element)
action.perform()
time.sleep(1) | def MouseOver(cls):
''' 鼠标悬浮 '''
element = cls._element()
action = ActionChains(Web.driver)
action.move_to_element(element)
action.perform()
time.sleep(1) | [
"鼠标悬浮"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L546-L552 | [
"def",
"MouseOver",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"move_to_element",
"(",
"element",
")",
"action",
".",
"perform",
"(",
")",
"time"... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.Click | 左键 点击 1次 | webuidriver/actions.py | def Click(cls):
''' 左键 点击 1次 '''
element= cls._element()
action = ActionChains(Web.driver)
action.click(element)
action.perform() | def Click(cls):
''' 左键 点击 1次 '''
element= cls._element()
action = ActionChains(Web.driver)
action.click(element)
action.perform() | [
"左键",
"点击",
"1次"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L555-L561 | [
"def",
"Click",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"click",
"(",
"element",
")",
"action",
".",
"perform",
"(",
")"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.DoubleClick | 左键点击2次 | webuidriver/actions.py | def DoubleClick(cls):
''' 左键点击2次 '''
element = cls._element()
action = ActionChains(Web.driver)
action.double_click(element)
action.perform() | def DoubleClick(cls):
''' 左键点击2次 '''
element = cls._element()
action = ActionChains(Web.driver)
action.double_click(element)
action.perform() | [
"左键点击2次"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L564-L570 | [
"def",
"DoubleClick",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"double_click",
"(",
"element",
")",
"action",
".",
"perform",
"(",
")"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.EnhancedClick | Description:
Sometimes, one click on the element doesn't work. So wait more time, then click again and again.
Risk:
It may operate more than one click operations. | webuidriver/actions.py | def EnhancedClick(cls):
'''
Description:
Sometimes, one click on the element doesn't work. So wait more time, then click again and again.
Risk:
It may operate more than one click operations.
'''
element = cls._element()
for _ in r... | def EnhancedClick(cls):
'''
Description:
Sometimes, one click on the element doesn't work. So wait more time, then click again and again.
Risk:
It may operate more than one click operations.
'''
element = cls._element()
for _ in r... | [
"Description",
":",
"Sometimes",
"one",
"click",
"on",
"the",
"element",
"doesn",
"t",
"work",
".",
"So",
"wait",
"more",
"time",
"then",
"click",
"again",
"and",
"again",
".",
"Risk",
":",
"It",
"may",
"operate",
"more",
"than",
"one",
"click",
"operati... | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L573-L586 | [
"def",
"EnhancedClick",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"3",
")",
":",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"move_to_element",
"(",
"elem... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.RightClick | 右键点击1次 | webuidriver/actions.py | def RightClick(cls):
''' 右键点击1次 '''
element = cls._element()
action = ActionChains(Web.driver)
action.context_click(element)
action.perform() | def RightClick(cls):
''' 右键点击1次 '''
element = cls._element()
action = ActionChains(Web.driver)
action.context_click(element)
action.perform() | [
"右键点击1次"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L589-L595 | [
"def",
"RightClick",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"context_click",
"(",
"element",
")",
"action",
".",
"perform",
"(",
")"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.ClickAndHold | 相当于 按压,press | webuidriver/actions.py | def ClickAndHold(cls):
''' 相当于 按压,press '''
element = cls._element()
action = ActionChains(Web.driver)
action.click_and_hold(element)
action.perform() | def ClickAndHold(cls):
''' 相当于 按压,press '''
element = cls._element()
action = ActionChains(Web.driver)
action.click_and_hold(element)
action.perform() | [
"相当于",
"按压,press"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L599-L605 | [
"def",
"ClickAndHold",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"click_and_hold",
"(",
"element",
")",
"action",
".",
"perform",
"(",
")"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.ReleaseClick | 释放按压操作 | webuidriver/actions.py | def ReleaseClick(cls):
''' 释放按压操作 '''
element = cls._element()
action = ActionChains(Web.driver)
action.release(element)
action.perform() | def ReleaseClick(cls):
''' 释放按压操作 '''
element = cls._element()
action = ActionChains(Web.driver)
action.release(element)
action.perform() | [
"释放按压操作"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L609-L615 | [
"def",
"ReleaseClick",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"release",
"(",
"element",
")",
"action",
".",
"perform",
"(",
")"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.Enter | 在指定输入框发送回回车键
@note: key event -> enter | webuidriver/actions.py | def Enter(cls):
''' 在指定输入框发送回回车键
@note: key event -> enter
'''
element = cls._element()
action = ActionChains(Web.driver)
action.send_keys_to_element(element, Keys.ENTER)
action.perform() | def Enter(cls):
''' 在指定输入框发送回回车键
@note: key event -> enter
'''
element = cls._element()
action = ActionChains(Web.driver)
action.send_keys_to_element(element, Keys.ENTER)
action.perform() | [
"在指定输入框发送回回车键"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L626-L634 | [
"def",
"Enter",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"send_keys_to_element",
"(",
"element",
",",
"Keys",
".",
"ENTER",
")",
"action",
".",... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.Ctrl | 在指定元素上执行ctrl组合键事件
@note: key event -> control + key
@param key: 如'X' | webuidriver/actions.py | def Ctrl(cls, key):
""" 在指定元素上执行ctrl组合键事件
@note: key event -> control + key
@param key: 如'X'
"""
element = cls._element()
element.send_keys(Keys.CONTROL, key) | def Ctrl(cls, key):
""" 在指定元素上执行ctrl组合键事件
@note: key event -> control + key
@param key: 如'X'
"""
element = cls._element()
element.send_keys(Keys.CONTROL, key) | [
"在指定元素上执行ctrl组合键事件"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L637-L643 | [
"def",
"Ctrl",
"(",
"cls",
",",
"key",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"element",
".",
"send_keys",
"(",
"Keys",
".",
"CONTROL",
",",
"key",
")"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.Alt | 在指定元素上执行alt组合事件
@note: key event -> alt + key
@param key: 如'X' | webuidriver/actions.py | def Alt(cls, key):
""" 在指定元素上执行alt组合事件
@note: key event -> alt + key
@param key: 如'X'
"""
element = cls._element()
element.send_keys(Keys.ALT, key) | def Alt(cls, key):
""" 在指定元素上执行alt组合事件
@note: key event -> alt + key
@param key: 如'X'
"""
element = cls._element()
element.send_keys(Keys.ALT, key) | [
"在指定元素上执行alt组合事件"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L647-L653 | [
"def",
"Alt",
"(",
"cls",
",",
"key",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"element",
".",
"send_keys",
"(",
"Keys",
".",
"ALT",
",",
"key",
")"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.Focus | 在指定输入框发送 Null, 用于设置焦点
@note: key event -> NULL | webuidriver/actions.py | def Focus(cls):
""" 在指定输入框发送 Null, 用于设置焦点
@note: key event -> NULL
"""
element = cls._element()
# element.send_keys(Keys.NULL)
action = ActionChains(Web.driver)
action.send_keys_to_element(element, Keys.NULL)
actio... | def Focus(cls):
""" 在指定输入框发送 Null, 用于设置焦点
@note: key event -> NULL
"""
element = cls._element()
# element.send_keys(Keys.NULL)
action = ActionChains(Web.driver)
action.send_keys_to_element(element, Keys.NULL)
actio... | [
"在指定输入框发送",
"Null,",
"用于设置焦点"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L693-L702 | [
"def",
"Focus",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"# element.send_keys(Keys.NULL) \r",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"send_keys_to_element",
"(",
"element",
",",... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.Upload | 文件上传, 非原生input
@todo: some upload.exe not prepared
@param file: 文件名(文件必须存在在工程resource目录下), upload.exe工具放在工程tools目录下 | webuidriver/actions.py | def Upload(cls, filename):
""" 文件上传, 非原生input
@todo: some upload.exe not prepared
@param file: 文件名(文件必须存在在工程resource目录下), upload.exe工具放在工程tools目录下
"""
raise Exception("to do")
TOOLS_PATH = ""
RESOURCE_PATH = ""
tool_4path = os.path.... | def Upload(cls, filename):
""" 文件上传, 非原生input
@todo: some upload.exe not prepared
@param file: 文件名(文件必须存在在工程resource目录下), upload.exe工具放在工程tools目录下
"""
raise Exception("to do")
TOOLS_PATH = ""
RESOURCE_PATH = ""
tool_4path = os.path.... | [
"文件上传,",
"非原生input"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L706-L723 | [
"def",
"Upload",
"(",
"cls",
",",
"filename",
")",
":",
"raise",
"Exception",
"(",
"\"to do\"",
")",
"TOOLS_PATH",
"=",
"\"\"",
"RESOURCE_PATH",
"=",
"\"\"",
"tool_4path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"TOOLS_PATH",
",",
"\"upload.exe\"",
")",
... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | WebActions.UploadType | 上传, 一般,上传页面如果是input,原生file文件框, 如: <input type="file" id="test-image-file" name="test" accept="image/gif">,像这样的,定位到该元素,然后使用 send_keys 上传的文件的绝对路径
@param file_name: 文件名(文件必须存在在工程resource目录下) | webuidriver/actions.py | def UploadType(cls, file_path):
""" 上传, 一般,上传页面如果是input,原生file文件框, 如: <input type="file" id="test-image-file" name="test" accept="image/gif">,像这样的,定位到该元素,然后使用 send_keys 上传的文件的绝对路径
@param file_name: 文件名(文件必须存在在工程resource目录下)
"""
if not os.path.isabs(file_path):
... | def UploadType(cls, file_path):
""" 上传, 一般,上传页面如果是input,原生file文件框, 如: <input type="file" id="test-image-file" name="test" accept="image/gif">,像这样的,定位到该元素,然后使用 send_keys 上传的文件的绝对路径
@param file_name: 文件名(文件必须存在在工程resource目录下)
"""
if not os.path.isabs(file_path):
... | [
"上传,",
"一般,上传页面如果是input",
"原生file文件框",
"如:",
"<input",
"type",
"=",
"file",
"id",
"=",
"test",
"-",
"image",
"-",
"file",
"name",
"=",
"test",
"accept",
"=",
"image",
"/",
"gif",
">",
",像这样的,定位到该元素,然后使用",
"send_keys",
"上传的文件的绝对路径"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L726-L736 | [
"def",
"UploadType",
"(",
"cls",
",",
"file_path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"file_path",
")",
":",
"return",
"False",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"file_path",
")",
":",
"cls",
".",
"SendKeys",
"(... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | Dict.update | Updates the Dict with the given values. Turns internal dicts into Dicts. | bl/dict.py | def update(xCqNck7t, **kwargs):
"""Updates the Dict with the given values. Turns internal dicts into Dicts."""
def dict_list_val(inlist):
l = []
for i in inlist:
if type(i)==dict:
l.append(Dict(**i))
elif type(i)==list:
... | def update(xCqNck7t, **kwargs):
"""Updates the Dict with the given values. Turns internal dicts into Dicts."""
def dict_list_val(inlist):
l = []
for i in inlist:
if type(i)==dict:
l.append(Dict(**i))
elif type(i)==list:
... | [
"Updates",
"the",
"Dict",
"with",
"the",
"given",
"values",
".",
"Turns",
"internal",
"dicts",
"into",
"Dicts",
"."
] | BlackEarth/bl | python | https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/dict.py#L48-L68 | [
"def",
"update",
"(",
"xCqNck7t",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"dict_list_val",
"(",
"inlist",
")",
":",
"l",
"=",
"[",
"]",
"for",
"i",
"in",
"inlist",
":",
"if",
"type",
"(",
"i",
")",
"==",
"dict",
":",
"l",
".",
"append",
"(",
... | edf6f37dac718987260b90ad0e7f7fe084a7c1a3 |
train | Dict.keys | sort the keys before returning them | bl/dict.py | def keys(self, key=None, reverse=False):
"""sort the keys before returning them"""
ks = sorted(list(dict.keys(self)), key=key, reverse=reverse)
return ks | def keys(self, key=None, reverse=False):
"""sort the keys before returning them"""
ks = sorted(list(dict.keys(self)), key=key, reverse=reverse)
return ks | [
"sort",
"the",
"keys",
"before",
"returning",
"them"
] | BlackEarth/bl | python | https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/dict.py#L83-L86 | [
"def",
"keys",
"(",
"self",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"ks",
"=",
"sorted",
"(",
"list",
"(",
"dict",
".",
"keys",
"(",
"self",
")",
")",
",",
"key",
"=",
"key",
",",
"reverse",
"=",
"reverse",
")",
"return... | edf6f37dac718987260b90ad0e7f7fe084a7c1a3 |
train | SeleniumJar.hub | java -jar selenium-server.jar -role hub -port 4444
@param port: listen port of selenium hub | webuidriver/remote/SeleniumJar.py | def hub(self, port):
''' java -jar selenium-server.jar -role hub -port 4444
@param port: listen port of selenium hub
'''
self._ip = "localhost"
self._port = port
self.command = [self._conf["java_path"], "-jar", self._conf["jar_path"], "-port", str(port), "-role",... | def hub(self, port):
''' java -jar selenium-server.jar -role hub -port 4444
@param port: listen port of selenium hub
'''
self._ip = "localhost"
self._port = port
self.command = [self._conf["java_path"], "-jar", self._conf["jar_path"], "-port", str(port), "-role",... | [
"java",
"-",
"jar",
"selenium",
"-",
"server",
".",
"jar",
"-",
"role",
"hub",
"-",
"port",
"4444"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/remote/SeleniumJar.py#L31-L38 | [
"def",
"hub",
"(",
"self",
",",
"port",
")",
":",
"self",
".",
"_ip",
"=",
"\"localhost\"",
"self",
".",
"_port",
"=",
"port",
"self",
".",
"command",
"=",
"[",
"self",
".",
"_conf",
"[",
"\"java_path\"",
"]",
",",
"\"-jar\"",
",",
"self",
".",
"_c... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | SeleniumJar.node | java -jar selenium-server.jar -role node -port 5555 -hub http://127.0.0.1:4444/grid/register/
@param port: listen port of selenium node
@param hub_address: hub address which node will connect to | webuidriver/remote/SeleniumJar.py | def node(self,port, hub_address=("localhost", 4444)):
''' java -jar selenium-server.jar -role node -port 5555 -hub http://127.0.0.1:4444/grid/register/
@param port: listen port of selenium node
@param hub_address: hub address which node will connect to
'''
self._ip, self._... | def node(self,port, hub_address=("localhost", 4444)):
''' java -jar selenium-server.jar -role node -port 5555 -hub http://127.0.0.1:4444/grid/register/
@param port: listen port of selenium node
@param hub_address: hub address which node will connect to
'''
self._ip, self._... | [
"java",
"-",
"jar",
"selenium",
"-",
"server",
".",
"jar",
"-",
"role",
"node",
"-",
"port",
"5555",
"-",
"hub",
"http",
":",
"//",
"127",
".",
"0",
".",
"0",
".",
"1",
":",
"4444",
"/",
"grid",
"/",
"register",
"/"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/remote/SeleniumJar.py#L40-L47 | [
"def",
"node",
"(",
"self",
",",
"port",
",",
"hub_address",
"=",
"(",
"\"localhost\"",
",",
"4444",
")",
")",
":",
"self",
".",
"_ip",
",",
"self",
".",
"_port",
"=",
"hub_address",
"self",
".",
"command",
"=",
"[",
"self",
".",
"_conf",
"[",
"\"j... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | SeleniumJar.start_server | start the selenium Remote Server. | webuidriver/remote/SeleniumJar.py | def start_server(self):
"""start the selenium Remote Server."""
self.__subp = subprocess.Popen(self.command)
#print("\tselenium jar pid[%s] is running." %self.__subp.pid)
time.sleep(2) | def start_server(self):
"""start the selenium Remote Server."""
self.__subp = subprocess.Popen(self.command)
#print("\tselenium jar pid[%s] is running." %self.__subp.pid)
time.sleep(2) | [
"start",
"the",
"selenium",
"Remote",
"Server",
"."
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/remote/SeleniumJar.py#L49-L53 | [
"def",
"start_server",
"(",
"self",
")",
":",
"self",
".",
"__subp",
"=",
"subprocess",
".",
"Popen",
"(",
"self",
".",
"command",
")",
"#print(\"\\tselenium jar pid[%s] is running.\" %self.__subp.pid) \r",
"time",
".",
"sleep",
"(",
"2",
")"
] | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | SeleniumJar.is_runnnig | Determine whether hub server is running
:return:True or False | webuidriver/remote/SeleniumJar.py | def is_runnnig(self):
"""Determine whether hub server is running
:return:True or False
"""
resp = None
try:
resp = requests.get("http://%s:%s" %(self._ip, self._port))
if resp.status_code == 200:
return True
else:
... | def is_runnnig(self):
"""Determine whether hub server is running
:return:True or False
"""
resp = None
try:
resp = requests.get("http://%s:%s" %(self._ip, self._port))
if resp.status_code == 200:
return True
else:
... | [
"Determine",
"whether",
"hub",
"server",
"is",
"running",
":",
"return",
":",
"True",
"or",
"False"
] | RockFeng0/rtsf-web | python | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/remote/SeleniumJar.py#L67-L80 | [
"def",
"is_runnnig",
"(",
"self",
")",
":",
"resp",
"=",
"None",
"try",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"\"http://%s:%s\"",
"%",
"(",
"self",
".",
"_ip",
",",
"self",
".",
"_port",
")",
")",
"if",
"resp",
".",
"status_code",
"==",
"2... | ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71 |
train | negate_gate | Implements two's complement negation. | aigerbv/common.py | def negate_gate(wordlen, input='x', output='~x'):
"""Implements two's complement negation."""
neg = bitwise_negate(wordlen, input, "tmp")
inc = inc_gate(wordlen, "tmp", output)
return neg >> inc | def negate_gate(wordlen, input='x', output='~x'):
"""Implements two's complement negation."""
neg = bitwise_negate(wordlen, input, "tmp")
inc = inc_gate(wordlen, "tmp", output)
return neg >> inc | [
"Implements",
"two",
"s",
"complement",
"negation",
"."
] | mvcisback/py-aiger-bv | python | https://github.com/mvcisback/py-aiger-bv/blob/855819844c429c35cdd8dc0b134bcd11f7b2fda3/aigerbv/common.py#L268-L272 | [
"def",
"negate_gate",
"(",
"wordlen",
",",
"input",
"=",
"'x'",
",",
"output",
"=",
"'~x'",
")",
":",
"neg",
"=",
"bitwise_negate",
"(",
"wordlen",
",",
"input",
",",
"\"tmp\"",
")",
"inc",
"=",
"inc_gate",
"(",
"wordlen",
",",
"\"tmp\"",
",",
"output"... | 855819844c429c35cdd8dc0b134bcd11f7b2fda3 |
train | kmodels | Return a circuit taking a wordlen bitvector where only k
valuations return True. Uses encoding from [1].
Note that this is equivalent to (~x < k).
- TODO: Add automated simplification so that the circuits
are equiv.
[1]: Chakraborty, Supratik, et al. "From Weighted to Unweighted Model
... | aigerbv/common.py | def kmodels(wordlen: int, k: int, input=None, output=None):
"""Return a circuit taking a wordlen bitvector where only k
valuations return True. Uses encoding from [1].
Note that this is equivalent to (~x < k).
- TODO: Add automated simplification so that the circuits
are equiv.
[1]: Ch... | def kmodels(wordlen: int, k: int, input=None, output=None):
"""Return a circuit taking a wordlen bitvector where only k
valuations return True. Uses encoding from [1].
Note that this is equivalent to (~x < k).
- TODO: Add automated simplification so that the circuits
are equiv.
[1]: Ch... | [
"Return",
"a",
"circuit",
"taking",
"a",
"wordlen",
"bitvector",
"where",
"only",
"k",
"valuations",
"return",
"True",
".",
"Uses",
"encoding",
"from",
"[",
"1",
"]",
"."
] | mvcisback/py-aiger-bv | python | https://github.com/mvcisback/py-aiger-bv/blob/855819844c429c35cdd8dc0b134bcd11f7b2fda3/aigerbv/common.py#L430-L464 | [
"def",
"kmodels",
"(",
"wordlen",
":",
"int",
",",
"k",
":",
"int",
",",
"input",
"=",
"None",
",",
"output",
"=",
"None",
")",
":",
"assert",
"0",
"<=",
"k",
"<",
"2",
"**",
"wordlen",
"if",
"output",
"is",
"None",
":",
"output",
"=",
"_fresh",
... | 855819844c429c35cdd8dc0b134bcd11f7b2fda3 |
train | flatten_list | Recursively flattens a list.
:param lobj: List to flatten
:type lobj: list
:rtype: list
For example:
>>> import pmisc
>>> pmisc.flatten_list([1, [2, 3, [4, 5, 6]], 7])
[1, 2, 3, 4, 5, 6, 7] | pmisc/misc.py | def flatten_list(lobj):
"""
Recursively flattens a list.
:param lobj: List to flatten
:type lobj: list
:rtype: list
For example:
>>> import pmisc
>>> pmisc.flatten_list([1, [2, 3, [4, 5, 6]], 7])
[1, 2, 3, 4, 5, 6, 7]
"""
ret = []
for item in lobj:
... | def flatten_list(lobj):
"""
Recursively flattens a list.
:param lobj: List to flatten
:type lobj: list
:rtype: list
For example:
>>> import pmisc
>>> pmisc.flatten_list([1, [2, 3, [4, 5, 6]], 7])
[1, 2, 3, 4, 5, 6, 7]
"""
ret = []
for item in lobj:
... | [
"Recursively",
"flattens",
"a",
"list",
"."
] | pmacosta/pmisc | python | https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/misc.py#L10-L32 | [
"def",
"flatten_list",
"(",
"lobj",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"item",
"in",
"lobj",
":",
"if",
"isinstance",
"(",
"item",
",",
"list",
")",
":",
"for",
"sub_item",
"in",
"flatten_list",
"(",
"item",
")",
":",
"ret",
".",
"append",
"(",... | dd2bb32e59eee872f1ef2db2d9921a396ab9f50b |
train | Config.auth | tuple of (username, password). if use_keyring is set to true the password will be queried from the local keyring instead of taken from the
configuration file. | studdp/config.py | def auth(self):
"""
tuple of (username, password). if use_keyring is set to true the password will be queried from the local keyring instead of taken from the
configuration file.
"""
username = self._settings["username"]
if not username:
raise ValueError("Use... | def auth(self):
"""
tuple of (username, password). if use_keyring is set to true the password will be queried from the local keyring instead of taken from the
configuration file.
"""
username = self._settings["username"]
if not username:
raise ValueError("Use... | [
"tuple",
"of",
"(",
"username",
"password",
")",
".",
"if",
"use_keyring",
"is",
"set",
"to",
"true",
"the",
"password",
"will",
"be",
"queried",
"from",
"the",
"local",
"keyring",
"instead",
"of",
"taken",
"from",
"the",
"configuration",
"file",
"."
] | CogSciUOS/StudDP | python | https://github.com/CogSciUOS/StudDP/blob/e953aea51766438f2901c9e87f5b7b9e5bb892f5/studdp/config.py#L98-L116 | [
"def",
"auth",
"(",
"self",
")",
":",
"username",
"=",
"self",
".",
"_settings",
"[",
"\"username\"",
"]",
"if",
"not",
"username",
":",
"raise",
"ValueError",
"(",
"\"Username was not configured in %s\"",
"%",
"CONFIG_FILE",
")",
"if",
"self",
".",
"_settings... | e953aea51766438f2901c9e87f5b7b9e5bb892f5 |
train | Config.load | load a configuration file. loads default config if file is not found | studdp/config.py | def load(self, file=CONFIG_FILE):
"""
load a configuration file. loads default config if file is not found
"""
if not os.path.exists(file):
print("Config file was not found under %s. Default file has been created" % CONFIG_FILE)
self._settings = yaml.load(DEFAULT_... | def load(self, file=CONFIG_FILE):
"""
load a configuration file. loads default config if file is not found
"""
if not os.path.exists(file):
print("Config file was not found under %s. Default file has been created" % CONFIG_FILE)
self._settings = yaml.load(DEFAULT_... | [
"load",
"a",
"configuration",
"file",
".",
"loads",
"default",
"config",
"if",
"file",
"is",
"not",
"found"
] | CogSciUOS/StudDP | python | https://github.com/CogSciUOS/StudDP/blob/e953aea51766438f2901c9e87f5b7b9e5bb892f5/studdp/config.py#L137-L147 | [
"def",
"load",
"(",
"self",
",",
"file",
"=",
"CONFIG_FILE",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"file",
")",
":",
"print",
"(",
"\"Config file was not found under %s. Default file has been created\"",
"%",
"CONFIG_FILE",
")",
"self",
... | e953aea51766438f2901c9e87f5b7b9e5bb892f5 |
train | Config.save | Save configuration to provided path as a yaml file | studdp/config.py | def save(self, file=CONFIG_FILE):
"""
Save configuration to provided path as a yaml file
"""
os.makedirs(os.path.dirname(file), exist_ok=True)
with open(file, "w") as f:
yaml.dump(self._settings, f, Dumper=yaml.RoundTripDumper, width=float("inf")) | def save(self, file=CONFIG_FILE):
"""
Save configuration to provided path as a yaml file
"""
os.makedirs(os.path.dirname(file), exist_ok=True)
with open(file, "w") as f:
yaml.dump(self._settings, f, Dumper=yaml.RoundTripDumper, width=float("inf")) | [
"Save",
"configuration",
"to",
"provided",
"path",
"as",
"a",
"yaml",
"file"
] | CogSciUOS/StudDP | python | https://github.com/CogSciUOS/StudDP/blob/e953aea51766438f2901c9e87f5b7b9e5bb892f5/studdp/config.py#L149-L155 | [
"def",
"save",
"(",
"self",
",",
"file",
"=",
"CONFIG_FILE",
")",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"file",
")",
",",
"exist_ok",
"=",
"True",
")",
"with",
"open",
"(",
"file",
",",
"\"w\"",
")",
"as",
"f",
... | e953aea51766438f2901c9e87f5b7b9e5bb892f5 |
train | Config.selection_dialog | opens a curses/picker based interface to select courses that should be downloaded. | studdp/config.py | def selection_dialog(self, courses):
"""
opens a curses/picker based interface to select courses that should be downloaded.
"""
selected = list(filter(lambda x: x.course.id in self._settings["selected_courses"], courses))
selection = Picker(
title="Select courses to d... | def selection_dialog(self, courses):
"""
opens a curses/picker based interface to select courses that should be downloaded.
"""
selected = list(filter(lambda x: x.course.id in self._settings["selected_courses"], courses))
selection = Picker(
title="Select courses to d... | [
"opens",
"a",
"curses",
"/",
"picker",
"based",
"interface",
"to",
"select",
"courses",
"that",
"should",
"be",
"downloaded",
"."
] | CogSciUOS/StudDP | python | https://github.com/CogSciUOS/StudDP/blob/e953aea51766438f2901c9e87f5b7b9e5bb892f5/studdp/config.py#L172-L184 | [
"def",
"selection_dialog",
"(",
"self",
",",
"courses",
")",
":",
"selected",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"course",
".",
"id",
"in",
"self",
".",
"_settings",
"[",
"\"selected_courses\"",
"]",
",",
"courses",
")",
")"... | e953aea51766438f2901c9e87f5b7b9e5bb892f5 |
train | ElasticIndex.create | Create the corresponding index. Will overwrite existing indexes of the same name. | simple_elastic/index.py | def create(self):
"""Create the corresponding index. Will overwrite existing indexes of the same name."""
body = dict()
if self.mapping is not None:
body['mappings'] = self.mapping
if self.settings is not None:
body['settings'] = self.settings
else:
... | def create(self):
"""Create the corresponding index. Will overwrite existing indexes of the same name."""
body = dict()
if self.mapping is not None:
body['mappings'] = self.mapping
if self.settings is not None:
body['settings'] = self.settings
else:
... | [
"Create",
"the",
"corresponding",
"index",
".",
"Will",
"overwrite",
"existing",
"indexes",
"of",
"the",
"same",
"name",
"."
] | UB-UNIBAS/simple-elastic | python | https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L75-L84 | [
"def",
"create",
"(",
"self",
")",
":",
"body",
"=",
"dict",
"(",
")",
"if",
"self",
".",
"mapping",
"is",
"not",
"None",
":",
"body",
"[",
"'mappings'",
"]",
"=",
"self",
".",
"mapping",
"if",
"self",
".",
"settings",
"is",
"not",
"None",
":",
"... | 54f2fdd3405a7eafbf8873f337da263b8d47532a |
train | ElasticIndex.search | Search the index with a query.
Can at most return 10'000 results from a search. If the search would yield more than 10'000 hits, only the first 10'000 are returned.
The default number of hits returned is 100. | simple_elastic/index.py | def search(self, query=None, size=100, unpack=True):
"""Search the index with a query.
Can at most return 10'000 results from a search. If the search would yield more than 10'000 hits, only the first 10'000 are returned.
The default number of hits returned is 100.
"""
logging.in... | def search(self, query=None, size=100, unpack=True):
"""Search the index with a query.
Can at most return 10'000 results from a search. If the search would yield more than 10'000 hits, only the first 10'000 are returned.
The default number of hits returned is 100.
"""
logging.in... | [
"Search",
"the",
"index",
"with",
"a",
"query",
"."
] | UB-UNIBAS/simple-elastic | python | https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L93-L112 | [
"def",
"search",
"(",
"self",
",",
"query",
"=",
"None",
",",
"size",
"=",
"100",
",",
"unpack",
"=",
"True",
")",
":",
"logging",
".",
"info",
"(",
"'Download all documents from index %s.'",
",",
"self",
".",
"index",
")",
"if",
"query",
"is",
"None",
... | 54f2fdd3405a7eafbf8873f337da263b8d47532a |
train | ElasticIndex.scan_index | Scan the index with the query.
Will return any number of results above 10'000. Important to note is, that
all the data is loaded into memory at once and returned. This works only with small
data sets. Use scroll otherwise which returns a generator to cycle through the resources
in set c... | simple_elastic/index.py | def scan_index(self, query: Union[Dict[str, str], None] = None) -> List[Dict[str, str]]:
"""Scan the index with the query.
Will return any number of results above 10'000. Important to note is, that
all the data is loaded into memory at once and returned. This works only with small
data ... | def scan_index(self, query: Union[Dict[str, str], None] = None) -> List[Dict[str, str]]:
"""Scan the index with the query.
Will return any number of results above 10'000. Important to note is, that
all the data is loaded into memory at once and returned. This works only with small
data ... | [
"Scan",
"the",
"index",
"with",
"the",
"query",
"."
] | UB-UNIBAS/simple-elastic | python | https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L114-L135 | [
"def",
"scan_index",
"(",
"self",
",",
"query",
":",
"Union",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
",",
"None",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"if",
"query",
"is",
"None",
":",
"q... | 54f2fdd3405a7eafbf8873f337da263b8d47532a |
train | ElasticIndex.scroll | Scroll an index with the specified search query.
Works as a generator. Will yield `size` results per iteration until all hits are returned. | simple_elastic/index.py | def scroll(self, query=None, scroll='5m', size=100, unpack=True):
"""Scroll an index with the specified search query.
Works as a generator. Will yield `size` results per iteration until all hits are returned.
"""
query = self.match_all if query is None else query
response = self... | def scroll(self, query=None, scroll='5m', size=100, unpack=True):
"""Scroll an index with the specified search query.
Works as a generator. Will yield `size` results per iteration until all hits are returned.
"""
query = self.match_all if query is None else query
response = self... | [
"Scroll",
"an",
"index",
"with",
"the",
"specified",
"search",
"query",
"."
] | UB-UNIBAS/simple-elastic | python | https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L137-L151 | [
"def",
"scroll",
"(",
"self",
",",
"query",
"=",
"None",
",",
"scroll",
"=",
"'5m'",
",",
"size",
"=",
"100",
",",
"unpack",
"=",
"True",
")",
":",
"query",
"=",
"self",
".",
"match_all",
"if",
"query",
"is",
"None",
"else",
"query",
"response",
"=... | 54f2fdd3405a7eafbf8873f337da263b8d47532a |
train | ElasticIndex.get | Fetch document by _id.
Returns None if it is not found. (Will log a warning if not found as well. Should not be used
to search an id.) | simple_elastic/index.py | def get(self, identifier):
"""Fetch document by _id.
Returns None if it is not found. (Will log a warning if not found as well. Should not be used
to search an id.)"""
logging.info('Download document with id ' + str(identifier) + '.')
try:
record = self.instance.get(... | def get(self, identifier):
"""Fetch document by _id.
Returns None if it is not found. (Will log a warning if not found as well. Should not be used
to search an id.)"""
logging.info('Download document with id ' + str(identifier) + '.')
try:
record = self.instance.get(... | [
"Fetch",
"document",
"by",
"_id",
"."
] | UB-UNIBAS/simple-elastic | python | https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L153-L166 | [
"def",
"get",
"(",
"self",
",",
"identifier",
")",
":",
"logging",
".",
"info",
"(",
"'Download document with id '",
"+",
"str",
"(",
"identifier",
")",
"+",
"'.'",
")",
"try",
":",
"record",
"=",
"self",
".",
"instance",
".",
"get",
"(",
"index",
"=",... | 54f2fdd3405a7eafbf8873f337da263b8d47532a |
train | ElasticIndex.index_into | Index a single document into the index. | simple_elastic/index.py | def index_into(self, document, id) -> bool:
"""Index a single document into the index."""
try:
self.instance.index(index=self.index, doc_type=self.doc_type, body=json.dumps(document, ensure_ascii=False), id=id)
except RequestError as ex:
logging.error(ex)
retu... | def index_into(self, document, id) -> bool:
"""Index a single document into the index."""
try:
self.instance.index(index=self.index, doc_type=self.doc_type, body=json.dumps(document, ensure_ascii=False), id=id)
except RequestError as ex:
logging.error(ex)
retu... | [
"Index",
"a",
"single",
"document",
"into",
"the",
"index",
"."
] | UB-UNIBAS/simple-elastic | python | https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L168-L176 | [
"def",
"index_into",
"(",
"self",
",",
"document",
",",
"id",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"instance",
".",
"index",
"(",
"index",
"=",
"self",
".",
"index",
",",
"doc_type",
"=",
"self",
".",
"doc_type",
",",
"body",
"=",
"json... | 54f2fdd3405a7eafbf8873f337da263b8d47532a |
train | ElasticIndex.delete | Delete a document with id. | simple_elastic/index.py | def delete(self, doc_id: str) -> bool:
"""Delete a document with id."""
try:
self.instance.delete(self.index, self.doc_type, doc_id)
except RequestError as ex:
logging.error(ex)
return False
else:
return True | def delete(self, doc_id: str) -> bool:
"""Delete a document with id."""
try:
self.instance.delete(self.index, self.doc_type, doc_id)
except RequestError as ex:
logging.error(ex)
return False
else:
return True | [
"Delete",
"a",
"document",
"with",
"id",
"."
] | UB-UNIBAS/simple-elastic | python | https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L178-L187 | [
"def",
"delete",
"(",
"self",
",",
"doc_id",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"instance",
".",
"delete",
"(",
"self",
".",
"index",
",",
"self",
".",
"doc_type",
",",
"doc_id",
")",
"except",
"RequestError",
"as",
"ex",
... | 54f2fdd3405a7eafbf8873f337da263b8d47532a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.