Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
TestStructBlock.test_render_structvalue
(self)
The HTML representation of a StructValue should use the block's template
The HTML representation of a StructValue should use the block's template
def test_render_structvalue(self): """ The HTML representation of a StructValue should use the block's template """ block = SectionBlock() value = block.to_python({'title': 'Hello', 'body': '<i>italic</i> world'}) result = value.__html__() self.assertEqual(result,...
[ "def", "test_render_structvalue", "(", "self", ")", ":", "block", "=", "SectionBlock", "(", ")", "value", "=", "block", ".", "to_python", "(", "{", "'title'", ":", "'Hello'", ",", "'body'", ":", "'<i>italic</i> world'", "}", ")", "result", "=", "value", "....
[ 1860, 4 ]
[ 1871, 73 ]
python
en
['en', 'error', 'th']
False
TestStructBlock.test_str_structvalue
(self)
The str() representation of a StructValue should NOT render the template, as that's liable to cause an infinite loop if any debugging / logging code attempts to log the fact that it rendered a template with this object in the context: https://github.com/wagtail/wagtail/issues/2874 ...
The str() representation of a StructValue should NOT render the template, as that's liable to cause an infinite loop if any debugging / logging code attempts to log the fact that it rendered a template with this object in the context: https://github.com/wagtail/wagtail/issues/2874 ...
def test_str_structvalue(self): """ The str() representation of a StructValue should NOT render the template, as that's liable to cause an infinite loop if any debugging / logging code attempts to log the fact that it rendered a template with this object in the context: https://g...
[ "def", "test_str_structvalue", "(", "self", ")", ":", "block", "=", "SectionBlock", "(", ")", "value", "=", "block", ".", "to_python", "(", "{", "'title'", ":", "'Hello'", ",", "'body'", ":", "'<i>italic</i> world'", "}", ")", "result", "=", "str", "(", ...
[ 1873, 4 ]
[ 1890, 38 ]
python
en
['en', 'error', 'th']
False
TestListBlock.test_render_calls_block_render_on_children
(self)
The default rendering of a ListBlock should invoke the block's render method on each child, rather than just outputting the child value as a string.
The default rendering of a ListBlock should invoke the block's render method on each child, rather than just outputting the child value as a string.
def test_render_calls_block_render_on_children(self): """ The default rendering of a ListBlock should invoke the block's render method on each child, rather than just outputting the child value as a string. """ block = blocks.ListBlock( blocks.CharBlock(template='test...
[ "def", "test_render_calls_block_render_on_children", "(", "self", ")", ":", "block", "=", "blocks", ".", "ListBlock", "(", "blocks", ".", "CharBlock", "(", "template", "=", "'tests/blocks/heading_block.html'", ")", ")", "html", "=", "block", ".", "render", "(", ...
[ 2105, 4 ]
[ 2116, 54 ]
python
en
['en', 'error', 'th']
False
TestListBlock.test_render_passes_context_to_children
(self)
Template context passed to the render method should be passed on to the render method of the child block.
Template context passed to the render method should be passed on to the render method of the child block.
def test_render_passes_context_to_children(self): """ Template context passed to the render method should be passed on to the render method of the child block. """ block = blocks.ListBlock( blocks.CharBlock(template='tests/blocks/heading_block.html') ) ...
[ "def", "test_render_passes_context_to_children", "(", "self", ")", ":", "block", "=", "blocks", ".", "ListBlock", "(", "blocks", ".", "CharBlock", "(", "template", "=", "'tests/blocks/heading_block.html'", ")", ")", "html", "=", "block", ".", "render", "(", "[",...
[ 2118, 4 ]
[ 2131, 69 ]
python
en
['en', 'error', 'th']
False
TestListBlock.test_get_api_representation_calls_same_method_on_children_with_context
(self)
The get_api_representation method of a ListBlock should invoke the block's get_api_representation method on each child and the context should be passed on.
The get_api_representation method of a ListBlock should invoke the block's get_api_representation method on each child and the context should be passed on.
def test_get_api_representation_calls_same_method_on_children_with_context(self): """ The get_api_representation method of a ListBlock should invoke the block's get_api_representation method on each child and the context should be passed on. """ class ContextBlock(blocks....
[ "def", "test_get_api_representation_calls_same_method_on_children_with_context", "(", "self", ")", ":", "class", "ContextBlock", "(", "blocks", ".", "CharBlock", ")", ":", "def", "get_api_representation", "(", "self", ",", "value", ",", "context", "=", "None", ")", ...
[ 2133, 4 ]
[ 2153, 9 ]
python
en
['en', 'error', 'th']
False
TestListBlock.test_default_default
(self)
if no explicit 'default' is set on the ListBlock, it should fall back on a single instance of the child block in its default state.
if no explicit 'default' is set on the ListBlock, it should fall back on a single instance of the child block in its default state.
def test_default_default(self): """ if no explicit 'default' is set on the ListBlock, it should fall back on a single instance of the child block in its default state. """ block = blocks.ListBlock(blocks.CharBlock(default='chocolate')) self.assertEqual(block.get_default(...
[ "def", "test_default_default", "(", "self", ")", ":", "block", "=", "blocks", ".", "ListBlock", "(", "blocks", ".", "CharBlock", "(", "default", "=", "'chocolate'", ")", ")", "self", ".", "assertEqual", "(", "block", ".", "get_default", "(", ")", ",", "[...
[ 2274, 4 ]
[ 2285, 49 ]
python
en
['en', 'error', 'th']
False
TestListBlock.test_default_value_is_distinct_instance
(self)
Whenever the default value of a ListBlock is invoked, it should be a distinct instance of the list so that modifying it doesn't modify other places where the default value appears.
Whenever the default value of a ListBlock is invoked, it should be a distinct instance of the list so that modifying it doesn't modify other places where the default value appears.
def test_default_value_is_distinct_instance(self): """ Whenever the default value of a ListBlock is invoked, it should be a distinct instance of the list so that modifying it doesn't modify other places where the default value appears. """ class ShoppingListBlock(blocks.S...
[ "def", "test_default_value_is_distinct_instance", "(", "self", ")", ":", "class", "ShoppingListBlock", "(", "blocks", ".", "StructBlock", ")", ":", "shop", "=", "blocks", ".", "CharBlock", "(", ")", "items", "=", "blocks", ".", "ListBlock", "(", "blocks", ".",...
[ 2287, 4 ]
[ 2305, 63 ]
python
en
['en', 'error', 'th']
False
TestListBlock.test_adapt_with_classname_via_kwarg
(self)
form_classname from kwargs to be used as an additional class when rendering list block
form_classname from kwargs to be used as an additional class when rendering list block
def test_adapt_with_classname_via_kwarg(self): """form_classname from kwargs to be used as an additional class when rendering list block""" class LinkBlock(blocks.StructBlock): title = blocks.CharBlock() link = blocks.URLBlock() block = blocks.ListBlock(LinkBlock, form_...
[ "def", "test_adapt_with_classname_via_kwarg", "(", "self", ")", ":", "class", "LinkBlock", "(", "blocks", ".", "StructBlock", ")", ":", "title", "=", "blocks", ".", "CharBlock", "(", ")", "link", "=", "blocks", ".", "URLBlock", "(", ")", "block", "=", "blo...
[ 2307, 4 ]
[ 2330, 10 ]
python
en
['en', 'en', 'en']
True
TestListBlock.test_adapt_with_classname_via_class_meta
(self)
form_classname from meta to be used as an additional class when rendering list block
form_classname from meta to be used as an additional class when rendering list block
def test_adapt_with_classname_via_class_meta(self): """form_classname from meta to be used as an additional class when rendering list block""" class LinkBlock(blocks.StructBlock): title = blocks.CharBlock() link = blocks.URLBlock() class CustomListBlock(blocks.ListBlock...
[ "def", "test_adapt_with_classname_via_class_meta", "(", "self", ")", ":", "class", "LinkBlock", "(", "blocks", ".", "StructBlock", ")", ":", "title", "=", "blocks", ".", "CharBlock", "(", ")", "link", "=", "blocks", ".", "URLBlock", "(", ")", "class", "Custo...
[ 2332, 4 ]
[ 2360, 10 ]
python
en
['en', 'en', 'en']
True
DataAccessor.__init__
(self)
Base class for accessors used with :class:`tkp.sourcefinder.image.ImageData`. Data accessors provide a uniform way for the ImageData class (ie, generic image representation) to access the various ways in which images may be stored (FITS files, arrays in memory, potentially HDF5...
Base class for accessors used with :class:`tkp.sourcefinder.image.ImageData`.
def __init__(self): # Sphinx only picks up the class docstring if it's under an __init__ # *le sigh* """ Base class for accessors used with :class:`tkp.sourcefinder.image.ImageData`. Data accessors provide a uniform way for the ImageData class (ie, generic image ...
[ "def", "__init__", "(", "self", ")", ":", "# Sphinx only picks up the class docstring if it's under an __init__", "# *le sigh*" ]
[ 24, 4 ]
[ 75, 11 ]
python
en
['en', 'error', 'th']
False
DataAccessor.extract_metadata
(self)
Massage the class attributes into a flat dictionary with database-friendly values. While rather tedious, this is easy to serialize and store separately to the actual image data. May be extended by subclasses to return additional data.
Massage the class attributes into a flat dictionary with database-friendly values.
def extract_metadata(self): """ Massage the class attributes into a flat dictionary with database-friendly values. While rather tedious, this is easy to serialize and store separately to the actual image data. May be extended by subclasses to return additional data. ...
[ "def", "extract_metadata", "(", "self", ")", ":", "return", "{", "'tau_time'", ":", "self", ".", "tau_time", ",", "'freq_eff'", ":", "self", ".", "freq_eff", ",", "'freq_bw'", ":", "self", ".", "freq_bw", ",", "'taustart_ts'", ":", "self", ".", "taustart_t...
[ 77, 4 ]
[ 100, 9 ]
python
en
['en', 'error', 'th']
False
DataAccessor.parse_pixelsize
(self)
Returns: - deltax: pixel size along the x axis in degrees - deltay: pixel size along the x axis in degrees
def parse_pixelsize(self): """ Returns: - deltax: pixel size along the x axis in degrees - deltay: pixel size along the x axis in degrees """ wcs = self.wcs # Check that pixels are square # (Would have to be pretty strange data for this not to be the...
[ "def", "parse_pixelsize", "(", "self", ")", ":", "wcs", "=", "self", ".", "wcs", "# Check that pixels are square", "# (Would have to be pretty strange data for this not to be the case)", "assert", "wcs", ".", "cunit", "[", "0", "]", "==", "wcs", ".", "cunit", "[", "...
[ 102, 4 ]
[ 129, 29 ]
python
en
['en', 'error', 'th']
False
DataAccessor.degrees2pixels
(bmaj, bmin, bpa, deltax, deltay)
Convert beam in degrees to beam in pixels and radians. For example Fits beam parameters are in degrees. Arguments: - bmaj: Beam major axis in degrees - bmin: Beam minor axis in degrees - bpa: Beam position angle in degrees - deltax: Pixel size alo...
Convert beam in degrees to beam in pixels and radians. For example Fits beam parameters are in degrees.
def degrees2pixels(bmaj, bmin, bpa, deltax, deltay): """ Convert beam in degrees to beam in pixels and radians. For example Fits beam parameters are in degrees. Arguments: - bmaj: Beam major axis in degrees - bmin: Beam minor axis in degrees - bpa: B...
[ "def", "degrees2pixels", "(", "bmaj", ",", "bmin", ",", "bpa", ",", "deltax", ",", "deltay", ")", ":", "semimaj", "=", "(", "bmaj", "/", "2.", ")", "*", "(", "sqrt", "(", "(", "sin", "(", "pi", "*", "bpa", "/", "180.", ")", "**", "2", ")", "/...
[ 132, 4 ]
[ 158, 40 ]
python
en
['en', 'error', 'th']
False
get_host_platform
()
Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included...
Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included...
def get_host_platform(): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although th...
[ "def", "get_host_platform", "(", ")", ":", "if", "os", ".", "name", "==", "'nt'", ":", "if", "'amd64'", "in", "sys", ".", "version", ".", "lower", "(", ")", ":", "return", "'win-amd64'", "if", "'(arm)'", "in", "sys", ".", "version", ".", "lower", "("...
[ 19, 0 ]
[ 97, 50 ]
python
en
['en', 'en', 'en']
True
convert_path
(pathname)
Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can ...
Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can ...
def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the...
[ "def", "convert_path", "(", "pathname", ")", ":", "if", "os", ".", "sep", "==", "'/'", ":", "return", "pathname", "if", "not", "pathname", ":", "return", "pathname", "if", "pathname", "[", "0", "]", "==", "'/'", ":", "raise", "ValueError", "(", "\"path...
[ 110, 0 ]
[ 133, 31 ]
python
en
['en', 'en', 'en']
True
change_root
(new_root, pathname)
Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.
Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. """ if...
[ "def", "change_root", "(", "new_root", ",", "pathname", ")", ":", "if", "os", ".", "name", "==", "'posix'", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "pathname", ")", ":", "return", "os", ".", "path", ".", "join", "(", "new_root", ","...
[ 138, 0 ]
[ 157, 83 ]
python
en
['en', 'en', 'en']
True
check_environ
()
Ensure that 'os.environ' has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes: HOME - user's home directory (Unix only) PLAT - description of the current platform, including hardware and OS (see 'get_platf...
Ensure that 'os.environ' has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes: HOME - user's home directory (Unix only) PLAT - description of the current platform, including hardware and OS (see 'get_platf...
def check_environ (): """Ensure that 'os.environ' has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes: HOME - user's home directory (Unix only) PLAT - description of the current platform, including hardware ...
[ "def", "check_environ", "(", ")", ":", "global", "_environ_checked", "if", "_environ_checked", ":", "return", "if", "os", ".", "name", "==", "'posix'", "and", "'HOME'", "not", "in", "os", ".", "environ", ":", "try", ":", "import", "pwd", "os", ".", "envi...
[ 161, 0 ]
[ 185, 24 ]
python
en
['en', 'en', 'en']
True
subst_vars
(s, local_vars)
Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guar...
Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guar...
def subst_vars (s, local_vars): """Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.envi...
[ "def", "subst_vars", "(", "s", ",", "local_vars", ")", ":", "check_environ", "(", ")", "def", "_subst", "(", "match", ",", "local_vars", "=", "local_vars", ")", ":", "var_name", "=", "match", ".", "group", "(", "1", ")", "if", "var_name", "in", "local_...
[ 188, 0 ]
[ 208, 56 ]
python
en
['en', 'en', 'en']
True
split_quoted
(s)
Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The b...
Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The b...
def split_quoted (s): """Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can ...
[ "def", "split_quoted", "(", "s", ")", ":", "# This is a nice algorithm for splitting up a single string, since it", "# doesn't require character-by-character examination. It was a little", "# bit of a brain-bender to get it working right, though...", "if", "_wordchars_re", "is", "None", "...
[ 228, 0 ]
[ 284, 16 ]
python
en
['en', 'en', 'en']
True
execute
(func, args, msg=None, verbose=0, dry_run=0)
Perform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an argument tuple for it (to e...
Perform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an argument tuple for it (to e...
def execute (func, args, msg=None, verbose=0, dry_run=0): """Perform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is s...
[ "def", "execute", "(", "func", ",", "args", ",", "msg", "=", "None", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ")", ":", "if", "msg", "is", "None", ":", "msg", "=", "\"%s%r\"", "%", "(", "func", ".", "__name__", ",", "args", ")", "if"...
[ 289, 0 ]
[ 305, 19 ]
python
en
['en', 'en', 'en']
True
strtobool
(val)
Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else.
Convert a string representation of truth to true (1) or false (0).
def strtobool (val): """Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. """ val = val.lower() if val in ('y', 'y...
[ "def", "strtobool", "(", "val", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "if", "val", "in", "(", "'y'", ",", "'yes'", ",", "'t'", ",", "'true'", ",", "'on'", ",", "'1'", ")", ":", "return", "1", "elif", "val", "in", "(", "'n'", ",...
[ 308, 0 ]
[ 321, 59 ]
python
en
['en', 'pt', 'en']
True
byte_compile
(py_files, optimize=0, force=0, prefix=None, base_dir=None, verbose=1, dry_run=0, direct=None)
Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize 1 - normal optimization (like "python -O")...
Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize 1 - normal optimization (like "python -O")...
def byte_compile (py_files, optimize=0, force=0, prefix=None, base_dir=None, verbose=1, dry_run=0, direct=None): """Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of f...
[ "def", "byte_compile", "(", "py_files", ",", "optimize", "=", "0", ",", "force", "=", "0", ",", "prefix", "=", "None", ",", "base_dir", "=", "None", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ",", "direct", "=", "None", ")", ":", "# Late i...
[ 324, 0 ]
[ 469, 47 ]
python
en
['en', 'en', 'en']
True
rfc822_escape
(header)
Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline.
Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline.
def rfc822_escape (header): """Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline. """ lines = header.split('\n') sep = '\n' + 8 * ' ' return sep.join(lines)
[ "def", "rfc822_escape", "(", "header", ")", ":", "lines", "=", "header", ".", "split", "(", "'\\n'", ")", "sep", "=", "'\\n'", "+", "8", "*", "' '", "return", "sep", ".", "join", "(", "lines", ")" ]
[ 473, 0 ]
[ 479, 26 ]
python
en
['en', 'en', 'en']
True
run_2to3
(files, fixer_names=None, options=None, explicit=None)
Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done in-place. To reduce the build time, only files modified since the last invocation of this function should be passed in the files argument.
Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done in-place. To reduce the build time, only files modified since the last invocation of this function should be passed in the files argument.
def run_2to3(files, fixer_names=None, options=None, explicit=None): """Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done in-place. To reduce the build time, only files modified since the last invocation of this function should be passed...
[ "def", "run_2to3", "(", "files", ",", "fixer_names", "=", "None", ",", "options", "=", "None", ",", "explicit", "=", "None", ")", ":", "if", "not", "files", ":", "return", "# Make this class local, to delay import of 2to3", "from", "lib2to3", ".", "refactor", ...
[ 483, 0 ]
[ 508, 33 ]
python
en
['en', 'haw', 'en']
True
copydir_run_2to3
(src, dest, template=None, fixer_names=None, options=None, explicit=None)
Recursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward. If you give a template string, it's parsed like a MANIFEST.in.
Recursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward.
def copydir_run_2to3(src, dest, template=None, fixer_names=None, options=None, explicit=None): """Recursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward. If you give a template string, it's parsed like a MANIFES...
[ "def", "copydir_run_2to3", "(", "src", ",", "dest", ",", "template", "=", "None", ",", "fixer_names", "=", "None", ",", "options", "=", "None", ",", "explicit", "=", "None", ")", ":", "from", "distutils", ".", "dir_util", "import", "mkpath", "from", "dis...
[ 510, 0 ]
[ 541, 17 ]
python
en
['en', 'en', 'en']
True
get_version
(version=None)
Returns a PEP 440-compliant version number from VERSION.
Returns a PEP 440-compliant version number from VERSION.
def get_version(version=None): "Returns a PEP 440-compliant version number from VERSION." version = get_complete_version(version) # Now build the two parts of the version number: # main = X.Y[.Z] # sub = .devN - for pre-alpha releases # | {a|b|rc}N - for alpha, beta, and rc releases ma...
[ "def", "get_version", "(", "version", "=", "None", ")", ":", "version", "=", "get_complete_version", "(", "version", ")", "# Now build the two parts of the version number:", "# main = X.Y[.Z]", "# sub = .devN - for pre-alpha releases", "# | {a|b|rc}N - for alpha, beta, and rc r...
[ 9, 0 ]
[ 30, 26 ]
python
en
['en', 'en', 'en']
True
get_main_version
(version=None)
Returns main version (X.Y[.Z]) from VERSION.
Returns main version (X.Y[.Z]) from VERSION.
def get_main_version(version=None): "Returns main version (X.Y[.Z]) from VERSION." version = get_complete_version(version) parts = 2 if version[2] == 0 else 3 return '.'.join(str(x) for x in version[:parts])
[ "def", "get_main_version", "(", "version", "=", "None", ")", ":", "version", "=", "get_complete_version", "(", "version", ")", "parts", "=", "2", "if", "version", "[", "2", "]", "==", "0", "else", "3", "return", "'.'", ".", "join", "(", "str", "(", "...
[ 33, 0 ]
[ 37, 52 ]
python
en
['en', 'en', 'en']
True
get_complete_version
(version=None)
Returns a tuple of the django version. If version argument is non-empty, then checks for correctness of the tuple provided.
Returns a tuple of the django version. If version argument is non-empty, then checks for correctness of the tuple provided.
def get_complete_version(version=None): """Returns a tuple of the django version. If version argument is non-empty, then checks for correctness of the tuple provided. """ if version is None: from django import VERSION as version else: assert len(version) == 5 assert version[3...
[ "def", "get_complete_version", "(", "version", "=", "None", ")", ":", "if", "version", "is", "None", ":", "from", "django", "import", "VERSION", "as", "version", "else", ":", "assert", "len", "(", "version", ")", "==", "5", "assert", "version", "[", "3",...
[ 40, 0 ]
[ 50, 18 ]
python
en
['en', 'en', 'en']
True
get_git_changeset
()
Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the development version numbers.
Returns a numeric identifier of the latest git changeset.
def get_git_changeset(): """Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the development version numbers....
[ "def", "get_git_changeset", "(", ")", ":", "repo_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ")", "git_log", "=", "subprocess", ".", "Popen",...
[ 62, 0 ]
[ 80, 45 ]
python
en
['en', 'en', 'en']
True
RemovePrefix
(a, prefix)
Returns 'a' without 'prefix' if it starts with 'prefix'.
Returns 'a' without 'prefix' if it starts with 'prefix'.
def RemovePrefix(a, prefix): """Returns 'a' without 'prefix' if it starts with 'prefix'.""" return a[len(prefix) :] if a.startswith(prefix) else a
[ "def", "RemovePrefix", "(", "a", ",", "prefix", ")", ":", "return", "a", "[", "len", "(", "prefix", ")", ":", "]", "if", "a", ".", "startswith", "(", "prefix", ")", "else", "a" ]
[ 81, 0 ]
[ 83, 58 ]
python
en
['en', 'en', 'en']
True
CalculateVariables
(default_variables, params)
Calculate additional variables for use in the build (called by gyp).
Calculate additional variables for use in the build (called by gyp).
def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" default_variables.setdefault("OS", gyp.common.GetFlavor(params))
[ "def", "CalculateVariables", "(", "default_variables", ",", "params", ")", ":", "default_variables", ".", "setdefault", "(", "\"OS\"", ",", "gyp", ".", "common", ".", "GetFlavor", "(", "params", ")", ")" ]
[ 86, 0 ]
[ 88, 68 ]
python
en
['en', 'en', 'en']
True
Compilable
(filename)
Return true if the file is compilable (should be in OBJS).
Return true if the file is compilable (should be in OBJS).
def Compilable(filename): """Return true if the file is compilable (should be in OBJS).""" return any(filename.endswith(e) for e in COMPILABLE_EXTENSIONS)
[ "def", "Compilable", "(", "filename", ")", ":", "return", "any", "(", "filename", ".", "endswith", "(", "e", ")", "for", "e", "in", "COMPILABLE_EXTENSIONS", ")" ]
[ 91, 0 ]
[ 93, 67 ]
python
en
['en', 'en', 'en']
True
Linkable
(filename)
Return true if the file is linkable (should be on the link line).
Return true if the file is linkable (should be on the link line).
def Linkable(filename): """Return true if the file is linkable (should be on the link line).""" return filename.endswith(".o")
[ "def", "Linkable", "(", "filename", ")", ":", "return", "filename", ".", "endswith", "(", "\".o\"", ")" ]
[ 96, 0 ]
[ 98, 34 ]
python
en
['en', 'en', 'en']
True
NormjoinPathForceCMakeSource
(base_path, rel_path)
Resolves rel_path against base_path and returns the result. If rel_path is an absolute path it is returned unchanged. Otherwise it is resolved against base_path and normalized. If the result is a relative path, it is forced to be relative to the CMakeLists.txt.
Resolves rel_path against base_path and returns the result.
def NormjoinPathForceCMakeSource(base_path, rel_path): """Resolves rel_path against base_path and returns the result. If rel_path is an absolute path it is returned unchanged. Otherwise it is resolved against base_path and normalized. If the result is a relative path, it is forced to be relative to the CMa...
[ "def", "NormjoinPathForceCMakeSource", "(", "base_path", ",", "rel_path", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "rel_path", ")", ":", "return", "rel_path", "if", "any", "(", "[", "rel_path", ".", "startswith", "(", "var", ")", "for", "var...
[ 101, 0 ]
[ 116, 5 ]
python
en
['en', 'en', 'en']
True
NormjoinPath
(base_path, rel_path)
Resolves rel_path against base_path and returns the result. TODO: what is this really used for? If rel_path begins with '$' it is returned unchanged. Otherwise it is resolved against base_path if relative, then normalized.
Resolves rel_path against base_path and returns the result. TODO: what is this really used for? If rel_path begins with '$' it is returned unchanged. Otherwise it is resolved against base_path if relative, then normalized.
def NormjoinPath(base_path, rel_path): """Resolves rel_path against base_path and returns the result. TODO: what is this really used for? If rel_path begins with '$' it is returned unchanged. Otherwise it is resolved against base_path if relative, then normalized. """ if rel_path.startswith("$") and not...
[ "def", "NormjoinPath", "(", "base_path", ",", "rel_path", ")", ":", "if", "rel_path", ".", "startswith", "(", "\"$\"", ")", "and", "not", "rel_path", ".", "startswith", "(", "\"${configuration}\"", ")", ":", "return", "rel_path", "return", "os", ".", "path",...
[ 119, 0 ]
[ 127, 62 ]
python
en
['en', 'en', 'en']
True
CMakeStringEscape
(a)
Escapes the string 'a' for use inside a CMake string. This means escaping '\' otherwise it may be seen as modifying the next character '"' otherwise it will end the string ';' otherwise the string becomes a list The following do not need to be escaped '#' when the lexer is in string state, this does not s...
Escapes the string 'a' for use inside a CMake string.
def CMakeStringEscape(a): """Escapes the string 'a' for use inside a CMake string. This means escaping '\' otherwise it may be seen as modifying the next character '"' otherwise it will end the string ';' otherwise the string becomes a list The following do not need to be escaped '#' when the lexer is...
[ "def", "CMakeStringEscape", "(", "a", ")", ":", "return", "a", ".", "replace", "(", "\"\\\\\"", ",", "\"\\\\\\\\\"", ")", ".", "replace", "(", "\";\"", ",", "\"\\\\;\"", ")", ".", "replace", "(", "'\"'", ",", "'\\\\\"'", ")" ]
[ 130, 0 ]
[ 146, 74 ]
python
en
['en', 'en', 'en']
True
SetFileProperty
(output, source_name, property_name, values, sep)
Given a set of source file, sets the given property on them.
Given a set of source file, sets the given property on them.
def SetFileProperty(output, source_name, property_name, values, sep): """Given a set of source file, sets the given property on them.""" output.write("set_source_files_properties(") output.write(source_name) output.write(" PROPERTIES ") output.write(property_name) output.write(' "') for valu...
[ "def", "SetFileProperty", "(", "output", ",", "source_name", ",", "property_name", ",", "values", ",", "sep", ")", ":", "output", ".", "write", "(", "\"set_source_files_properties(\"", ")", "output", ".", "write", "(", "source_name", ")", "output", ".", "write...
[ 149, 0 ]
[ 159, 24 ]
python
en
['en', 'en', 'en']
True
SetFilesProperty
(output, variable, property_name, values, sep)
Given a set of source files, sets the given property on them.
Given a set of source files, sets the given property on them.
def SetFilesProperty(output, variable, property_name, values, sep): """Given a set of source files, sets the given property on them.""" output.write("set_source_files_properties(") WriteVariable(output, variable) output.write(" PROPERTIES ") output.write(property_name) output.write(' "') for...
[ "def", "SetFilesProperty", "(", "output", ",", "variable", ",", "property_name", ",", "values", ",", "sep", ")", ":", "output", ".", "write", "(", "\"set_source_files_properties(\"", ")", "WriteVariable", "(", "output", ",", "variable", ")", "output", ".", "wr...
[ 162, 0 ]
[ 172, 24 ]
python
en
['en', 'en', 'en']
True
SetTargetProperty
(output, target_name, property_name, values, sep="")
Given a target, sets the given property.
Given a target, sets the given property.
def SetTargetProperty(output, target_name, property_name, values, sep=""): """Given a target, sets the given property.""" output.write("set_target_properties(") output.write(target_name) output.write(" PROPERTIES ") output.write(property_name) output.write(' "') for value in values: ...
[ "def", "SetTargetProperty", "(", "output", ",", "target_name", ",", "property_name", ",", "values", ",", "sep", "=", "\"\"", ")", ":", "output", ".", "write", "(", "\"set_target_properties(\"", ")", "output", ".", "write", "(", "target_name", ")", "output", ...
[ 175, 0 ]
[ 185, 24 ]
python
en
['en', 'en', 'en']
True
SetVariable
(output, variable_name, value)
Sets a CMake variable.
Sets a CMake variable.
def SetVariable(output, variable_name, value): """Sets a CMake variable.""" output.write("set(") output.write(variable_name) output.write(' "') output.write(CMakeStringEscape(value)) output.write('")\n')
[ "def", "SetVariable", "(", "output", ",", "variable_name", ",", "value", ")", ":", "output", ".", "write", "(", "\"set(\"", ")", "output", ".", "write", "(", "variable_name", ")", "output", ".", "write", "(", "' \"'", ")", "output", ".", "write", "(", ...
[ 188, 0 ]
[ 194, 24 ]
python
en
['en', 'fil', 'en']
True
SetVariableList
(output, variable_name, values)
Sets a CMake variable to a list.
Sets a CMake variable to a list.
def SetVariableList(output, variable_name, values): """Sets a CMake variable to a list.""" if not values: return SetVariable(output, variable_name, "") if len(values) == 1: return SetVariable(output, variable_name, values[0]) output.write("list(APPEND ") output.write(variable_name) ...
[ "def", "SetVariableList", "(", "output", ",", "variable_name", ",", "values", ")", ":", "if", "not", "values", ":", "return", "SetVariable", "(", "output", ",", "variable_name", ",", "\"\"", ")", "if", "len", "(", "values", ")", "==", "1", ":", "return",...
[ 197, 0 ]
[ 207, 24 ]
python
en
['en', 'en', 'en']
True
UnsetVariable
(output, variable_name)
Unsets a CMake variable.
Unsets a CMake variable.
def UnsetVariable(output, variable_name): """Unsets a CMake variable.""" output.write("unset(") output.write(variable_name) output.write(")\n")
[ "def", "UnsetVariable", "(", "output", ",", "variable_name", ")", ":", "output", ".", "write", "(", "\"unset(\"", ")", "output", ".", "write", "(", "variable_name", ")", "output", ".", "write", "(", "\")\\n\"", ")" ]
[ 210, 0 ]
[ 214, 23 ]
python
en
['en', 'en', 'en']
True
StringToCMakeTargetName
(a)
Converts the given string 'a' to a valid CMake target name. All invalid characters are replaced by '_'. Invalid for cmake: ' ', '/', '(', ')', '"' Invalid for make: ':' Invalid for unknown reasons but cause failures: '.'
Converts the given string 'a' to a valid CMake target name.
def StringToCMakeTargetName(a): """Converts the given string 'a' to a valid CMake target name. All invalid characters are replaced by '_'. Invalid for cmake: ' ', '/', '(', ')', '"' Invalid for make: ':' Invalid for unknown reasons but cause failures: '.' """ return a.translate(_maketrans(' /():."', ...
[ "def", "StringToCMakeTargetName", "(", "a", ")", ":", "return", "a", ".", "translate", "(", "_maketrans", "(", "' /():.\"'", ",", "\"_______\"", ")", ")" ]
[ 241, 0 ]
[ 249, 56 ]
python
en
['en', 'en', 'en']
True
WriteActions
(target_name, actions, extra_sources, extra_deps, path_to_gyp, output)
Write CMake for the 'actions' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_sources: [(<cmake_src>, <src>)] to append with generated source files. extra_deps: [<cmake_taget>] to append with generated targets. ...
Write CMake for the 'actions' in the target.
def WriteActions(target_name, actions, extra_sources, extra_deps, path_to_gyp, output): """Write CMake for the 'actions' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_sources: [(<cmake_src>, <src>)] to append wit...
[ "def", "WriteActions", "(", "target_name", ",", "actions", ",", "extra_sources", ",", "extra_deps", ",", "path_to_gyp", ",", "output", ")", ":", "for", "action", "in", "actions", ":", "action_name", "=", "StringToCMakeTargetName", "(", "action", "[", "\"action_n...
[ 252, 0 ]
[ 331, 45 ]
python
en
['en', 'en', 'en']
True
WriteRules
(target_name, rules, extra_sources, extra_deps, path_to_gyp, output)
Write CMake for the 'rules' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_sources: [(<cmake_src>, <src>)] to append with generated source files. extra_deps: [<cmake_taget>] to append with generated targets. p...
Write CMake for the 'rules' in the target.
def WriteRules(target_name, rules, extra_sources, extra_deps, path_to_gyp, output): """Write CMake for the 'rules' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_sources: [(<cmake_src>, <src>)] to append with gene...
[ "def", "WriteRules", "(", "target_name", ",", "rules", ",", "extra_sources", ",", "extra_deps", ",", "path_to_gyp", ",", "output", ")", ":", "for", "rule", "in", "rules", ":", "rule_name", "=", "StringToCMakeTargetName", "(", "target_name", "+", "\"__\"", "+",...
[ 341, 0 ]
[ 456, 36 ]
python
en
['en', 'en', 'en']
True
WriteCopies
(target_name, copies, extra_deps, path_to_gyp, output)
Write CMake for the 'copies' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_deps: [<cmake_taget>] to append with generated targets. path_to_gyp: relative path from CMakeLists.txt being generated to the Gyp...
Write CMake for the 'copies' in the target.
def WriteCopies(target_name, copies, extra_deps, path_to_gyp, output): """Write CMake for the 'copies' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_deps: [<cmake_taget>] to append with generated targets. pat...
[ "def", "WriteCopies", "(", "target_name", ",", "copies", ",", "extra_deps", ",", "path_to_gyp", ",", "output", ")", ":", "copy_name", "=", "target_name", "+", "\"__copies\"", "# CMake gets upset with custom targets with OUTPUT which specify no output.", "have_copies", "=", ...
[ 459, 0 ]
[ 564, 32 ]
python
en
['en', 'en', 'en']
True
CreateCMakeTargetBaseName
(qualified_target)
This is the name we would like the target to have.
This is the name we would like the target to have.
def CreateCMakeTargetBaseName(qualified_target): """This is the name we would like the target to have.""" _, gyp_target_name, gyp_target_toolset = gyp.common.ParseQualifiedTarget( qualified_target ) cmake_target_base_name = gyp_target_name if gyp_target_toolset and gyp_target_toolset != "tar...
[ "def", "CreateCMakeTargetBaseName", "(", "qualified_target", ")", ":", "_", ",", "gyp_target_name", ",", "gyp_target_toolset", "=", "gyp", ".", "common", ".", "ParseQualifiedTarget", "(", "qualified_target", ")", "cmake_target_base_name", "=", "gyp_target_name", "if", ...
[ 567, 0 ]
[ 575, 58 ]
python
en
['en', 'en', 'en']
True
CreateCMakeTargetFullName
(qualified_target)
An unambiguous name for the target.
An unambiguous name for the target.
def CreateCMakeTargetFullName(qualified_target): """An unambiguous name for the target.""" gyp_file, gyp_target_name, gyp_target_toolset = gyp.common.ParseQualifiedTarget( qualified_target ) cmake_target_full_name = gyp_file + ":" + gyp_target_name if gyp_target_toolset and gyp_target_toolse...
[ "def", "CreateCMakeTargetFullName", "(", "qualified_target", ")", ":", "gyp_file", ",", "gyp_target_name", ",", "gyp_target_toolset", "=", "gyp", ".", "common", ".", "ParseQualifiedTarget", "(", "qualified_target", ")", "cmake_target_full_name", "=", "gyp_file", "+", ...
[ 578, 0 ]
[ 586, 58 ]
python
en
['en', 'en', 'en']
True
Project.update
(self)
Update the project using related->update endpoint.
Update the project using related->update endpoint.
def update(self): """Update the project using related->update endpoint.""" # get related->launch update_pg = self.get_related('update') # assert can_update == True assert update_pg.can_update, "The specified project (id:%s) is not able to update (can_update:%s)" % (self.id, upda...
[ "def", "update", "(", "self", ")", ":", "# get related->launch", "update_pg", "=", "self", ".", "get_related", "(", "'update'", ")", "# assert can_update == True", "assert", "update_pg", ".", "can_update", ",", "\"The specified project (id:%s) is not able to update (can_upd...
[ 97, 4 ]
[ 117, 33 ]
python
en
['en', 'en', 'en']
True
Project.is_successful
(self)
An project is considered successful when: 0) scm_type != "" 1) unified_job_template.is_successful
An project is considered successful when: 0) scm_type != "" 1) unified_job_template.is_successful
def is_successful(self): """An project is considered successful when: 0) scm_type != "" 1) unified_job_template.is_successful """ return self.scm_type != "" and super(Project, self).is_successful
[ "def", "is_successful", "(", "self", ")", ":", "return", "self", ".", "scm_type", "!=", "\"\"", "and", "super", "(", "Project", ",", "self", ")", ".", "is_successful" ]
[ 120, 4 ]
[ 125, 73 ]
python
en
['en', 'en', 'en']
True
create_multiple_ref_generator
(args: MultipleCompressorArg, spend_bundle: SpendBundle)
Decompress a transaction by referencing bytes from multiple input generator references
Decompress a transaction by referencing bytes from multiple input generator references
def create_multiple_ref_generator(args: MultipleCompressorArg, spend_bundle: SpendBundle) -> BlockGenerator: """ Decompress a transaction by referencing bytes from multiple input generator references """ compressed_cse_list = compressed_coin_solution_entry_list(spend_bundle) program = TEST_MULTIPLE....
[ "def", "create_multiple_ref_generator", "(", "args", ":", "MultipleCompressorArg", ",", "spend_bundle", ":", "SpendBundle", ")", "->", "BlockGenerator", ":", "compressed_cse_list", "=", "compressed_coin_solution_entry_list", "(", "spend_bundle", ")", "program", "=", "TEST...
[ 59, 0 ]
[ 79, 50 ]
python
en
['en', 'error', 'th']
False
TestDecompression.test_decompress_cse
(self)
Decompress a single CSE / CoinSolutionEntry
Decompress a single CSE / CoinSolutionEntry
def test_decompress_cse(self): """Decompress a single CSE / CoinSolutionEntry""" cse0 = binutils.assemble( "((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) (0xb081963921826355dcb6c355ccf9c2637c18adf7d38ee44d803ea9ca41587e48c913d8d46896eb830aeadfc13144a8eac3 (()...
[ "def", "test_decompress_cse", "(", "self", ")", ":", "cse0", "=", "binutils", ".", "assemble", "(", "\"((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) (0xb081963921826355dcb6c355ccf9c2637c18adf7d38ee44d803ea9ca41587e48c913d8d46896eb830aeadfc13144a8eac3 (() (q (...
[ 181, 4 ]
[ 191, 18 ]
python
en
['en', 'en', 'en']
True
TestDecompression.test_block_program_zero
(self)
Decompress a list of CSEs
Decompress a list of CSEs
def test_block_program_zero(self): "Decompress a list of CSEs" self.maxDiff = None cse1 = binutils.assemble( "(((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) (0xb081963921826355dcb6c355ccf9c2637c18adf7d38ee44d803ea9ca41587e48c913d8d46896eb830aeadfc1314...
[ "def", "test_block_program_zero", "(", "self", ")", ":", "self", ".", "maxDiff", "=", "None", "cse1", "=", "binutils", ".", "assemble", "(", "\"(((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) (0xb081963921826355dcb6c355ccf9c2637c18adf7d38ee44d803ea9c...
[ 209, 4 ]
[ 250, 18 ]
python
en
['en', 'ca', 'en']
True
TestOne2OneFlux.tearDown
(self)
remove all stuff after the test has been run
remove all stuff after the test has been run
def tearDown(self): """remove all stuff after the test has been run""" self.database.close()
[ "def", "tearDown", "(", "self", ")", ":", "self", ".", "database", ".", "close", "(", ")" ]
[ 20, 4 ]
[ 22, 29 ]
python
en
['en', 'en', 'en']
True
TestOne2ManyFlux.tearDown
(self)
remove all stuff after the test has been run
remove all stuff after the test has been run
def tearDown(self): """remove all stuff after the test has been run""" self.database.close()
[ "def", "tearDown", "(", "self", ")", ":", "self", ".", "database", ".", "close", "(", ")" ]
[ 80, 4 ]
[ 82, 29 ]
python
en
['en', 'en', 'en']
True
TestMany2OneFlux.tearDown
(self)
remove all stuff after the test has been run
remove all stuff after the test has been run
def tearDown(self): """remove all stuff after the test has been run""" self.database.close()
[ "def", "tearDown", "(", "self", ")", ":", "self", ".", "database", ".", "close", "(", ")" ]
[ 184, 4 ]
[ 186, 29 ]
python
en
['en', 'en', 'en']
True
TestMany2Many.tearDown
(self)
remove all stuff after the test has been run
remove all stuff after the test has been run
def tearDown(self): """remove all stuff after the test has been run""" self.database.close()
[ "def", "tearDown", "(", "self", ")", ":", "self", ".", "database", ".", "close", "(", ")" ]
[ 286, 4 ]
[ 288, 29 ]
python
en
['en', 'en', 'en']
True
TestMany2Many.test_many2manyflux_reduced_to_two_1_to_many_one_1to1
(self)
(See also assoc. test test_many2many_reduced_to_two_1_to_many_one_1to1 ) In this test-case we cross-associate between a rhombus of sources spread about a central position, east-west in the first image, north-south in the second. The latter, north-south pair are both slightly of...
(See also assoc. test test_many2many_reduced_to_two_1_to_many_one_1to1 ) In this test-case we cross-associate between a rhombus of sources spread about a central position, east-west in the first image, north-south in the second.
def test_many2manyflux_reduced_to_two_1_to_many_one_1to1(self): """ (See also assoc. test test_many2many_reduced_to_two_1_to_many_one_1to1 ) In this test-case we cross-associate between a rhombus of sources spread about a central position, east-west in the first image, north-sout...
[ "def", "test_many2manyflux_reduced_to_two_1_to_many_one_1to1", "(", "self", ")", ":", "dataset", "=", "tkp", ".", "db", ".", "DataSet", "(", "database", "=", "self", ".", "database", ",", "data", "=", "{", "'description'", ":", "'flux test set: n-m, '", "+", "se...
[ 290, 4 ]
[ 391, 66 ]
python
en
['en', 'error', 'th']
False
TestMany2Many.test_many2manyflux_reduced_to_two_1to1
(self)
(See also assoc. test test_many2many_reduced_to_two_1to1 ) In this test-case we cross-associate between a rhombus of sources spread about a central position, east-west in the first image, north-south in the second. The latter, north-south pair are slightly offset towards positi...
(See also assoc. test test_many2many_reduced_to_two_1to1 ) In this test-case we cross-associate between a rhombus of sources spread about a central position, east-west in the first image, north-south in the second.
def test_many2manyflux_reduced_to_two_1to1(self): """ (See also assoc. test test_many2many_reduced_to_two_1to1 ) In this test-case we cross-associate between a rhombus of sources spread about a central position, east-west in the first image, north-south in the second. Th...
[ "def", "test_many2manyflux_reduced_to_two_1to1", "(", "self", ")", ":", "dataset", "=", "tkp", ".", "db", ".", "DataSet", "(", "database", "=", "self", ".", "database", ",", "data", "=", "{", "'description'", ":", "'flux test set: n-m, '", "+", "self", ".", ...
[ 393, 4 ]
[ 494, 66 ]
python
en
['en', 'error', 'th']
False
get_mac_from_raw_query
(request_raw_query: str)
Get MAC address inside a matchbox "request raw query" /path?<request_raw_query> :param request_raw_query: :return: mac address
Get MAC address inside a matchbox "request raw query" /path?<request_raw_query> :param request_raw_query: :return: mac address
def get_mac_from_raw_query(request_raw_query: str): """ Get MAC address inside a matchbox "request raw query" /path?<request_raw_query> :param request_raw_query: :return: mac address """ mac = "" raw_query_list = request_raw_query.split("&") for param in raw_query_list: if "m...
[ "def", "get_mac_from_raw_query", "(", "request_raw_query", ":", "str", ")", ":", "mac", "=", "\"\"", "raw_query_list", "=", "request_raw_query", ".", "split", "(", "\"&\"", ")", "for", "param", "in", "raw_query_list", ":", "if", "\"mac=\"", "in", "param", ":",...
[ 10, 0 ]
[ 24, 32 ]
python
en
['en', 'error', 'th']
False
get_verified_dns_query
(interface: dict)
A discovery machine give a FQDN. This method will do the resolution before insert in the db :param interface: :return:
A discovery machine give a FQDN. This method will do the resolution before insert in the db :param interface: :return:
def get_verified_dns_query(interface: dict): """ A discovery machine give a FQDN. This method will do the resolution before insert in the db :param interface: :return: """ fqdn_list = [] try: for name in interface["fqdn"]: if EC.discovery_fqdn_verify is False: ...
[ "def", "get_verified_dns_query", "(", "interface", ":", "dict", ")", ":", "fqdn_list", "=", "[", "]", "try", ":", "for", "name", "in", "interface", "[", "\"fqdn\"", "]", ":", "if", "EC", ".", "discovery_fqdn_verify", "is", "False", ":", "logger", ".", "w...
[ 27, 0 ]
[ 69, 46 ]
python
en
['en', 'error', 'th']
False
Memoize.delete
(self, instance)
Forget a memoized value
Forget a memoized value
def delete(self, instance): """Forget a memoized value""" try: del(self.memo[instance]) except KeyError: pass
[ "def", "delete", "(", "self", ",", "instance", ")", ":", "try", ":", "del", "(", "self", ".", "memo", "[", "instance", "]", ")", "except", "KeyError", ":", "pass" ]
[ 31, 4 ]
[ 36, 16 ]
python
en
['fr', 'en', 'en']
True
AnalyzeQueueStatsTests.test_queue_stuck
(self)
Last update > 5 minutes ago and there's events in the queue.
Last update > 5 minutes ago and there's events in the queue.
def test_queue_stuck(self) -> None: """Last update > 5 minutes ago and there's events in the queue.""" result = analyze_queue_stats("name", {"update_time": time.time() - 301}, 100) self.assertEqual(result["status"], CRITICAL) self.assertIn("queue appears to be stuck", result["message"])
[ "def", "test_queue_stuck", "(", "self", ")", "->", "None", ":", "result", "=", "analyze_queue_stats", "(", "\"name\"", ",", "{", "\"update_time\"", ":", "time", ".", "time", "(", ")", "-", "301", "}", ",", "100", ")", "self", ".", "assertEqual", "(", "...
[ 11, 4 ]
[ 16, 69 ]
python
en
['en', 'en', 'en']
True
AnalyzeQueueStatsTests.test_queue_just_started
(self)
We just started processing a burst of events, and haven't processed enough to log productivity statistics yet.
We just started processing a burst of events, and haven't processed enough to log productivity statistics yet.
def test_queue_just_started(self) -> None: """ We just started processing a burst of events, and haven't processed enough to log productivity statistics yet. """ result = analyze_queue_stats( "name", { "update_time": time.time(), ...
[ "def", "test_queue_just_started", "(", "self", ")", "->", "None", ":", "result", "=", "analyze_queue_stats", "(", "\"name\"", ",", "{", "\"update_time\"", ":", "time", ".", "time", "(", ")", ",", "\"current_queue_size\"", ":", "10000", ",", "\"recent_average_con...
[ 18, 4 ]
[ 32, 46 ]
python
en
['en', 'error', 'th']
False
AnalyzeQueueStatsTests.test_queue_normal
(self)
10000 events and each takes a second => it'll take a long time to empty.
10000 events and each takes a second => it'll take a long time to empty.
def test_queue_normal(self) -> None: """10000 events and each takes a second => it'll take a long time to empty.""" result = analyze_queue_stats( "name", { "update_time": time.time(), "current_queue_size": 10000, "queue_last_emptied...
[ "def", "test_queue_normal", "(", "self", ")", "->", "None", ":", "result", "=", "analyze_queue_stats", "(", "\"name\"", ",", "{", "\"update_time\"", ":", "time", ".", "time", "(", ")", ",", "\"current_queue_size\"", ":", "10000", ",", "\"queue_last_emptied_times...
[ 34, 4 ]
[ 87, 50 ]
python
en
['en', 'en', 'en']
True
prepare_for_inversion
(gdir, add_debug_var=False, invert_with_rectangular=True, invert_all_rectangular=False, invert_with_trapezoid=True, invert_all_trapezoid=False)
Prepares the data needed for the inversion. Mostly the mass flux and slope angle, the rest (width, height) was already computed. It is then stored in a list of dicts in order to be faster. Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the glacier directory to process
Prepares the data needed for the inversion.
def prepare_for_inversion(gdir, add_debug_var=False, invert_with_rectangular=True, invert_all_rectangular=False, invert_with_trapezoid=True, invert_all_trapezoid=False): """Prepares the data needed for the invers...
[ "def", "prepare_for_inversion", "(", "gdir", ",", "add_debug_var", "=", "False", ",", "invert_with_rectangular", "=", "True", ",", "invert_all_rectangular", "=", "False", ",", "invert_with_trapezoid", "=", "True", ",", "invert_all_trapezoid", "=", "False", ")", ":",...
[ 53, 0 ]
[ 150, 49 ]
python
en
['en', 'en', 'en']
True
_inversion_poly
(a3, a0)
Solve for degree 5 polynomial with coefficients a5=1, a3, a0.
Solve for degree 5 polynomial with coefficients a5=1, a3, a0.
def _inversion_poly(a3, a0): """Solve for degree 5 polynomial with coefficients a5=1, a3, a0.""" sols = np.roots([1., 0., a3, 0., 0., a0]) test = (np.isreal(sols)*np.greater(sols, [0]*len(sols))) return sols[test][0].real
[ "def", "_inversion_poly", "(", "a3", ",", "a0", ")", ":", "sols", "=", "np", ".", "roots", "(", "[", "1.", ",", "0.", ",", "a3", ",", "0.", ",", "0.", ",", "a0", "]", ")", "test", "=", "(", "np", ".", "isreal", "(", "sols", ")", "*", "np", ...
[ 153, 0 ]
[ 157, 29 ]
python
en
['en', 'en', 'en']
True
_inversion_simple
(a3, a0)
Solve for degree 5 polynomial with coefficients a5=1, a3=0., a0.
Solve for degree 5 polynomial with coefficients a5=1, a3=0., a0.
def _inversion_simple(a3, a0): """Solve for degree 5 polynomial with coefficients a5=1, a3=0., a0.""" return (-a0)**(1./5.)
[ "def", "_inversion_simple", "(", "a3", ",", "a0", ")", ":", "return", "(", "-", "a0", ")", "**", "(", "1.", "/", "5.", ")" ]
[ 160, 0 ]
[ 163, 25 ]
python
en
['en', 'en', 'en']
True
_compute_thick
(a0s, a3, flux_a0, shape_factor, _inv_function)
Content of the original inner loop of the mass-conservation inversion. Put here to avoid code duplication. Parameters ---------- a0s a3 flux_a0 shape_factor _inv_function Returns ------- the thickness
Content of the original inner loop of the mass-conservation inversion.
def _compute_thick(a0s, a3, flux_a0, shape_factor, _inv_function): """Content of the original inner loop of the mass-conservation inversion. Put here to avoid code duplication. Parameters ---------- a0s a3 flux_a0 shape_factor _inv_function Returns ------- the thicknes...
[ "def", "_compute_thick", "(", "a0s", ",", "a3", ",", "flux_a0", ",", "shape_factor", ",", "_inv_function", ")", ":", "a0s", "=", "a0s", "/", "(", "shape_factor", "**", "3", ")", "if", "np", ".", "any", "(", "~", "np", ".", "isfinite", "(", "a0s", "...
[ 166, 0 ]
[ 201, 20 ]
python
en
['en', 'en', 'en']
True
sia_thickness_via_optim
(slope, width, flux, shape='rectangular', glen_a=None, fs=None, t_lambda=None)
Compute the thickness numerically instead of analytically. It's the only way that works for trapezoid shapes. Parameters ---------- slope : -np.gradient(hgt, dx) width : section width in m flux : mass flux in m3 s-1 shape : 'rectangular', 'trapezoid' or 'parabolic' glen_a : Glen A, def...
Compute the thickness numerically instead of analytically.
def sia_thickness_via_optim(slope, width, flux, shape='rectangular', glen_a=None, fs=None, t_lambda=None): """Compute the thickness numerically instead of analytically. It's the only way that works for trapezoid shapes. Parameters ---------- slope : -np.gradient(hgt, dx...
[ "def", "sia_thickness_via_optim", "(", "slope", ",", "width", ",", "flux", ",", "shape", "=", "'rectangular'", ",", "glen_a", "=", "None", ",", "fs", "=", "None", ",", "t_lambda", "=", "None", ")", ":", "if", "len", "(", "np", ".", "atleast_1d", "(", ...
[ 204, 0 ]
[ 271, 16 ]
python
en
['en', 'en', 'en']
True
sia_thickness
(slope, width, flux, shape='rectangular', glen_a=None, fs=None, shape_factor=None)
Computes the ice thickness from mass-conservation. This is a utility function tested against the true OGGM inversion function. Useful for teaching and inversion with calving. Parameters ---------- slope : -np.gradient(hgt, dx) (we don't clip for min slope!) width : section width in m flux ...
Computes the ice thickness from mass-conservation.
def sia_thickness(slope, width, flux, shape='rectangular', glen_a=None, fs=None, shape_factor=None): """Computes the ice thickness from mass-conservation. This is a utility function tested against the true OGGM inversion function. Useful for teaching and inversion with calving. Param...
[ "def", "sia_thickness", "(", "slope", ",", "width", ",", "flux", ",", "shape", "=", "'rectangular'", ",", "glen_a", "=", "None", ",", "fs", "=", "None", ",", "shape_factor", "=", "None", ")", ":", "if", "glen_a", "is", "None", ":", "glen_a", "=", "cf...
[ 274, 0 ]
[ 354, 61 ]
python
en
['en', 'en', 'en']
True
find_sia_flux_from_thickness
(slope, width, thick, glen_a=None, fs=None, shape='rectangular')
Find the ice flux produced by a given thickness and slope. This can be done analytically but I'm lazy and use optimisation instead.
Find the ice flux produced by a given thickness and slope.
def find_sia_flux_from_thickness(slope, width, thick, glen_a=None, fs=None, shape='rectangular'): """Find the ice flux produced by a given thickness and slope. This can be done analytically but I'm lazy and use optimisation instead. """ def to_minimize(x): h = ...
[ "def", "find_sia_flux_from_thickness", "(", "slope", ",", "width", ",", "thick", ",", "glen_a", "=", "None", ",", "fs", "=", "None", ",", "shape", "=", "'rectangular'", ")", ":", "def", "to_minimize", "(", "x", ")", ":", "h", "=", "sia_thickness", "(", ...
[ 357, 0 ]
[ 377, 15 ]
python
en
['en', 'en', 'en']
True
mass_conservation_inversion
(gdir, glen_a=None, fs=None, write=True, filesuffix='', water_level=None, t_lambda=None)
Compute the glacier thickness along the flowlines More or less following Farinotti et al., (2009). Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the glacier directory to process glen_a : float glen's creep parameter A. Defaults to cfg.PARAMS. fs : float ...
Compute the glacier thickness along the flowlines
def mass_conservation_inversion(gdir, glen_a=None, fs=None, write=True, filesuffix='', water_level=None, t_lambda=None): """ Compute the glacier thickness along the flowlines More or less following Farinotti et al., (2009). Parameters ---...
[ "def", "mass_conservation_inversion", "(", "gdir", ",", "glen_a", "=", "None", ",", "fs", "=", "None", ",", "write", "=", "True", ",", "filesuffix", "=", "''", ",", "water_level", "=", "None", ",", "t_lambda", "=", "None", ")", ":", "# Defaults", "if", ...
[ 399, 0 ]
[ 573, 21 ]
python
en
['en', 'en', 'en']
True
filter_inversion_output
(gdir)
Filters the last few grid points after the physically-based inversion. For various reasons (but mostly: the equilibrium assumption), the last few grid points on a glacier flowline are often noisy and create unphysical depressions. Here we try to correct for that. It is not volume conserving, but area c...
Filters the last few grid points after the physically-based inversion.
def filter_inversion_output(gdir): """Filters the last few grid points after the physically-based inversion. For various reasons (but mostly: the equilibrium assumption), the last few grid points on a glacier flowline are often noisy and create unphysical depressions. Here we try to correct for that. I...
[ "def", "filter_inversion_output", "(", "gdir", ")", ":", "if", "gdir", ".", "is_tidewater", ":", "# No need for filter in tidewater case", "cls", "=", "gdir", ".", "read_pickle", "(", "'inversion_output'", ")", "init_vol", "=", "np", ".", "sum", "(", "[", "np", ...
[ 577, 0 ]
[ 643, 55 ]
python
en
['en', 'en', 'en']
True
get_inversion_volume
(gdir)
Small utility task to get to the volume od all glaciers.
Small utility task to get to the volume od all glaciers.
def get_inversion_volume(gdir): """Small utility task to get to the volume od all glaciers.""" cls = gdir.read_pickle('inversion_output') return np.sum([np.sum(cl['volume']) for cl in cls])
[ "def", "get_inversion_volume", "(", "gdir", ")", ":", "cls", "=", "gdir", ".", "read_pickle", "(", "'inversion_output'", ")", "return", "np", ".", "sum", "(", "[", "np", ".", "sum", "(", "cl", "[", "'volume'", "]", ")", "for", "cl", "in", "cls", "]",...
[ 647, 0 ]
[ 650, 55 ]
python
en
['en', 'en', 'en']
True
compute_velocities
(gdir, glen_a=None, fs=None, filesuffix='', with_sliding=False)
Surface velocities along the flowlines from inverted ice thickness. Computed following the methods described in Cuffey and Paterson (2010) Eq. 8.35, pp 310: u_s = u_basal + (2A/n+1)* tau^n * H In the case of no sliding (or if with_sliding=False, which is a justifiable simplification given unc...
Surface velocities along the flowlines from inverted ice thickness.
def compute_velocities(gdir, glen_a=None, fs=None, filesuffix='', with_sliding=False): """Surface velocities along the flowlines from inverted ice thickness. Computed following the methods described in Cuffey and Paterson (2010) Eq. 8.35, pp 310: u_s = u_basal + (2A/n+1)* ta...
[ "def", "compute_velocities", "(", "gdir", ",", "glen_a", "=", "None", ",", "fs", "=", "None", ",", "filesuffix", "=", "''", ",", "with_sliding", "=", "False", ")", ":", "# Defaults", "if", "glen_a", "is", "None", ":", "glen_a", "=", "cfg", ".", "PARAMS...
[ 654, 0 ]
[ 742, 69 ]
python
en
['en', 'en', 'en']
True
distribute_thickness_per_altitude
(gdir, add_slope=True, smooth_radius=None, dis_from_border_exp=0.25, varname_suffix='')
Compute a thickness map by redistributing mass along altitudinal bands. This is a rather cosmetic task, not relevant for OGGM but for ITMIX. Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the glacier directory to process add_slope : bool whether a corrective slope f...
Compute a thickness map by redistributing mass along altitudinal bands.
def distribute_thickness_per_altitude(gdir, add_slope=True, smooth_radius=None, dis_from_border_exp=0.25, varname_suffix=''): """Compute a thickness map by redistributing mass along altitudinal bands. ...
[ "def", "distribute_thickness_per_altitude", "(", "gdir", ",", "add_slope", "=", "True", ",", "smooth_radius", "=", "None", ",", "dis_from_border_exp", "=", "0.25", ",", "varname_suffix", "=", "''", ")", ":", "# Variables", "grids_file", "=", "gdir", ".", "get_fi...
[ 746, 0 ]
[ 865, 16 ]
python
en
['en', 'en', 'en']
True
distribute_thickness_interp
(gdir, add_slope=True, smooth_radius=None, varname_suffix='')
Compute a thickness map by interpolating between centerlines and border. IMPORTANT: this is NOT what has been used for ITMIX. We used distribute_thickness_per_altitude for ITMIX and global ITMIX. This is a rather cosmetic task, not relevant for OGGM but for ITMIX. Parameters ---------- gdir :...
Compute a thickness map by interpolating between centerlines and border.
def distribute_thickness_interp(gdir, add_slope=True, smooth_radius=None, varname_suffix=''): """Compute a thickness map by interpolating between centerlines and border. IMPORTANT: this is NOT what has been used for ITMIX. We used distribute_thickness_per_altitude for ITMIX ...
[ "def", "distribute_thickness_interp", "(", "gdir", ",", "add_slope", "=", "True", ",", "smooth_radius", "=", "None", ",", "varname_suffix", "=", "''", ")", ":", "# Variables", "grids_file", "=", "gdir", ".", "get_filepath", "(", "'gridded_data'", ")", "# See if ...
[ 869, 0 ]
[ 969, 16 ]
python
en
['en', 'en', 'en']
True
calving_flux_from_depth
(gdir, k=None, water_level=None, water_depth=None, thick=None, fixed_water_depth=False)
Finds a calving flux from the calving front thickness. Approach based on Huss and Hock, (2015) and Oerlemans and Nick (2005). We take the initial output of the model and surface elevation data to calculate the water depth of the calving front. Parameters ---------- gdir : GlacierDirectory ...
Finds a calving flux from the calving front thickness.
def calving_flux_from_depth(gdir, k=None, water_level=None, water_depth=None, thick=None, fixed_water_depth=False): """Finds a calving flux from the calving front thickness. Approach based on Huss and Hock, (2015) and Oerlemans and Nick (2005). We take the initial output of the ...
[ "def", "calving_flux_from_depth", "(", "gdir", ",", "k", "=", "None", ",", "water_level", "=", "None", ",", "water_depth", "=", "None", ",", "thick", "=", "None", ",", "fixed_water_depth", "=", "False", ")", ":", "# Defaults", "if", "k", "is", "None", ":...
[ 972, 0 ]
[ 1042, 37 ]
python
en
['en', 'en', 'en']
True
find_inversion_calving
(gdir, water_level=None, fixed_water_depth=None, glen_a=None, fs=None, min_mu_star_frac=None)
Optimized search for a calving flux compatible with the bed inversion. See Recinos et al 2019 for details. Parameters ---------- water_level : float the water level. It should be zero m a.s.l, but: - sometimes the frontal elevation is unrealistically high (or low). - lake termi...
Optimized search for a calving flux compatible with the bed inversion.
def find_inversion_calving(gdir, water_level=None, fixed_water_depth=None, glen_a=None, fs=None, min_mu_star_frac=None): """Optimized search for a calving flux compatible with the bed inversion. See Recinos et al 2019 for details. Parameters ---------- water_level : floa...
[ "def", "find_inversion_calving", "(", "gdir", ",", "water_level", "=", "None", ",", "fixed_water_depth", "=", "None", ",", "glen_a", "=", "None", ",", "fs", "=", "None", ",", "min_mu_star_frac", "=", "None", ")", ":", "from", "oggm", ".", "core", "import",...
[ 1046, 0 ]
[ 1239, 14 ]
python
en
['en', 'en', 'en']
True
find_inversion_calving_from_any_mb
(gdir, mb_model=None, mb_years=None, water_level=None, glen_a=None, fs=None)
Optimized search for a calving flux compatible with the bed inversion. See Recinos et al 2019 for details. This task is an update to `find_inversion_calving` but acting upon a MB residual (i.e. a shift) instead of the model temperature sensitivity. Parameters ---------- mb_model : :py:class:`o...
Optimized search for a calving flux compatible with the bed inversion.
def find_inversion_calving_from_any_mb(gdir, mb_model=None, mb_years=None, water_level=None, glen_a=None, fs=None): """Optimized search for a calving flux compatible with the bed inversion. See Recinos et al 2019 for details. This ta...
[ "def", "find_inversion_calving_from_any_mb", "(", "gdir", ",", "mb_model", "=", "None", ",", "mb_years", "=", "None", ",", "water_level", "=", "None", ",", "glen_a", "=", "None", ",", "fs", "=", "None", ")", ":", "from", "oggm", ".", "core", "import", "c...
[ 1243, 0 ]
[ 1389, 14 ]
python
en
['en', 'en', 'en']
True
Load
( build_files, format, default_variables={}, includes=[], depth=".", params=None, check=False, circular_check=True, )
Loads one or more specified build files. default_variables and includes will be copied before use. Returns the generator for the specified format and the data returned by loading the specified build files.
Loads one or more specified build files. default_variables and includes will be copied before use. Returns the generator for the specified format and the data returned by loading the specified build files.
def Load( build_files, format, default_variables={}, includes=[], depth=".", params=None, check=False, circular_check=True, ): """ Loads one or more specified build files. default_variables and includes will be copied before use. Returns the generator for the specified format a...
[ "def", "Load", "(", "build_files", ",", "format", ",", "default_variables", "=", "{", "}", ",", "includes", "=", "[", "]", ",", "depth", "=", "\".\"", ",", "params", "=", "None", ",", "check", "=", "False", ",", "circular_check", "=", "True", ",", ")...
[ 61, 0 ]
[ 160, 31 ]
python
en
['en', 'error', 'th']
False
NameValueListToDict
(name_value_list)
Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary of the pairs. If a string is simply NAME, then the value in the dictionary is set to True. If VALUE can be converted to an integer, it is.
Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary of the pairs. If a string is simply NAME, then the value in the dictionary is set to True. If VALUE can be converted to an integer, it is.
def NameValueListToDict(name_value_list): """ Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary of the pairs. If a string is simply NAME, then the value in the dictionary is set to True. If VALUE can be converted to an integer, it is. """ result = {} for item in name_valu...
[ "def", "NameValueListToDict", "(", "name_value_list", ")", ":", "result", "=", "{", "}", "for", "item", "in", "name_value_list", ":", "tokens", "=", "item", ".", "split", "(", "\"=\"", ",", "1", ")", "if", "len", "(", "tokens", ")", "==", "2", ":", "...
[ 163, 0 ]
[ 183, 17 ]
python
en
['en', 'error', 'th']
False
RegenerateAppendFlag
(flag, values, predicate, env_name, options)
Regenerate a list of command line flags, for an option of action='append'. The |env_name|, if given, is checked in the environment and used to generate an initial list of options, then the options that were specified on the command line (given in |values|) are appended. This matches the handling of environmen...
Regenerate a list of command line flags, for an option of action='append'.
def RegenerateAppendFlag(flag, values, predicate, env_name, options): """Regenerate a list of command line flags, for an option of action='append'. The |env_name|, if given, is checked in the environment and used to generate an initial list of options, then the options that were specified on the command line...
[ "def", "RegenerateAppendFlag", "(", "flag", ",", "values", ",", "predicate", ",", "env_name", ",", "options", ")", ":", "flags", "=", "[", "]", "if", "options", ".", "use_environment", "and", "env_name", ":", "for", "flag_value", "in", "ShlexEnv", "(", "en...
[ 199, 0 ]
[ 219, 16 ]
python
en
['en', 'en', 'en']
True
RegenerateFlags
(options)
Given a parsed options object, and taking the environment variables into account, returns a list of flags that should regenerate an equivalent options object (even in the absence of the environment variables.) Any path options will be normalized relative to depth. The format flag is not included, as it is ass...
Given a parsed options object, and taking the environment variables into account, returns a list of flags that should regenerate an equivalent options object (even in the absence of the environment variables.)
def RegenerateFlags(options): """Given a parsed options object, and taking the environment variables into account, returns a list of flags that should regenerate an equivalent options object (even in the absence of the environment variables.) Any path options will be normalized relative to depth. The form...
[ "def", "RegenerateFlags", "(", "options", ")", ":", "def", "FixPath", "(", "path", ")", ":", "path", "=", "gyp", ".", "common", ".", "FixIfRelativePath", "(", "path", ",", "options", ".", "depth", ")", "if", "not", "path", ":", "return", "os", ".", "...
[ 222, 0 ]
[ 278, 16 ]
python
en
['en', 'en', 'en']
True
RegeneratableOptionParser.add_argument
(self, *args, **kw)
Add an option to the parser. This accepts the same arguments as ArgumentParser.add_argument, plus the following: regenerate: can be set to False to prevent this option from being included in regeneration. env_name: name of environment variable that additional values for this ...
Add an option to the parser.
def add_argument(self, *args, **kw): """Add an option to the parser. This accepts the same arguments as ArgumentParser.add_argument, plus the following: regenerate: can be set to False to prevent this option from being included in regeneration. env_name: name of environmen...
[ "def", "add_argument", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "env_name", "=", "kw", ".", "pop", "(", "\"env_name\"", ",", "None", ")", "if", "\"dest\"", "in", "kw", "and", "kw", ".", "pop", "(", "\"regenerate\"", ",", "True"...
[ 286, 4 ]
[ 315, 63 ]
python
en
['en', 'en', 'en']
True
env_func
(f, argtypes)
For getting OGREnvelopes.
For getting OGREnvelopes.
def env_func(f, argtypes): "For getting OGREnvelopes." f.argtypes = argtypes f.restype = None f.errcheck = check_envelope return f
[ "def", "env_func", "(", "f", ",", "argtypes", ")", ":", "f", ".", "argtypes", "=", "argtypes", "f", ".", "restype", "=", "None", "f", ".", "errcheck", "=", "check_envelope", "return", "f" ]
[ 12, 0 ]
[ 17, 12 ]
python
de
['de', 'no', 'en']
False
pnt_func
(f)
For accessing point information.
For accessing point information.
def pnt_func(f): "For accessing point information." return double_output(f, [c_void_p, c_int])
[ "def", "pnt_func", "(", "f", ")", ":", "return", "double_output", "(", "f", ",", "[", "c_void_p", ",", "c_int", "]", ")" ]
[ 20, 0 ]
[ 22, 46 ]
python
en
['en', 'en', 'en']
True
add_message
(request, level, message, extra_tags='', fail_silently=False)
Attempts to add a message to the request using the 'messages' app.
Attempts to add a message to the request using the 'messages' app.
def add_message(request, level, message, extra_tags='', fail_silently=False): """ Attempts to add a message to the request using the 'messages' app. """ try: messages = request._messages except AttributeError: if not hasattr(request, 'META'): raise TypeError( ...
[ "def", "add_message", "(", "request", ",", "level", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "try", ":", "messages", "=", "request", ".", "_messages", "except", "AttributeError", ":", "if", "not", "hasattr...
[ 15, 0 ]
[ 33, 55 ]
python
en
['en', 'error', 'th']
False
get_messages
(request)
Returns the message storage on the request if it exists, otherwise returns an empty list.
Returns the message storage on the request if it exists, otherwise returns an empty list.
def get_messages(request): """ Returns the message storage on the request if it exists, otherwise returns an empty list. """ return getattr(request, '_messages', [])
[ "def", "get_messages", "(", "request", ")", ":", "return", "getattr", "(", "request", ",", "'_messages'", ",", "[", "]", ")" ]
[ 36, 0 ]
[ 41, 44 ]
python
en
['en', 'error', 'th']
False
get_level
(request)
Returns the minimum level of messages to be recorded. The default level is the ``MESSAGE_LEVEL`` setting. If this is not found, the ``INFO`` level is used.
Returns the minimum level of messages to be recorded.
def get_level(request): """ Returns the minimum level of messages to be recorded. The default level is the ``MESSAGE_LEVEL`` setting. If this is not found, the ``INFO`` level is used. """ storage = getattr(request, '_messages', default_storage(request)) return storage.level
[ "def", "get_level", "(", "request", ")", ":", "storage", "=", "getattr", "(", "request", ",", "'_messages'", ",", "default_storage", "(", "request", ")", ")", "return", "storage", ".", "level" ]
[ 44, 0 ]
[ 52, 24 ]
python
en
['en', 'error', 'th']
False
set_level
(request, level)
Sets the minimum level of messages to be recorded, returning ``True`` if the level was recorded successfully. If set to ``None``, the default level will be used (see the ``get_level`` method).
Sets the minimum level of messages to be recorded, returning ``True`` if the level was recorded successfully.
def set_level(request, level): """ Sets the minimum level of messages to be recorded, returning ``True`` if the level was recorded successfully. If set to ``None``, the default level will be used (see the ``get_level`` method). """ if not hasattr(request, '_messages'): return False ...
[ "def", "set_level", "(", "request", ",", "level", ")", ":", "if", "not", "hasattr", "(", "request", ",", "'_messages'", ")", ":", "return", "False", "request", ".", "_messages", ".", "level", "=", "level", "return", "True" ]
[ 55, 0 ]
[ 66, 15 ]
python
en
['en', 'error', 'th']
False
debug
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``DEBUG`` level.
Adds a message with the ``DEBUG`` level.
def debug(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``DEBUG`` level. """ add_message(request, constants.DEBUG, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "debug", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "DEBUG", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_sile...
[ 69, 0 ]
[ 74, 44 ]
python
en
['en', 'error', 'th']
False
info
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``INFO`` level.
Adds a message with the ``INFO`` level.
def info(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``INFO`` level. """ add_message(request, constants.INFO, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "info", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "INFO", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_silent...
[ 77, 0 ]
[ 82, 44 ]
python
en
['en', 'error', 'th']
False
success
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``SUCCESS`` level.
Adds a message with the ``SUCCESS`` level.
def success(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``SUCCESS`` level. """ add_message(request, constants.SUCCESS, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "success", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "SUCCESS", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_...
[ 85, 0 ]
[ 90, 44 ]
python
en
['en', 'error', 'th']
False
warning
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``WARNING`` level.
Adds a message with the ``WARNING`` level.
def warning(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``WARNING`` level. """ add_message(request, constants.WARNING, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "warning", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "WARNING", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_...
[ 93, 0 ]
[ 98, 44 ]
python
en
['en', 'error', 'th']
False
error
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``ERROR`` level.
Adds a message with the ``ERROR`` level.
def error(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``ERROR`` level. """ add_message(request, constants.ERROR, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "error", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "ERROR", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_sile...
[ 101, 0 ]
[ 106, 44 ]
python
en
['en', 'error', 'th']
False
test_job_relaunch_permission_denied_response_other_user
(get, post, inventory, project, alice, bob, survey_spec_factory)
Asserts custom permission denied message corresponding to awx/main/tests/functional/test_rbac_job.py::TestJobRelaunchAccess::test_other_user_prompts
Asserts custom permission denied message corresponding to awx/main/tests/functional/test_rbac_job.py::TestJobRelaunchAccess::test_other_user_prompts
def test_job_relaunch_permission_denied_response_other_user(get, post, inventory, project, alice, bob, survey_spec_factory): """ Asserts custom permission denied message corresponding to awx/main/tests/functional/test_rbac_job.py::TestJobRelaunchAccess::test_other_user_prompts """ jt = JobTemplate.o...
[ "def", "test_job_relaunch_permission_denied_response_other_user", "(", "get", ",", "post", ",", "inventory", ",", "project", ",", "alice", ",", "bob", ",", "survey_spec_factory", ")", ":", "jt", "=", "JobTemplate", ".", "objects", ".", "create", "(", "name", "="...
[ 62, 0 ]
[ 86, 94 ]
python
en
['en', 'error', 'th']
False
len_img_block
(string)
Length of image html blocks from a string.
Length of image html blocks from a string.
def len_img_block(string): """ Length of image html blocks from a string. """ all_oc = regex.findall(r'<img\s[^<>]*+>', string) tot_len = 0 for oc in all_oc: tot_len += len(oc) return tot_len
[ "def", "len_img_block", "(", "string", ")", ":", "all_oc", "=", "regex", ".", "findall", "(", "r'<img\\s[^<>]*+>'", ",", "string", ")", "tot_len", "=", "0", "for", "oc", "in", "all_oc", ":", "tot_len", "+=", "len", "(", "oc", ")", "return", "tot_len" ]
[ 797, 0 ]
[ 803, 18 ]
python
en
['en', 'en', 'en']
True
check_numbers
(s, numlist, numlist_normalized=None)
Extract sequences of possible phone numbers. Check extracted numbers against verbatim match (identical to item in list) or normalized match (digits are identical, but spacing or punctuation contains differences).
Extract sequences of possible phone numbers. Check extracted numbers against verbatim match (identical to item in list) or normalized match (digits are identical, but spacing or punctuation contains differences).
def check_numbers(s, numlist, numlist_normalized=None): """ Extract sequences of possible phone numbers. Check extracted numbers against verbatim match (identical to item in list) or normalized match (digits are identical, but spacing or punctuation contains differences). """ numlist_normalized ...
[ "def", "check_numbers", "(", "s", ",", "numlist", ",", "numlist_normalized", "=", "None", ")", ":", "numlist_normalized", "=", "numlist_normalized", "or", "set", "(", ")", "matches", "=", "[", "]", "for", "number_candidate", "in", "NUMBER_REGEX", ".", "findall...
[ 921, 0 ]
[ 940, 24 ]
python
en
['en', 'error', 'th']
False