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
ListIndentProcessor.get_level
(self, parent, block)
Get level of indent based on list level.
Get level of indent based on list level.
def get_level(self, parent, block): """ Get level of indent based on list level. """ # Get indent level m = self.INDENT_RE.match(block) if m: indent_level = len(m.group(1))/markdown.TAB_LENGTH else: indent_level = 0 if self.parser.state.isstate('li...
[ "def", "get_level", "(", "self", ",", "parent", ",", "block", ")", ":", "# Get indent level", "m", "=", "self", ".", "INDENT_RE", ".", "match", "(", "block", ")", "if", "m", ":", "indent_level", "=", "len", "(", "m", ".", "group", "(", "1", ")", ")...
[ 157, 4 ]
[ 182, 28 ]
python
en
['en', 'da', 'en']
True
BlockQuoteProcessor.clean
(self, line)
Remove ``>`` from beginning of a line.
Remove ``>`` from beginning of a line.
def clean(self, line): """ Remove ``>`` from beginning of a line. """ m = self.RE.match(line) if line.strip() == ">": return "" elif m: return m.group(2) else: return line
[ "def", "clean", "(", "self", ",", "line", ")", ":", "m", "=", "self", ".", "RE", ".", "match", "(", "line", ")", "if", "line", ".", "strip", "(", ")", "==", "\">\"", ":", "return", "\"\"", "elif", "m", ":", "return", "m", ".", "group", "(", "...
[ 246, 4 ]
[ 254, 23 ]
python
en
['en', 'en', 'en']
True
OListProcessor.get_items
(self, block)
Break a block into list items.
Break a block into list items.
def get_items(self, block): """ Break a block into list items. """ items = [] for line in block.split('\n'): m = self.CHILD_RE.match(line) if m: # This is a new item. Append items.append(m.group(3)) elif self.INDENT_RE.match(lin...
[ "def", "get_items", "(", "self", ",", "block", ")", ":", "items", "=", "[", "]", "for", "line", "in", "block", ".", "split", "(", "'\\n'", ")", ":", "m", "=", "self", ".", "CHILD_RE", ".", "match", "(", "line", ")", "if", "m", ":", "# This is a n...
[ 304, 4 ]
[ 322, 20 ]
python
en
['it', 'fy', 'en']
False
EditMessageSideEffectsTest._login_and_send_original_stream_message
( self, content: str, enable_online_push_notifications: bool = False )
Note our conventions here: Hamlet is our logged in user (and sender). Cordelia is the receiver we care about. Scotland is the stream we send messages to.
Note our conventions here:
def _login_and_send_original_stream_message( self, content: str, enable_online_push_notifications: bool = False ) -> int: """ Note our conventions here: Hamlet is our logged in user (and sender). Cordelia is the receiver we care about. Scotland is the str...
[ "def", "_login_and_send_original_stream_message", "(", "self", ",", "content", ":", "str", ",", "enable_online_push_notifications", ":", "bool", "=", "False", ")", "->", "int", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "cordelia", ...
[ 45, 4 ]
[ 71, 25 ]
python
en
['en', 'error', 'th']
False
EditMessageSideEffectsTest._get_queued_data_for_message_update
( self, message_id: int, content: str, expect_short_circuit: bool = False )
This function updates a message with a post to /json/messages/(message_id). By using mocks, we are able to capture two pieces of data: enqueue_kwargs: These are the arguments passed in to maybe_enqueue_notifications. queue_messages: These a...
This function updates a message with a post to /json/messages/(message_id).
def _get_queued_data_for_message_update( self, message_id: int, content: str, expect_short_circuit: bool = False ) -> Dict[str, Any]: """ This function updates a message with a post to /json/messages/(message_id). By using mocks, we are able to capture two pieces of data: ...
[ "def", "_get_queued_data_for_message_update", "(", "self", ",", "message_id", ":", "int", ",", "content", ":", "str", ",", "expect_short_circuit", ":", "bool", "=", "False", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "url", "=", "\"/json/messages/\...
[ 73, 4 ]
[ 139, 9 ]
python
en
['en', 'error', 'th']
False
EditMessageSideEffectsTest._turn_on_stream_push_for_cordelia
(self)
conventions: Cordelia is the message receiver we care about. Scotland is our stream.
conventions: Cordelia is the message receiver we care about. Scotland is our stream.
def _turn_on_stream_push_for_cordelia(self) -> None: """ conventions: Cordelia is the message receiver we care about. Scotland is our stream. """ cordelia = self.example_user("cordelia") stream = self.subscribe(cordelia, "Scotland") recipient = str...
[ "def", "_turn_on_stream_push_for_cordelia", "(", "self", ")", "->", "None", ":", "cordelia", "=", "self", ".", "example_user", "(", "\"cordelia\"", ")", "stream", "=", "self", ".", "subscribe", "(", "cordelia", ",", "\"Scotland\"", ")", "recipient", "=", "stre...
[ 223, 4 ]
[ 237, 36 ]
python
en
['en', 'error', 'th']
False
EditMessageSideEffectsTest._cordelia_connected_to_zulip
(self)
Right now the easiest way to make Cordelia look connected to Zulip is to mock the function below. This is a bit blunt, as it affects other users too, but we only really look at Cordelia's data, anyway.
Right now the easiest way to make Cordelia look connected to Zulip is to mock the function below.
def _cordelia_connected_to_zulip(self) -> Any: """ Right now the easiest way to make Cordelia look connected to Zulip is to mock the function below. This is a bit blunt, as it affects other users too, but we only really look at Cordelia's data, anyway. """ return...
[ "def", "_cordelia_connected_to_zulip", "(", "self", ")", "->", "Any", ":", "return", "mock", ".", "patch", "(", "\"zerver.tornado.event_queue.receiver_is_off_zulip\"", ",", "return_value", "=", "False", ",", ")" ]
[ 249, 4 ]
[ 260, 9 ]
python
en
['en', 'error', 'th']
False
add_stderr_logger
(level=logging.DEBUG)
Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it.
Helper for quickly adding a StreamHandler to the logger. Useful for debugging.
def add_stderr_logger(level=logging.DEBUG): """ Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it. """ # This method needs to be in this __init__.py to get the __name__ correct # even if urllib3 is vendored within another pack...
[ "def", "add_stderr_logger", "(", "level", "=", "logging", ".", "DEBUG", ")", ":", "# This method needs to be in this __init__.py to get the __name__ correct", "# even if urllib3 is vendored within another package.", "logger", "=", "logging", ".", "getLogger", "(", "__name__", "...
[ 46, 0 ]
[ 61, 18 ]
python
en
['en', 'error', 'th']
False
disable_warnings
(category=exceptions.HTTPWarning)
Helper for quickly disabling all urllib3 warnings.
Helper for quickly disabling all urllib3 warnings.
def disable_warnings(category=exceptions.HTTPWarning): """ Helper for quickly disabling all urllib3 warnings. """ warnings.simplefilter("ignore", category)
[ "def", "disable_warnings", "(", "category", "=", "exceptions", ".", "HTTPWarning", ")", ":", "warnings", ".", "simplefilter", "(", "\"ignore\"", ",", "category", ")" ]
[ 81, 0 ]
[ 85, 45 ]
python
en
['en', 'error', 'th']
False
get_user
()
Return the current user name, or None if getuser() does not work in the current environment (see #1010).
Return the current user name, or None if getuser() does not work in the current environment (see #1010).
def get_user(): """Return the current user name, or None if getuser() does not work in the current environment (see #1010). """ import getpass try: return getpass.getuser() except (ImportError, KeyError): return None
[ "def", "get_user", "(", ")", ":", "import", "getpass", "try", ":", "return", "getpass", ".", "getuser", "(", ")", "except", "(", "ImportError", ",", "KeyError", ")", ":", "return", "None" ]
[ 75, 0 ]
[ 83, 19 ]
python
en
['en', 'en', 'en']
True
pytest_configure
(config)
Create a TempdirFactory and attach it to the config object. This is to comply with existing plugins which expect the handler to be available at pytest_configure time, but ideally should be moved entirely to the tmpdir_factory session fixture.
Create a TempdirFactory and attach it to the config object.
def pytest_configure(config): """Create a TempdirFactory and attach it to the config object. This is to comply with existing plugins which expect the handler to be available at pytest_configure time, but ideally should be moved entirely to the tmpdir_factory session fixture. """ mp = MonkeyPatc...
[ "def", "pytest_configure", "(", "config", ")", ":", "mp", "=", "MonkeyPatch", "(", ")", "t", "=", "TempdirFactory", "(", "config", ")", "config", ".", "_cleanup", ".", "extend", "(", "[", "mp", ".", "undo", ",", "t", ".", "finish", "]", ")", "mp", ...
[ 90, 0 ]
[ 101, 65 ]
python
en
['en', 'en', 'en']
True
tmpdir_factory
(request)
Return a TempdirFactory instance for the test session.
Return a TempdirFactory instance for the test session.
def tmpdir_factory(request): """Return a TempdirFactory instance for the test session. """ return request.config._tmpdirhandler
[ "def", "tmpdir_factory", "(", "request", ")", ":", "return", "request", ".", "config", ".", "_tmpdirhandler" ]
[ 105, 0 ]
[ 108, 40 ]
python
en
['en', 'en', 'en']
True
tmpdir
(request, tmpdir_factory)
Return a temporary directory path object which is unique to each test function invocation, created as a sub directory of the base temporary directory. The returned object is a `py.path.local`_ path object.
Return a temporary directory path object which is unique to each test function invocation, created as a sub directory of the base temporary directory. The returned object is a `py.path.local`_ path object.
def tmpdir(request, tmpdir_factory): """Return a temporary directory path object which is unique to each test function invocation, created as a sub directory of the base temporary directory. The returned object is a `py.path.local`_ path object. """ name = request.node.name name = re.su...
[ "def", "tmpdir", "(", "request", ",", "tmpdir_factory", ")", ":", "name", "=", "request", ".", "node", ".", "name", "name", "=", "re", ".", "sub", "(", "r\"[\\W]\"", ",", "\"_\"", ",", "name", ")", "MAXVAL", "=", "30", "if", "len", "(", "name", ")"...
[ 112, 0 ]
[ 125, 12 ]
python
en
['en', 'en', 'en']
True
TempdirFactory.ensuretemp
(self, string, dir=1)
(deprecated) return temporary directory path with the given string as the trailing part. It is usually better to use the 'tmpdir' function argument which provides an empty unique-per-test-invocation directory and is guaranteed to be empty.
(deprecated) return temporary directory path with the given string as the trailing part. It is usually better to use the 'tmpdir' function argument which provides an empty unique-per-test-invocation directory and is guaranteed to be empty.
def ensuretemp(self, string, dir=1): """ (deprecated) return temporary directory path with the given string as the trailing part. It is usually better to use the 'tmpdir' function argument which provides an empty unique-per-test-invocation directory and is guaran...
[ "def", "ensuretemp", "(", "self", ",", "string", ",", "dir", "=", "1", ")", ":", "# py.log._apiwarn(\">1.1\", \"use tmpdir function argument\")", "return", "self", ".", "getbasetemp", "(", ")", ".", "ensure", "(", "string", ",", "dir", "=", "dir", ")" ]
[ 20, 4 ]
[ 28, 57 ]
python
en
['en', 'en', 'en']
True
TempdirFactory.mktemp
(self, basename, numbered=True)
Create a subdirectory of the base temporary directory and return it. If ``numbered``, ensure the directory is unique by adding a number prefix greater than any existing one.
Create a subdirectory of the base temporary directory and return it. If ``numbered``, ensure the directory is unique by adding a number prefix greater than any existing one.
def mktemp(self, basename, numbered=True): """Create a subdirectory of the base temporary directory and return it. If ``numbered``, ensure the directory is unique by adding a number prefix greater than any existing one. """ basetemp = self.getbasetemp() if not numbered: ...
[ "def", "mktemp", "(", "self", ",", "basename", ",", "numbered", "=", "True", ")", ":", "basetemp", "=", "self", ".", "getbasetemp", "(", ")", "if", "not", "numbered", ":", "p", "=", "basetemp", ".", "mkdir", "(", "basename", ")", "else", ":", "p", ...
[ 30, 4 ]
[ 42, 16 ]
python
en
['en', 'en', 'en']
True
TempdirFactory.getbasetemp
(self)
return base temporary directory.
return base temporary directory.
def getbasetemp(self): """ return base temporary directory. """ try: return self._basetemp except AttributeError: basetemp = self.config.option.basetemp if basetemp: basetemp = py.path.local(basetemp) if basetemp.check(): ...
[ "def", "getbasetemp", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_basetemp", "except", "AttributeError", ":", "basetemp", "=", "self", ".", "config", ".", "option", ".", "basetemp", "if", "basetemp", ":", "basetemp", "=", "py", ".", "path...
[ 44, 4 ]
[ 69, 20 ]
python
en
['en', 'en', 'en']
True
get_msvcr
()
Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later.
Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later.
def get_msvcr(): """Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. """ msc_pos = sys.version.find('MSC v.') if msc_pos != -1: msc_ver = sys.version[msc_pos+6:msc_pos+10] if msc_ver == '1300': # MSVC 7.0 return ['msvcr7...
[ "def", "get_msvcr", "(", ")", ":", "msc_pos", "=", "sys", ".", "version", ".", "find", "(", "'MSC v.'", ")", "if", "msc_pos", "!=", "-", "1", ":", "msc_ver", "=", "sys", ".", "version", "[", "msc_pos", "+", "6", ":", "msc_pos", "+", "10", "]", "i...
[ 60, 0 ]
[ 83, 73 ]
python
en
['en', 'en', 'en']
True
check_config_h
()
Check if the current Python installation appears amenable to building extensions with GCC. Returns a tuple (status, details), where 'status' is one of the following constants: - CONFIG_H_OK: all is well, go ahead and compile - CONFIG_H_NOTOK: doesn't look good - CONFIG_H_UNCERTAIN: not sure --...
Check if the current Python installation appears amenable to building extensions with GCC.
def check_config_h(): """Check if the current Python installation appears amenable to building extensions with GCC. Returns a tuple (status, details), where 'status' is one of the following constants: - CONFIG_H_OK: all is well, go ahead and compile - CONFIG_H_NOTOK: doesn't look good - CO...
[ "def", "check_config_h", "(", ")", ":", "# XXX since this function also checks sys.version, it's not strictly a", "# \"pyconfig.h\" check -- should probably be renamed...", "from", "distutils", "import", "sysconfig", "# if sys.version contains GCC then python was compiled with GCC, and the", ...
[ 325, 0 ]
[ 366, 62 ]
python
en
['en', 'en', 'en']
True
_find_exe_version
(cmd)
Find the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None.
Find the version of an executable by running `cmd` in the shell.
def _find_exe_version(cmd): """Find the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None. """ executable = cmd.split()[0] if find_executable(executable) is None: return None out = Popen(cmd, ...
[ "def", "_find_exe_version", "(", "cmd", ")", ":", "executable", "=", "cmd", ".", "split", "(", ")", "[", "0", "]", "if", "find_executable", "(", "executable", ")", "is", "None", ":", "return", "None", "out", "=", "Popen", "(", "cmd", ",", "shell", "=...
[ 370, 0 ]
[ 389, 49 ]
python
en
['en', 'en', 'en']
True
get_versions
()
Try to find out the versions of gcc, ld and dllwrap. If not possible it returns None for it.
Try to find out the versions of gcc, ld and dllwrap.
def get_versions(): """ Try to find out the versions of gcc, ld and dllwrap. If not possible it returns None for it. """ commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version'] return tuple([_find_exe_version(cmd) for cmd in commands])
[ "def", "get_versions", "(", ")", ":", "commands", "=", "[", "'gcc -dumpversion'", ",", "'ld -v'", ",", "'dllwrap --version'", "]", "return", "tuple", "(", "[", "_find_exe_version", "(", "cmd", ")", "for", "cmd", "in", "commands", "]", ")" ]
[ 391, 0 ]
[ 397, 62 ]
python
en
['en', 'en', 'en']
True
is_cygwingcc
()
Try to determine if the gcc that would be used is from cygwin.
Try to determine if the gcc that would be used is from cygwin.
def is_cygwingcc(): '''Try to determine if the gcc that would be used is from cygwin.''' out_string = check_output(['gcc', '-dumpmachine']) return out_string.strip().endswith(b'cygwin')
[ "def", "is_cygwingcc", "(", ")", ":", "out_string", "=", "check_output", "(", "[", "'gcc'", ",", "'-dumpmachine'", "]", ")", "return", "out_string", ".", "strip", "(", ")", ".", "endswith", "(", "b'cygwin'", ")" ]
[ 399, 0 ]
[ 402, 49 ]
python
en
['en', 'en', 'en']
True
CygwinCCompiler._compile
(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
Compiles the source by spawning GCC and windres if needed.
Compiles the source by spawning GCC and windres if needed.
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): """Compiles the source by spawning GCC and windres if needed.""" if ext == '.rc' or ext == '.res': # gcc needs '.res' and '.rc' compiled to object files !!! try: self.spawn(["windres", "-i", src,...
[ "def", "_compile", "(", "self", ",", "obj", ",", "src", ",", "ext", ",", "cc_args", ",", "extra_postargs", ",", "pp_opts", ")", ":", "if", "ext", "==", "'.rc'", "or", "ext", "==", "'.res'", ":", "# gcc needs '.res' and '.rc' compiled to object files !!!", "try...
[ 156, 4 ]
[ 169, 39 ]
python
en
['en', 'en', 'en']
True
CygwinCCompiler.link
(self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None)
Link the objects.
Link the objects.
def link(self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): """Link the objects.""" #...
[ "def", "link", "(", "self", ",", "target_desc", ",", "objects", ",", "output_filename", ",", "output_dir", "=", "None", ",", "libraries", "=", "None", ",", "library_dirs", "=", "None", ",", "runtime_library_dirs", "=", "None", ",", "export_symbols", "=", "No...
[ 171, 4 ]
[ 245, 39 ]
python
en
['en', 'en', 'en']
True
CygwinCCompiler.object_filenames
(self, source_filenames, strip_dir=0, output_dir='')
Adds supports for rc and res files.
Adds supports for rc and res files.
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): """Adds supports for rc and res files.""" if output_dir is None: output_dir = '' obj_names = [] for src_name in source_filenames: # use normcase to make sure '.rc' is really '.rc' and not '....
[ "def", "object_filenames", "(", "self", ",", "source_filenames", ",", "strip_dir", "=", "0", ",", "output_dir", "=", "''", ")", ":", "if", "output_dir", "is", "None", ":", "output_dir", "=", "''", "obj_names", "=", "[", "]", "for", "src_name", "in", "sou...
[ 249, 4 ]
[ 269, 24 ]
python
en
['en', 'en', 'en']
True
segregate
(str)
3.1 Basic code point segregation
3.1 Basic code point segregation
def segregate(str): """3.1 Basic code point segregation""" base = bytearray() extended = set() for c in str: if ord(c) < 128: base.append(ord(c)) else: extended.add(c) extended = sorted(extended) return bytes(base), extended
[ "def", "segregate", "(", "str", ")", ":", "base", "=", "bytearray", "(", ")", "extended", "=", "set", "(", ")", "for", "c", "in", "str", ":", "if", "ord", "(", "c", ")", "<", "128", ":", "base", ".", "append", "(", "ord", "(", "c", ")", ")", ...
[ 9, 0 ]
[ 19, 32 ]
python
ca
['ca', 'zu', 'en']
False
selective_len
(str, max)
Return the length of str, considering only characters below max.
Return the length of str, considering only characters below max.
def selective_len(str, max): """Return the length of str, considering only characters below max.""" res = 0 for c in str: if ord(c) < max: res += 1 return res
[ "def", "selective_len", "(", "str", ",", "max", ")", ":", "res", "=", "0", "for", "c", "in", "str", ":", "if", "ord", "(", "c", ")", "<", "max", ":", "res", "+=", "1", "return", "res" ]
[ 21, 0 ]
[ 27, 14 ]
python
en
['en', 'en', 'en']
True
selective_find
(str, char, index, pos)
Return a pair (index, pos), indicating the next occurrence of char in str. index is the position of the character considering only ordinals up to and including char, and pos is the position in the full string. index/pos is the starting position in the full string.
Return a pair (index, pos), indicating the next occurrence of char in str. index is the position of the character considering only ordinals up to and including char, and pos is the position in the full string. index/pos is the starting position in the full string.
def selective_find(str, char, index, pos): """Return a pair (index, pos), indicating the next occurrence of char in str. index is the position of the character considering only ordinals up to and including char, and pos is the position in the full string. index/pos is the starting position in the full ...
[ "def", "selective_find", "(", "str", ",", "char", ",", "index", ",", "pos", ")", ":", "l", "=", "len", "(", "str", ")", "while", "1", ":", "pos", "+=", "1", "if", "pos", "==", "l", ":", "return", "(", "-", "1", ",", "-", "1", ")", "c", "=",...
[ 29, 0 ]
[ 45, 22 ]
python
en
['en', 'en', 'en']
True
insertion_unsort
(str, extended)
3.2 Insertion unsort coding
3.2 Insertion unsort coding
def insertion_unsort(str, extended): """3.2 Insertion unsort coding""" oldchar = 0x80 result = [] oldindex = -1 for c in extended: index = pos = -1 char = ord(c) curlen = selective_len(str, char) delta = (curlen+1) * (char - oldchar) while 1: index...
[ "def", "insertion_unsort", "(", "str", ",", "extended", ")", ":", "oldchar", "=", "0x80", "result", "=", "[", "]", "oldindex", "=", "-", "1", "for", "c", "in", "extended", ":", "index", "=", "pos", "=", "-", "1", "char", "=", "ord", "(", "c", ")"...
[ 47, 0 ]
[ 67, 17 ]
python
de
['de', 'ja', 'en']
False
generate_generalized_integer
(N, bias)
3.3 Generalized variable-length integers
3.3 Generalized variable-length integers
def generate_generalized_integer(N, bias): """3.3 Generalized variable-length integers""" result = bytearray() j = 0 while 1: t = T(j, bias) if N < t: result.append(digits[N]) return bytes(result) result.append(digits[t + ((N - t) % (36 - t))]) N =...
[ "def", "generate_generalized_integer", "(", "N", ",", "bias", ")", ":", "result", "=", "bytearray", "(", ")", "j", "=", "0", "while", "1", ":", "t", "=", "T", "(", "j", ",", "bias", ")", "if", "N", "<", "t", ":", "result", ".", "append", "(", "...
[ 77, 0 ]
[ 88, 14 ]
python
en
['de', 'en', 'en']
True
generate_integers
(baselen, deltas)
3.4 Bias adaptation
3.4 Bias adaptation
def generate_integers(baselen, deltas): """3.4 Bias adaptation""" # Punycode parameters: initial bias = 72, damp = 700, skew = 38 result = bytearray() bias = 72 for points, delta in enumerate(deltas): s = generate_generalized_integer(delta, bias) result.extend(s) bias = adapt...
[ "def", "generate_integers", "(", "baselen", ",", "deltas", ")", ":", "# Punycode parameters: initial bias = 72, damp = 700, skew = 38", "result", "=", "bytearray", "(", ")", "bias", "=", "72", "for", "points", ",", "delta", "in", "enumerate", "(", "deltas", ")", "...
[ 105, 0 ]
[ 114, 24 ]
python
en
['es', 'lt', 'en']
False
decode_generalized_number
(extended, extpos, bias, errors)
3.3 Generalized variable-length integers
3.3 Generalized variable-length integers
def decode_generalized_number(extended, extpos, bias, errors): """3.3 Generalized variable-length integers""" result = 0 w = 1 j = 0 while 1: try: char = ord(extended[extpos]) except IndexError: if errors == "strict": raise UnicodeError("incomp...
[ "def", "decode_generalized_number", "(", "extended", ",", "extpos", ",", "bias", ",", "errors", ")", ":", "result", "=", "0", "w", "=", "1", "j", "=", "0", "while", "1", ":", "try", ":", "char", "=", "ord", "(", "extended", "[", "extpos", "]", ")",...
[ 126, 0 ]
[ 153, 14 ]
python
en
['de', 'en', 'en']
True
insertion_sort
(base, extended, errors)
3.2 Insertion unsort coding
3.2 Insertion unsort coding
def insertion_sort(base, extended, errors): """3.2 Insertion unsort coding""" char = 0x80 pos = -1 bias = 72 extpos = 0 while extpos < len(extended): newpos, delta = decode_generalized_number(extended, extpos, bias, errors) if del...
[ "def", "insertion_sort", "(", "base", ",", "extended", ",", "errors", ")", ":", "char", "=", "0x80", "pos", "=", "-", "1", "bias", "=", "72", "extpos", "=", "0", "while", "extpos", "<", "len", "(", "extended", ")", ":", "newpos", ",", "delta", "=",...
[ 156, 0 ]
[ 179, 15 ]
python
de
['de', 'ja', 'en']
False
make_user_stats_chunk
(error_dict: Dict[str, Any])
Creates a stat chunk about total occurrences and users affected for the error. Example: usersAffected: 2, totalOccurrences: 10 Output: 2 users affected with 10 total occurrences :param error_dict: The error dictionary containing the error keys and values :returns: A message chunk that will be ...
Creates a stat chunk about total occurrences and users affected for the error.
def make_user_stats_chunk(error_dict: Dict[str, Any]) -> str: """Creates a stat chunk about total occurrences and users affected for the error. Example: usersAffected: 2, totalOccurrences: 10 Output: 2 users affected with 10 total occurrences :param error_dict: The error dictionary containing the ...
[ "def", "make_user_stats_chunk", "(", "error_dict", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "users_affected", "=", "error_dict", "[", "\"usersAffected\"", "]", "total_occurrences", "=", "error_dict", "[", "\"totalOccurrences\"", "]", "# O...
[ 45, 0 ]
[ 60, 92 ]
python
en
['en', 'en', 'en']
True
make_time_chunk
(error_dict: Dict[str, Any])
Creates a time message chunk. Example: firstOccurredOn: "X", lastOccurredOn: "Y" Output: First occurred: X Last occurred: Y :param error_dict: The error dictionary containing the error keys and values :returns: A message chunk that will be added to the main message
Creates a time message chunk.
def make_time_chunk(error_dict: Dict[str, Any]) -> str: """Creates a time message chunk. Example: firstOccurredOn: "X", lastOccurredOn: "Y" Output: First occurred: X Last occurred: Y :param error_dict: The error dictionary containing the error keys and values :returns: A message chunk ...
[ "def", "make_time_chunk", "(", "error_dict", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "# Make the timestamp more readable to a human.", "time_first", "=", "parse_time", "(", "error_dict", "[", "\"firstOccurredOn\"", "]", ")", "time_last", "...
[ 63, 0 ]
[ 80, 84 ]
python
en
['en', 'en', 'en']
True
make_message_chunk
(message: str)
Creates a message chunk if exists. Example: message: "This is an example message" returns "Message: This is an example message". Whereas message: "" returns "". :param message: The value of message inside of the error dictionary :returns: A message chunk if there exists an additional message, otherwis...
Creates a message chunk if exists.
def make_message_chunk(message: str) -> str: """Creates a message chunk if exists. Example: message: "This is an example message" returns "Message: This is an example message". Whereas message: "" returns "". :param message: The value of message inside of the error dictionary :returns: A message c...
[ "def", "make_message_chunk", "(", "message", ":", "str", ")", "->", "str", ":", "# \"Message\" shouldn't be included if there is none supplied.", "return", "f\"* **Message**: {message}\\n\"", "if", "message", "!=", "\"\"", "else", "\"\"" ]
[ 83, 0 ]
[ 94, 65 ]
python
en
['en', 'en', 'en']
True
make_app_info_chunk
(app_dict: Dict[str, str])
Creates a message chunk that contains the application info and the link to the Raygun dashboard about the application. :param app_dict: The application dictionary obtained from the payload :returns: A message chunk that will be added to the main message
Creates a message chunk that contains the application info and the link to the Raygun dashboard about the application.
def make_app_info_chunk(app_dict: Dict[str, str]) -> str: """Creates a message chunk that contains the application info and the link to the Raygun dashboard about the application. :param app_dict: The application dictionary obtained from the payload :returns: A message chunk that will be added to the m...
[ "def", "make_app_info_chunk", "(", "app_dict", ":", "Dict", "[", "str", ",", "str", "]", ")", "->", "str", ":", "app_name", "=", "app_dict", "[", "\"name\"", "]", "app_url", "=", "app_dict", "[", "\"url\"", "]", "return", "f\"* **Application details**: [{app_n...
[ 97, 0 ]
[ 106, 66 ]
python
en
['en', 'en', 'en']
True
notification_message_follow_up
(payload: Dict[str, Any])
Creates a message for a repeating error follow up :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted
Creates a message for a repeating error follow up
def notification_message_follow_up(payload: Dict[str, Any]) -> str: """Creates a message for a repeating error follow up :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted """ message = "" # Link to Raygun about the follow up followup_link_md = "[fo...
[ "def", "notification_message_follow_up", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "message", "=", "\"\"", "# Link to Raygun about the follow up", "followup_link_md", "=", "\"[follow-up error]({})\"", ".", "format", "(", "paylo...
[ 109, 0 ]
[ 140, 18 ]
python
en
['en', 'en', 'en']
True
notification_message_error_occurred
(payload: Dict[str, Any])
Creates a message for a new error or reoccurred error :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted
Creates a message for a new error or reoccurred error
def notification_message_error_occurred(payload: Dict[str, Any]) -> str: """Creates a message for a new error or reoccurred error :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted """ message = "" # Provide a clickable link that goes to Raygun about th...
[ "def", "notification_message_error_occurred", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "message", "=", "\"\"", "# Provide a clickable link that goes to Raygun about this error.", "error_link_md", "=", "\"[Error]({})\"", ".", "form...
[ 143, 0 ]
[ 198, 18 ]
python
en
['en', 'en', 'en']
True
compose_notification_message
(payload: Dict[str, Any])
Composes a message that contains information on the error :param payload: Raygun payload :return: Returns a response message
Composes a message that contains information on the error
def compose_notification_message(payload: Dict[str, Any]) -> str: """Composes a message that contains information on the error :param payload: Raygun payload :return: Returns a response message """ # Get the event type of the error. This can be "NewErrorOccurred", # "ErrorReoccurred", "OneMinu...
[ "def", "compose_notification_message", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "# Get the event type of the error. This can be \"NewErrorOccurred\",", "# \"ErrorReoccurred\", \"OneMinuteFollowUp\", \"FiveMinuteFollowUp\", ...,", "# \"HourlyF...
[ 201, 0 ]
[ 225, 53 ]
python
en
['en', 'en', 'en']
True
activity_message
(payload: Dict[str, Any])
Creates a message from an activity that is being taken for an error :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted
Creates a message from an activity that is being taken for an error
def activity_message(payload: Dict[str, Any]) -> str: """Creates a message from an activity that is being taken for an error :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted """ message = "" error_link_md = "[Error]({})".format(payload["error"]["url"]...
[ "def", "activity_message", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "message", "=", "\"\"", "error_link_md", "=", "\"[Error]({})\"", ".", "format", "(", "payload", "[", "\"error\"", "]", "[", "\"url\"", "]", ")", ...
[ 228, 0 ]
[ 255, 18 ]
python
en
['en', 'en', 'en']
True
compose_activity_message
(payload: Dict[str, Any])
Composes a message that contains an activity that is being taken to an error, such as commenting, assigning an error to a user, ignoring the error, etc. :param payload: Raygun payload :return: Returns a response message
Composes a message that contains an activity that is being taken to an error, such as commenting, assigning an error to a user, ignoring the error, etc.
def compose_activity_message(payload: Dict[str, Any]) -> str: """Composes a message that contains an activity that is being taken to an error, such as commenting, assigning an error to a user, ignoring the error, etc. :param payload: Raygun payload :return: Returns a response message """ e...
[ "def", "compose_activity_message", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "event_type", "=", "payload", "[", "\"eventType\"", "]", "# Activity is separated into three main categories: status changes (", "# ignores, resolved), erro...
[ 258, 0 ]
[ 283, 53 ]
python
en
['en', 'en', 'en']
True
parse_time
(timestamp: str)
Parses and returns the timestamp provided :param timestamp: The timestamp provided by the payload :returns: A string containing the time
Parses and returns the timestamp provided
def parse_time(timestamp: str) -> str: """Parses and returns the timestamp provided :param timestamp: The timestamp provided by the payload :returns: A string containing the time """ # Raygun provides two timestamp format, one with the Z at the end, # and one without the Z. format = "%Y-%...
[ "def", "parse_time", "(", "timestamp", ":", "str", ")", "->", "str", ":", "# Raygun provides two timestamp format, one with the Z at the end,", "# and one without the Z.", "format", "=", "\"%Y-%m-%dT%H:%M:%S\"", "format", "+=", "\"Z\"", "if", "timestamp", "[", "-", "1", ...
[ 286, 0 ]
[ 299, 22 ]
python
en
['en', 'en', 'en']
True
CacheEntry.__repr__
(self)
Debug string.
Debug string.
def __repr__(self): """Debug string.""" return "(s={},last={},hits={},cf={},l={},bt={})\n".format( self.value_size, self.last_access_number, self.num_hits, self.cf_id, self.level, self.block_type, )
[ "def", "__repr__", "(", "self", ")", ":", "return", "\"(s={},last={},hits={},cf={},l={},bt={})\\n\"", ".", "format", "(", "self", ".", "value_size", ",", "self", ".", "last_access_number", ",", "self", ".", "num_hits", ",", "self", ".", "cf_id", ",", "self", "...
[ 109, 4 ]
[ 118, 9 ]
python
en
['en', 'ceb', 'en']
False
HashTable.random_sample
(self, sample_size)
Randomly sample 'sample_size' hash entries from the table.
Randomly sample 'sample_size' hash entries from the table.
def random_sample(self, sample_size): """Randomly sample 'sample_size' hash entries from the table.""" samples = [] index = random.randint(0, len(self.table) - 1) pos = index # Starting from index, adding hash entries to the sample list until # sample_size is met or we ra...
[ "def", "random_sample", "(", "self", ",", "sample_size", ")", ":", "samples", "=", "[", "]", "index", "=", "random", ".", "randint", "(", "0", ",", "len", "(", "self", ".", "table", ")", "-", "1", ")", "pos", "=", "index", "# Starting from index, addin...
[ 162, 4 ]
[ 182, 22 ]
python
en
['en', 'en', 'en']
True
HashTable.insert
(self, key, hash, value)
Insert a hash entry in the table. Replace the old entry if it already exists.
Insert a hash entry in the table. Replace the old entry if it already exists.
def insert(self, key, hash, value): """ Insert a hash entry in the table. Replace the old entry if it already exists. """ self.grow() inserted = False index = hash % len(self.table) if self.table[index] is None: self.table[index] = [] #...
[ "def", "insert", "(", "self", ",", "key", ",", "hash", ",", "value", ")", ":", "self", ".", "grow", "(", ")", "inserted", "=", "False", "index", "=", "hash", "%", "len", "(", "self", ".", "table", ")", "if", "self", ".", "table", "[", "index", ...
[ 207, 4 ]
[ 234, 26 ]
python
en
['en', 'error', 'th']
False
Cache._lookup
(self, trace_record, key, hash)
Look up the key in the cache. Returns true upon a cache hit, false otherwise.
Look up the key in the cache. Returns true upon a cache hit, false otherwise.
def _lookup(self, trace_record, key, hash): """ Look up the key in the cache. Returns true upon a cache hit, false otherwise. """ raise NotImplementedError
[ "def", "_lookup", "(", "self", ",", "trace_record", ",", "key", ",", "hash", ")", ":", "raise", "NotImplementedError" ]
[ 681, 4 ]
[ 686, 33 ]
python
en
['en', 'error', 'th']
False
Cache._evict
(self, trace_record, key, hash, value_size)
Evict entries in the cache until there is enough room to insert the new entry with 'value_size'.
Evict entries in the cache until there is enough room to insert the new entry with 'value_size'.
def _evict(self, trace_record, key, hash, value_size): """ Evict entries in the cache until there is enough room to insert the new entry with 'value_size'. """ raise NotImplementedError
[ "def", "_evict", "(", "self", ",", "trace_record", ",", "key", ",", "hash", ",", "value_size", ")", ":", "raise", "NotImplementedError" ]
[ 688, 4 ]
[ 693, 33 ]
python
en
['en', 'error', 'th']
False
Cache._insert
(self, trace_record, key, hash, value_size)
Insert the new entry into the cache.
Insert the new entry into the cache.
def _insert(self, trace_record, key, hash, value_size): """ Insert the new entry into the cache. """ raise NotImplementedError
[ "def", "_insert", "(", "self", ",", "trace_record", ",", "key", ",", "hash", ",", "value_size", ")", ":", "raise", "NotImplementedError" ]
[ 695, 4 ]
[ 699, 33 ]
python
en
['en', 'error', 'th']
False
Cache._should_admit
(self, trace_record, key, hash, value_size)
A custom admission policy to decide whether we should admit the new entry upon a cache miss. Returns true if the new entry should be admitted, false otherwise.
A custom admission policy to decide whether we should admit the new entry upon a cache miss. Returns true if the new entry should be admitted, false otherwise.
def _should_admit(self, trace_record, key, hash, value_size): """ A custom admission policy to decide whether we should admit the new entry upon a cache miss. Returns true if the new entry should be admitted, false otherwise. """ raise NotImplementedError
[ "def", "_should_admit", "(", "self", ",", "trace_record", ",", "key", ",", "hash", ",", "value_size", ")", ":", "raise", "NotImplementedError" ]
[ 701, 4 ]
[ 707, 33 ]
python
en
['en', 'error', 'th']
False
Cache.cache_name
(self)
The name of the replacement policy.
The name of the replacement policy.
def cache_name(self): """ The name of the replacement policy. """ raise NotImplementedError
[ "def", "cache_name", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 709, 4 ]
[ 713, 33 ]
python
en
['en', 'error', 'th']
False
Cache.access
(self, trace_record)
Access a trace record. The simulator calls this function to access a trace record.
Access a trace record. The simulator calls this function to access a trace record.
def access(self, trace_record): """ Access a trace record. The simulator calls this function to access a trace record. """ assert self.used_size <= self.cache_size if ( self.enable_cache_row_key > 0 and trace_record.caller == 1 and trac...
[ "def", "access", "(", "self", ",", "trace_record", ")", ":", "assert", "self", ".", "used_size", "<=", "self", ".", "cache_size", "if", "(", "self", ".", "enable_cache_row_key", ">", "0", "and", "trace_record", ".", "caller", "==", "1", "and", "trace_recor...
[ 723, 4 ]
[ 747, 9 ]
python
en
['en', 'error', 'th']
False
PQTable.pqinsert
(self, entry)
Add a new key or update the priority of an existing key
Add a new key or update the priority of an existing key
def pqinsert(self, entry): "Add a new key or update the priority of an existing key" # Remove the entry from the table first. removed_entry = self.table.pop(entry.key, None) if removed_entry: # Mark as removed since there is no 'remove' API in heappq. # Instead, a...
[ "def", "pqinsert", "(", "self", ",", "entry", ")", ":", "# Remove the entry from the table first.", "removed_entry", "=", "self", ".", "table", ".", "pop", "(", "entry", ".", "key", ",", "None", ")", "if", "removed_entry", ":", "# Mark as removed since there is no...
[ 1141, 4 ]
[ 1151, 28 ]
python
en
['en', 'en', 'en']
True
OperationLogMiddlewareTest.test_process_response_for_get_no_target
(self, mock_logger)
In default setting, Get method is not logged
In default setting, Get method is not logged
def test_process_response_for_get_no_target(self, mock_logger): """In default setting, Get method is not logged""" request, response = self._test_ready_for_get() get_response = mock.Mock(return_value=response) olm = middleware.OperationLogMiddleware(get_response) resp = olm(requ...
[ "def", "test_process_response_for_get_no_target", "(", "self", ",", "mock_logger", ")", ":", "request", ",", "response", "=", "self", ".", "_test_ready_for_get", "(", ")", "get_response", "=", "mock", ".", "Mock", "(", "return_value", "=", "response", ")", "olm"...
[ 120, 4 ]
[ 130, 47 ]
python
en
['en', 'en', 'en']
True
keystoneclient
(request, admin=False)
Returns a client connected to the Keystone backend. Several forms of authentication are supported: * Username + password -> Unscoped authentication * Username + password + tenant id -> Scoped authentication * Unscoped token -> Unscoped authentication * Unscoped token + tenant id ->...
Returns a client connected to the Keystone backend.
def keystoneclient(request, admin=False): """Returns a client connected to the Keystone backend. Several forms of authentication are supported: * Username + password -> Unscoped authentication * Username + password + tenant id -> Scoped authentication * Unscoped token -> Unscoped authe...
[ "def", "keystoneclient", "(", "request", ",", "admin", "=", "False", ")", ":", "client_version", "=", "VERSIONS", ".", "get_active_version", "(", ")", "user", "=", "request", ".", "user", "token_id", "=", "user", ".", "token", ".", "id", "if", "is_multi_do...
[ 124, 0 ]
[ 189, 15 ]
python
en
['en', 'en', 'en']
True
get_default_domain
(request, get_name=True)
Gets the default domain object to use when creating Identity object. Returns the domain context if is set, otherwise return the domain of the logon user. :param get_name: Whether to get the domain name from Keystone if the context isn't set. Setting this to False prevents an unnecessary call ...
Gets the default domain object to use when creating Identity object.
def get_default_domain(request, get_name=True): """Gets the default domain object to use when creating Identity object. Returns the domain context if is set, otherwise return the domain of the logon user. :param get_name: Whether to get the domain name from Keystone if the context isn't set. ...
[ "def", "get_default_domain", "(", "request", ",", "get_name", "=", "True", ")", ":", "domain_id", "=", "request", ".", "session", ".", "get", "(", "\"domain_context\"", ",", "None", ")", "domain_name", "=", "request", ".", "session", ".", "get", "(", "\"do...
[ 264, 0 ]
[ 304, 17 ]
python
en
['en', 'en', 'en']
True
get_effective_domain_id
(request)
Gets the id of the default domain. If the requests default domain is the same as DEFAULT_DOMAIN, return None.
Gets the id of the default domain.
def get_effective_domain_id(request): """Gets the id of the default domain. If the requests default domain is the same as DEFAULT_DOMAIN, return None. """ default_domain = get_default_domain(request) domain_id = default_domain.get('id') domain_name = default_domain.get('name') return No...
[ "def", "get_effective_domain_id", "(", "request", ")", ":", "default_domain", "=", "get_default_domain", "(", "request", ")", "domain_id", "=", "default_domain", ".", "get", "(", "'id'", ")", "domain_name", "=", "default_domain", ".", "get", "(", "'name'", ")", ...
[ 307, 0 ]
[ 316, 63 ]
python
en
['en', 'en', 'en']
True
get_project_groups_roles
(request, project)
Gets the groups roles in a given project. :param request: the request entity containing the login user information :param project: the project to filter the groups roles. It accepts both project object resource or project ID :returns group_roles: a dictionary mapping the groups and the...
Gets the groups roles in a given project.
def get_project_groups_roles(request, project): """Gets the groups roles in a given project. :param request: the request entity containing the login user information :param project: the project to filter the groups roles. It accepts both project object resource or project ID :retur...
[ "def", "get_project_groups_roles", "(", "request", ",", "project", ")", ":", "groups_roles", "=", "collections", ".", "defaultdict", "(", "list", ")", "project_role_assignments", "=", "role_assignments_list", "(", "request", ",", "project", "=", "project", ")", "f...
[ 573, 0 ]
[ 598, 23 ]
python
en
['en', 'en', 'en']
True
role_list
(request, filters=None)
Returns a global list of available roles.
Returns a global list of available roles.
def role_list(request, filters=None): """Returns a global list of available roles.""" manager = keystoneclient(request, admin=True).roles roles = [] kwargs = {} if filters is not None: kwargs.update(filters) if 'id' in kwargs: try: roles = [manager.get(kwargs['id'])] ...
[ "def", "role_list", "(", "request", ",", "filters", "=", "None", ")", ":", "manager", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", ".", "roles", "roles", "=", "[", "]", "kwargs", "=", "{", "}", "if", "filters", "is", "not", ...
[ 641, 0 ]
[ 657, 16 ]
python
en
['en', 'en', 'en']
True
roles_for_user
(request, user, project=None, domain=None)
Returns a list of user roles scoped to a project or domain.
Returns a list of user roles scoped to a project or domain.
def roles_for_user(request, user, project=None, domain=None): """Returns a list of user roles scoped to a project or domain.""" manager = keystoneclient(request, admin=True).roles return manager.list(user=user, domain=domain, project=project)
[ "def", "roles_for_user", "(", "request", ",", "user", ",", "project", "=", "None", ",", "domain", "=", "None", ")", ":", "manager", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", ".", "roles", "return", "manager", ".", "list", "...
[ 661, 0 ]
[ 664, 66 ]
python
en
['en', 'en', 'en']
True
add_domain_user_role
(request, user, role, domain)
Adds a role for a user on a domain.
Adds a role for a user on a domain.
def add_domain_user_role(request, user, role, domain): """Adds a role for a user on a domain.""" manager = keystoneclient(request, admin=True).roles return manager.grant(role, user=user, domain=domain)
[ "def", "add_domain_user_role", "(", "request", ",", "user", ",", "role", ",", "domain", ")", ":", "manager", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", ".", "roles", "return", "manager", ".", "grant", "(", "role", ",", "user",...
[ 687, 0 ]
[ 690, 56 ]
python
en
['en', 'en', 'en']
True
remove_domain_user_role
(request, user, role, domain=None)
Removes a given single role for a user from a domain.
Removes a given single role for a user from a domain.
def remove_domain_user_role(request, user, role, domain=None): """Removes a given single role for a user from a domain.""" manager = keystoneclient(request, admin=True).roles return manager.revoke(role, user=user, domain=domain)
[ "def", "remove_domain_user_role", "(", "request", ",", "user", ",", "role", ",", "domain", "=", "None", ")", ":", "manager", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", ".", "roles", "return", "manager", ".", "revoke", "(", "ro...
[ 694, 0 ]
[ 697, 57 ]
python
en
['en', 'en', 'en']
True
add_tenant_user_role
(request, project=None, user=None, role=None, group=None, domain=None)
Adds a role for a user on a tenant.
Adds a role for a user on a tenant.
def add_tenant_user_role(request, project=None, user=None, role=None, group=None, domain=None): """Adds a role for a user on a tenant.""" manager = keystoneclient(request, admin=True).roles manager.grant(role, user=user, project=project, group=group, domain=domain)
[ "def", "add_tenant_user_role", "(", "request", ",", "project", "=", "None", ",", "user", "=", "None", ",", "role", "=", "None", ",", "group", "=", "None", ",", "domain", "=", "None", ")", ":", "manager", "=", "keystoneclient", "(", "request", ",", "adm...
[ 719, 0 ]
[ 724, 45 ]
python
en
['en', 'en', 'en']
True
remove_tenant_user_role
(request, project=None, user=None, role=None, group=None, domain=None)
Removes a given single role for a user from a tenant.
Removes a given single role for a user from a tenant.
def remove_tenant_user_role(request, project=None, user=None, role=None, group=None, domain=None): """Removes a given single role for a user from a tenant.""" manager = keystoneclient(request, admin=True).roles return manager.revoke(role, user=user, project=project, ...
[ "def", "remove_tenant_user_role", "(", "request", ",", "project", "=", "None", ",", "user", "=", "None", ",", "role", "=", "None", ",", "group", "=", "None", ",", "domain", "=", "None", ")", ":", "manager", "=", "keystoneclient", "(", "request", ",", "...
[ 728, 0 ]
[ 733, 53 ]
python
en
['en', 'en', 'en']
True
remove_tenant_user
(request, project=None, user=None, domain=None)
Removes all roles from a user on a tenant, removing them from it.
Removes all roles from a user on a tenant, removing them from it.
def remove_tenant_user(request, project=None, user=None, domain=None): """Removes all roles from a user on a tenant, removing them from it.""" client = keystoneclient(request, admin=True) roles = client.roles.roles_for_user(user, project) for role in roles: remove_tenant_user_role(request, user=...
[ "def", "remove_tenant_user", "(", "request", ",", "project", "=", "None", ",", "user", "=", "None", ",", "domain", "=", "None", ")", ":", "client", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", "roles", "=", "client", ".", "rol...
[ 736, 0 ]
[ 742, 63 ]
python
en
['en', 'en', 'en']
True
add_group_role
(request, role, group, domain=None, project=None)
Adds a role for a group on a domain or project.
Adds a role for a group on a domain or project.
def add_group_role(request, role, group, domain=None, project=None): """Adds a role for a group on a domain or project.""" manager = keystoneclient(request, admin=True).roles return manager.grant(role=role, group=group, domain=domain, project=project)
[ "def", "add_group_role", "(", "request", ",", "role", ",", "group", ",", "domain", "=", "None", ",", "project", "=", "None", ")", ":", "manager", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", ".", "roles", "return", "manager", ...
[ 752, 0 ]
[ 756, 41 ]
python
en
['en', 'en', 'en']
True
remove_group_role
(request, role, group, domain=None, project=None)
Removes a given single role for a group from a domain or project.
Removes a given single role for a group from a domain or project.
def remove_group_role(request, role, group, domain=None, project=None): """Removes a given single role for a group from a domain or project.""" manager = keystoneclient(request, admin=True).roles return manager.revoke(role=role, group=group, project=project, domain=domain)
[ "def", "remove_group_role", "(", "request", ",", "role", ",", "group", ",", "domain", "=", "None", ",", "project", "=", "None", ")", ":", "manager", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", ".", "roles", "return", "manager",...
[ 760, 0 ]
[ 764, 40 ]
python
en
['en', 'en', 'en']
True
remove_group_roles
(request, group, domain=None, project=None)
Removes all roles from a group on a domain or project.
Removes all roles from a group on a domain or project.
def remove_group_roles(request, group, domain=None, project=None): """Removes all roles from a group on a domain or project.""" client = keystoneclient(request, admin=True) roles = client.roles.list(group=group, domain=domain, project=project) for role in roles: remove_group_role(request, role=r...
[ "def", "remove_group_roles", "(", "request", ",", "group", ",", "domain", "=", "None", ",", "project", "=", "None", ")", ":", "client", "=", "keystoneclient", "(", "request", ",", "admin", "=", "True", ")", "roles", "=", "client", ".", "roles", ".", "l...
[ 768, 0 ]
[ 774, 57 ]
python
en
['en', 'en', 'en']
True
get_default_role
(request)
Gets the default role object from Keystone and saves it as a global. Since this is configured in settings and should not change from request to request. Supports lookup by name or id.
Gets the default role object from Keystone and saves it as a global.
def get_default_role(request): """Gets the default role object from Keystone and saves it as a global. Since this is configured in settings and should not change from request to request. Supports lookup by name or id. """ global DEFAULT_ROLE default = settings.OPENSTACK_KEYSTONE_DEFAULT_ROLE ...
[ "def", "get_default_role", "(", "request", ")", ":", "global", "DEFAULT_ROLE", "default", "=", "settings", ".", "OPENSTACK_KEYSTONE_DEFAULT_ROLE", "if", "default", "and", "DEFAULT_ROLE", "is", "None", ":", "try", ":", "roles", "=", "keystoneclient", "(", "request"...
[ 777, 0 ]
[ 795, 23 ]
python
en
['en', 'en', 'en']
True
openstack
(request)
Context processor necessary for OpenStack Dashboard functionality. The following variables are added to the request context: ``authorized_tenants`` A list of tenant objects which the current user has access to. ``regions`` A dictionary containing information about region support, the cur...
Context processor necessary for OpenStack Dashboard functionality.
def openstack(request): """Context processor necessary for OpenStack Dashboard functionality. The following variables are added to the request context: ``authorized_tenants`` A list of tenant objects which the current user has access to. ``regions`` A dictionary containing informatio...
[ "def", "openstack", "(", "request", ")", ":", "context", "=", "{", "}", "# Auth/Keystone context", "context", ".", "setdefault", "(", "'authorized_tenants'", ",", "[", "]", ")", "if", "request", ".", "user", ".", "is_authenticated", ":", "context", "[", "'au...
[ 29, 0 ]
[ 102, 18 ]
python
en
['en', 'en', 'en']
True
TabGroup.load_tab_data
(self)
Preload all data that for the tabs that will be displayed.
Preload all data that for the tabs that will be displayed.
def load_tab_data(self): """Preload all data that for the tabs that will be displayed.""" for tab in self._tabs.values(): if tab.load and not tab.data_loaded: try: tab._data = tab.get_context_data(self.request) except Exception: ...
[ "def", "load_tab_data", "(", "self", ")", ":", "for", "tab", "in", "self", ".", "_tabs", ".", "values", "(", ")", ":", "if", "tab", ".", "load", "and", "not", "tab", ".", "data_loaded", ":", "try", ":", "tab", ".", "_data", "=", "tab", ".", "get_...
[ 169, 4 ]
[ 177, 51 ]
python
en
['en', 'en', 'en']
True
TabGroup.get_id
(self)
Returns the id for this tab group. Defaults to the value of the tab group's :attr:`horizon.tabs.Tab.slug`.
Returns the id for this tab group.
def get_id(self): """Returns the id for this tab group. Defaults to the value of the tab group's :attr:`horizon.tabs.Tab.slug`. """ return self.slug
[ "def", "get_id", "(", "self", ")", ":", "return", "self", ".", "slug" ]
[ 179, 4 ]
[ 185, 24 ]
python
en
['en', 'en', 'en']
True
TabGroup.get_default_classes
(self)
Returns a list of the default classes for the tab group. Defaults to ``["nav", "nav-tabs", "ajax-tabs"]``.
Returns a list of the default classes for the tab group.
def get_default_classes(self): """Returns a list of the default classes for the tab group. Defaults to ``["nav", "nav-tabs", "ajax-tabs"]``. """ default_classes = super(TabGroup, self).get_default_classes() default_classes.extend(CSS_TAB_GROUP_CLASSES) return default_cla...
[ "def", "get_default_classes", "(", "self", ")", ":", "default_classes", "=", "super", "(", "TabGroup", ",", "self", ")", ".", "get_default_classes", "(", ")", "default_classes", ".", "extend", "(", "CSS_TAB_GROUP_CLASSES", ")", "return", "default_classes" ]
[ 187, 4 ]
[ 194, 30 ]
python
en
['en', 'en', 'en']
True
TabGroup.tabs_not_available
(self)
The fallback handler if no tabs are either allowed or enabled. In the event that no tabs are either allowed or enabled, this method is the fallback handler. By default it's a no-op, but it exists to make redirecting or raising exceptions possible for subclasses.
The fallback handler if no tabs are either allowed or enabled.
def tabs_not_available(self): """The fallback handler if no tabs are either allowed or enabled. In the event that no tabs are either allowed or enabled, this method is the fallback handler. By default it's a no-op, but it exists to make redirecting or raising exceptions possible for sub...
[ "def", "tabs_not_available", "(", "self", ")", ":" ]
[ 196, 4 ]
[ 202, 11 ]
python
en
['en', 'en', 'en']
True
TabGroup.render
(self)
Renders the HTML output for this tab group.
Renders the HTML output for this tab group.
def render(self): """Renders the HTML output for this tab group.""" return render_to_string(self.template_name, {"tab_group": self})
[ "def", "render", "(", "self", ")", ":", "return", "render_to_string", "(", "self", ".", "template_name", ",", "{", "\"tab_group\"", ":", "self", "}", ")" ]
[ 227, 4 ]
[ 229, 72 ]
python
en
['en', 'en', 'en']
True
TabGroup.get_tabs
(self)
Returns a list of the allowed tabs for this tab group.
Returns a list of the allowed tabs for this tab group.
def get_tabs(self): """Returns a list of the allowed tabs for this tab group.""" return [tab for tab in self._tabs.values() if tab._allowed]
[ "def", "get_tabs", "(", "self", ")", ":", "return", "[", "tab", "for", "tab", "in", "self", ".", "_tabs", ".", "values", "(", ")", "if", "tab", ".", "_allowed", "]" ]
[ 231, 4 ]
[ 233, 67 ]
python
en
['en', 'en', 'en']
True
TabGroup.get_tab
(self, tab_name, allow_disabled=False)
Returns a specific tab from this tab group. If the tab is not allowed or not enabled this method returns ``None``. If the tab is disabled but you wish to return it anyway, you can pass ``True`` to the allow_disabled argument.
Returns a specific tab from this tab group.
def get_tab(self, tab_name, allow_disabled=False): """Returns a specific tab from this tab group. If the tab is not allowed or not enabled this method returns ``None``. If the tab is disabled but you wish to return it anyway, you can pass ``True`` to the allow_disabled argument. ...
[ "def", "get_tab", "(", "self", ",", "tab_name", ",", "allow_disabled", "=", "False", ")", ":", "tab", "=", "self", ".", "_tabs", ".", "get", "(", "tab_name", ",", "None", ")", "if", "tab", "and", "tab", ".", "_allowed", "and", "(", "tab", ".", "_en...
[ 235, 4 ]
[ 246, 19 ]
python
en
['en', 'en', 'en']
True
TabGroup.get_selected_tab
(self)
Returns the tab specific by the GET request parameter. In the event that there is no GET request parameter, the value of the query parameter is invalid, or the tab is not allowed/enabled, the return value of this function is None.
Returns the tab specific by the GET request parameter.
def get_selected_tab(self): """Returns the tab specific by the GET request parameter. In the event that there is no GET request parameter, the value of the query parameter is invalid, or the tab is not allowed/enabled, the return value of this function is None. """ selec...
[ "def", "get_selected_tab", "(", "self", ")", ":", "selected", "=", "self", ".", "request", ".", "GET", ".", "get", "(", "self", ".", "param_name", ",", "None", ")", "if", "selected", ":", "try", ":", "tab_group", ",", "tab_name", "=", "selected", ".", ...
[ 251, 4 ]
[ 266, 29 ]
python
en
['en', 'en', 'en']
True
Tab.is_active
(self)
Method to access whether or not this tab is the active tab.
Method to access whether or not this tab is the active tab.
def is_active(self): """Method to access whether or not this tab is the active tab.""" if self._active is None: self.tab_group._set_active_tab() return self._active
[ "def", "is_active", "(", "self", ")", ":", "if", "self", ".", "_active", "is", "None", ":", "self", ".", "tab_group", ".", "_set_active_tab", "(", ")", "return", "self", ".", "_active" ]
[ 334, 4 ]
[ 338, 27 ]
python
en
['en', 'en', 'en']
True
Tab.render
(self)
Renders the tab to HTML. :meth:`~horizon.tabs.Tab.get_context_data` method and the :meth:`~horizon.tabs.Tab.get_template_name` method are called. If :attr:`~horizon.tabs.Tab.preload` is ``False`` and ``force_load`` is not ``True``, or either :meth:`~horizon.tabs.Tab.allowed` or...
Renders the tab to HTML.
def render(self): """Renders the tab to HTML. :meth:`~horizon.tabs.Tab.get_context_data` method and the :meth:`~horizon.tabs.Tab.get_template_name` method are called. If :attr:`~horizon.tabs.Tab.preload` is ``False`` and ``force_load`` is not ``True``, or either :meth:`...
[ "def", "render", "(", "self", ")", ":", "if", "not", "self", ".", "load", ":", "return", "''", "try", ":", "context", "=", "self", ".", "data", "except", "exceptions", ".", "Http302", ":", "raise", "except", "Exception", ":", "exc_type", ",", "exc_valu...
[ 355, 4 ]
[ 376, 78 ]
python
en
['en', 'en', 'en']
True
Tab.get_id
(self)
Returns the id for this tab. Defaults to ``"{{ tab_group.slug }}__{{ tab.slug }}"``.
Returns the id for this tab.
def get_id(self): """Returns the id for this tab. Defaults to ``"{{ tab_group.slug }}__{{ tab.slug }}"``. """ return SEPARATOR.join([self.tab_group.slug, self.slug])
[ "def", "get_id", "(", "self", ")", ":", "return", "SEPARATOR", ".", "join", "(", "[", "self", ".", "tab_group", ".", "slug", ",", "self", ".", "slug", "]", ")" ]
[ 378, 4 ]
[ 383, 63 ]
python
en
['en', 'en', 'en']
True
Tab.get_default_classes
(self)
Returns a list of the default classes for the tab. Defaults to and empty list (``[]``), however additional classes may be added depending on the state of the tab as follows: If the tab is the active tab for the tab group, in which the class ``"active"`` will be added. If the t...
Returns a list of the default classes for the tab.
def get_default_classes(self): """Returns a list of the default classes for the tab. Defaults to and empty list (``[]``), however additional classes may be added depending on the state of the tab as follows: If the tab is the active tab for the tab group, in which the class ``"...
[ "def", "get_default_classes", "(", "self", ")", ":", "default_classes", "=", "super", "(", "Tab", ",", "self", ")", ".", "get_default_classes", "(", ")", "if", "self", ".", "is_active", "(", ")", ":", "default_classes", ".", "extend", "(", "CSS_ACTIVE_TAB_CL...
[ 388, 4 ]
[ 405, 30 ]
python
en
['en', 'en', 'en']
True
Tab.get_template_name
(self, request)
Returns the name of the template to be used for rendering this tab. By default it returns the value of the ``template_name`` attribute on the ``Tab`` class.
Returns the name of the template to be used for rendering this tab.
def get_template_name(self, request): """Returns the name of the template to be used for rendering this tab. By default it returns the value of the ``template_name`` attribute on the ``Tab`` class. """ if not hasattr(self, "template_name"): raise AttributeError("%s m...
[ "def", "get_template_name", "(", "self", ",", "request", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"template_name\"", ")", ":", "raise", "AttributeError", "(", "\"%s must have a template_name attribute or \"", "\"override the get_template_name method.\"", "%",...
[ 407, 4 ]
[ 417, 33 ]
python
en
['en', 'en', 'en']
True
Tab.get_context_data
(self, request, **kwargs)
Return a dictionary of context data used to render the tab. Required.
Return a dictionary of context data used to render the tab.
def get_context_data(self, request, **kwargs): """Return a dictionary of context data used to render the tab. Required. """ return kwargs
[ "def", "get_context_data", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "return", "kwargs" ]
[ 419, 4 ]
[ 424, 21 ]
python
en
['en', 'en', 'en']
True
Tab.enabled
(self, request)
Determines whether or not the tab should be accessible. For example, the tab should be rendered into the HTML on load and respond to a click event. If a tab returns ``False`` from ``enabled`` it will ignore the value of ``preload`` and only render the HTML of the tab after being clicke...
Determines whether or not the tab should be accessible.
def enabled(self, request): """Determines whether or not the tab should be accessible. For example, the tab should be rendered into the HTML on load and respond to a click event. If a tab returns ``False`` from ``enabled`` it will ignore the value of ``preload`` and only render...
[ "def", "enabled", "(", "self", ",", "request", ")", ":", "return", "True" ]
[ 426, 4 ]
[ 437, 19 ]
python
en
['en', 'en', 'en']
True
Tab.allowed
(self, request)
Determines whether or not the tab is displayed. Tab instances can override this method to specify conditions under which this tab should not be shown at all by returning ``False``. The default behavior is to return ``True`` for all cases.
Determines whether or not the tab is displayed.
def allowed(self, request): """Determines whether or not the tab is displayed. Tab instances can override this method to specify conditions under which this tab should not be shown at all by returning ``False``. The default behavior is to return ``True`` for all cases. """ ...
[ "def", "allowed", "(", "self", ",", "request", ")", ":", "return", "True" ]
[ 439, 4 ]
[ 447, 19 ]
python
en
['en', 'en', 'en']
True
Tab.post
(self, request, *args, **kwargs)
Handles POST data sent to a tab. Tab instances can override this method to have tab-specific POST logic without polluting the TabView code. The default behavior is to ignore POST data.
Handles POST data sent to a tab.
def post(self, request, *args, **kwargs): """Handles POST data sent to a tab. Tab instances can override this method to have tab-specific POST logic without polluting the TabView code. The default behavior is to ignore POST data. """
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":" ]
[ 449, 4 ]
[ 456, 11 ]
python
en
['en', 'en', 'en']
True
TableTab.load_table_data
(self)
Calls the ``get_{{ table_name }}_data`` methods for each table class. When returning, the loaded data is set on the tables.
Calls the ``get_{{ table_name }}_data`` methods for each table class.
def load_table_data(self): """Calls the ``get_{{ table_name }}_data`` methods for each table class. When returning, the loaded data is set on the tables. """ # We only want the data to be loaded once, so we track if we have... if not self._table_data_loaded: for tabl...
[ "def", "load_table_data", "(", "self", ")", ":", "# We only want the data to be loaded once, so we track if we have...", "if", "not", "self", ".", "_table_data_loaded", ":", "for", "table_name", ",", "table", "in", "self", ".", "_tables", ".", "items", "(", ")", ":"...
[ 495, 4 ]
[ 518, 42 ]
python
en
['en', 'en', 'en']
True
TableTab.get_context_data
(self, request, **kwargs)
Adds a ``{{ table_name }}_table`` item to the context for each table. The target tables are specified by the :attr:`~horizon.tabs.TableTab.table_classes` attribute. If only one table class is provided, a shortcut ``table`` context variable is also added containing the single table. ...
Adds a ``{{ table_name }}_table`` item to the context for each table.
def get_context_data(self, request, **kwargs): """Adds a ``{{ table_name }}_table`` item to the context for each table. The target tables are specified by the :attr:`~horizon.tabs.TableTab.table_classes` attribute. If only one table class is provided, a shortcut ``table`` context ...
[ "def", "get_context_data", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "TableTab", ",", "self", ")", ".", "get_context_data", "(", "request", ",", "*", "*", "kwargs", ")", "# If the data hasn't been manually ...
[ 520, 4 ]
[ 538, 22 ]
python
en
['en', 'en', 'en']
True
areRowsEqual
(rows, expected)
expected is a list [({name:'lion',...}, {var_name:True,...})]
expected is a list [({name:'lion',...}, {var_name:True,...})]
def areRowsEqual(rows, expected): """expected is a list [({name:'lion',...}, {var_name:True,...})] """ rows = list(rows) if len(rows) != len(expected): print 'got len %d, expected %d' % (len(rows), len(expected)) return False for attrs_dict, vars_dict in expected: for r i...
[ "def", "areRowsEqual", "(", "rows", ",", "expected", ")", ":", "rows", "=", "list", "(", "rows", ")", "if", "len", "(", "rows", ")", "!=", "len", "(", "expected", ")", ":", "print", "'got len %d, expected %d'", "%", "(", "len", "(", "rows", ")", ",",...
[ 18, 0 ]
[ 36, 15 ]
python
en
['en', 'en', 'en']
True
TestJeevesModel.testQueryDelete
(self)
Test that delete removes all rows.
Test that delete removes all rows.
def testQueryDelete(self): """Test that delete removes all rows. """ Animal.objects.create(name='delete_test1', sound=JeevesLib.mkSensitive(self.x, JeevesLib.mkSensitive(self.y, 'b', 'c'), JeevesLib.mkSensitive(self.y, 'd', 'e'))) Animal.object...
[ "def", "testQueryDelete", "(", "self", ")", ":", "Animal", ".", "objects", ".", "create", "(", "name", "=", "'delete_test1'", ",", "sound", "=", "JeevesLib", ".", "mkSensitive", "(", "self", ".", "x", ",", "JeevesLib", ".", "mkSensitive", "(", "self", "....
[ 87, 4 ]
[ 161, 11 ]
python
en
['en', 'en', 'en']
True
TestJeevesModel.testSave
(self)
Test that saving does the correct bookkeeping.
Test that saving does the correct bookkeeping.
def testSave(self): """Test that saving does the correct bookkeeping. """ an = Animal.objects.create(name='save_test1', sound='b') an.sound = 'c' with JeevesLib.PositiveVariable(self.x): an.save() a = list(Animal._objects_ordinary.filter(name='save_test1').all...
[ "def", "testSave", "(", "self", ")", ":", "an", "=", "Animal", ".", "objects", ".", "create", "(", "name", "=", "'save_test1'", ",", "sound", "=", "'b'", ")", "an", ".", "sound", "=", "'c'", "with", "JeevesLib", ".", "PositiveVariable", "(", "self", ...
[ 163, 4 ]
[ 275, 11 ]
python
en
['en', 'en', 'en']
True
TestJeevesModel.testObjectModel
(self)
dataset={"sound":animal.sound} self.assertIn(dataset['sound'],["meow",""]) self.assertTrue(False) # TODO: This should fail! self.assertEquals(dogWithPolicy,dog) allAnimals=AnimalWithPolicy.objects.filter self.assertIn(dataset.sound,["meow",""])
dataset={"sound":animal.sound} self.assertIn(dataset['sound'],["meow",""]) self.assertTrue(False) # TODO: This should fail! self.assertEquals(dogWithPolicy,dog) allAnimals=AnimalWithPolicy.objects.filter self.assertIn(dataset.sound,["meow",""])
def testObjectModel(self): dogWithPolicy = AnimalWithPolicy() dogWithPolicy.name="dog" dogWithPolicy.sound="bark" AnimalWithPolicy.objects.create(name="dog",sound="bark") AnimalWithPolicy.objects.create(name="cat",sound="meow") AnimalWithPolicy.objects.create(name="gorill...
[ "def", "testObjectModel", "(", "self", ")", ":", "dogWithPolicy", "=", "AnimalWithPolicy", "(", ")", "dogWithPolicy", ".", "name", "=", "\"dog\"", "dogWithPolicy", ".", "sound", "=", "\"bark\"", "AnimalWithPolicy", ".", "objects", ".", "create", "(", "name", "...
[ 510, 4 ]
[ 526, 11 ]
python
en
['en', 'error', 'th']
False
create_command
(name, **kwargs)
Create an instance of the Command class with the given name.
Create an instance of the Command class with the given name.
def create_command(name, **kwargs): # type: (str, **Any) -> Command """ Create an instance of the Command class with the given name. """ module_path, class_name, summary = commands_dict[name] module = importlib.import_module(module_path) command_class = getattr(module, class_name) comman...
[ "def", "create_command", "(", "name", ",", "*", "*", "kwargs", ")", ":", "# type: (str, **Any) -> Command", "module_path", ",", "class_name", ",", "summary", "=", "commands_dict", "[", "name", "]", "module", "=", "importlib", ".", "import_module", "(", "module_p...
[ 97, 0 ]
[ 107, 18 ]
python
en
['en', 'error', 'th']
False
get_similar_commands
(name)
Command name auto-correct.
Command name auto-correct.
def get_similar_commands(name): """Command name auto-correct.""" from difflib import get_close_matches name = name.lower() close_commands = get_close_matches(name, commands_dict.keys()) if close_commands: return close_commands[0] else: return False
[ "def", "get_similar_commands", "(", "name", ")", ":", "from", "difflib", "import", "get_close_matches", "name", "=", "name", ".", "lower", "(", ")", "close_commands", "=", "get_close_matches", "(", "name", ",", "commands_dict", ".", "keys", "(", ")", ")", "i...
[ 110, 0 ]
[ 121, 20 ]
python
en
['en', 'sm', 'en']
True
assertProtoEqual
(self, a, b, check_initialized=True, # pylint: disable=invalid-name normalize_numbers=False, msg=None)
Fails with a useful error if a and b aren't equal. Comparison of repeated fields matches the semantics of unittest.TestCase.assertEqual(), ie order and extra duplicates fields matter. Args: self: googletest.TestCase a: proto2 PB instance, or text string representing one. b: proto2 PB instance -- mes...
Fails with a useful error if a and b aren't equal.
def assertProtoEqual(self, a, b, check_initialized=True, # pylint: disable=invalid-name normalize_numbers=False, msg=None): """Fails with a useful error if a and b aren't equal. Comparison of repeated fields matches the semantics of unittest.TestCase.assertEqual(), ie order and extra duplic...
[ "def", "assertProtoEqual", "(", "self", ",", "a", ",", "b", ",", "check_initialized", "=", "True", ",", "# pylint: disable=invalid-name", "normalize_numbers", "=", "False", ",", "msg", "=", "None", ")", ":", "pool", "=", "descriptor_pool", ".", "Default", "(",...
[ 69, 0 ]
[ 110, 38 ]
python
en
['en', 'en', 'en']
True
NormalizeNumberFields
(pb)
Normalizes types and precisions of number fields in a protocol buffer. Due to subtleties in the python protocol buffer implementation, it is possible for values to have different types and precision depending on whether they were set and retrieved directly or deserialized from a protobuf. This function normali...
Normalizes types and precisions of number fields in a protocol buffer.
def NormalizeNumberFields(pb): """Normalizes types and precisions of number fields in a protocol buffer. Due to subtleties in the python protocol buffer implementation, it is possible for values to have different types and precision depending on whether they were set and retrieved directly or deserialized from...
[ "def", "NormalizeNumberFields", "(", "pb", ")", ":", "for", "desc", ",", "values", "in", "pb", ".", "ListFields", "(", ")", ":", "is_repeated", "=", "True", "if", "desc", ".", "label", "is", "not", "descriptor", ".", "FieldDescriptor", ".", "LABEL_REPEATED...
[ 113, 0 ]
[ 178, 11 ]
python
en
['en', 'en', 'en']
True
ProtoEq
(a, b)
Compares two proto2 objects for equality. Recurses into nested messages. Uses list (not set) semantics for comparing repeated fields, ie duplicates and order matter. Args: a: A proto2 message or a primitive. b: A proto2 message or a primitive. Returns: `True` if the messages are equal.
Compares two proto2 objects for equality.
def ProtoEq(a, b): """Compares two proto2 objects for equality. Recurses into nested messages. Uses list (not set) semantics for comparing repeated fields, ie duplicates and order matter. Args: a: A proto2 message or a primitive. b: A proto2 message or a primitive. Returns: `True` if the messag...
[ "def", "ProtoEq", "(", "a", ",", "b", ")", ":", "def", "Format", "(", "pb", ")", ":", "\"\"\"Returns a dictionary or unchanged pb bases on its type.\n\n Specifically, this function returns a dictionary that maps tag\n number (for messages) or element index (for repeated fields) to\...
[ 195, 0 ]
[ 247, 13 ]
python
en
['en', 'en', 'en']
True
abs__file__
()
Set all module' __file__ attribute to an absolute path
Set all module' __file__ attribute to an absolute path
def abs__file__(): """Set all module' __file__ attribute to an absolute path""" for m in sys.modules.values(): f = getattr(m, "__file__", None) if f is None: continue m.__file__ = os.path.abspath(f)
[ "def", "abs__file__", "(", ")", ":", "for", "m", "in", "sys", ".", "modules", ".", "values", "(", ")", ":", "f", "=", "getattr", "(", "m", ",", "\"__file__\"", ",", "None", ")", "if", "f", "is", "None", ":", "continue", "m", ".", "__file__", "=",...
[ 96, 0 ]
[ 102, 39 ]
python
en
['en', 'en', 'en']
True
removeduppaths
()
Remove duplicate entries from sys.path along with making them absolute
Remove duplicate entries from sys.path along with making them absolute
def removeduppaths(): """ Remove duplicate entries from sys.path along with making them absolute""" # This ensures that the initial path provided by the interpreter contains # only absolute pathnames, even if we're running from the build directory. L = [] known_paths = set() for dir in sys.p...
[ "def", "removeduppaths", "(", ")", ":", "# This ensures that the initial path provided by the interpreter contains", "# only absolute pathnames, even if we're running from the build directory.", "L", "=", "[", "]", "known_paths", "=", "set", "(", ")", "for", "dir", "in", "sys",...
[ 105, 0 ]
[ 121, 22 ]
python
en
['en', 'en', 'en']
True
addbuilddir
()
Append ./build/lib.<platform> in case we're running in the build dir (especially for Guido :-)
Append ./build/lib.<platform> in case we're running in the build dir (especially for Guido :-)
def addbuilddir(): """Append ./build/lib.<platform> in case we're running in the build dir (especially for Guido :-)""" from distutils.util import get_platform s = "build/lib.{}-{:.3}".format(get_platform(), sys.version) if hasattr(sys, "gettotalrefcount"): s += "-pydebug" s = os.path.j...
[ "def", "addbuilddir", "(", ")", ":", "from", "distutils", ".", "util", "import", "get_platform", "s", "=", "\"build/lib.{}-{:.3}\"", ".", "format", "(", "get_platform", "(", ")", ",", "sys", ".", "version", ")", "if", "hasattr", "(", "sys", ",", "\"gettota...
[ 126, 0 ]
[ 135, 22 ]
python
en
['en', 'en', 'en']
True