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
wagtail_site
(context)
Returns the Site object for the given request
Returns the Site object for the given request
def wagtail_site(context): """ Returns the Site object for the given request """ try: request = context['request'] except KeyError: return None return Site.find_for_request(request=request)
[ "def", "wagtail_site", "(", "context", ")", ":", "try", ":", "request", "=", "context", "[", "'request'", "]", "except", "KeyError", ":", "return", "None", "return", "Site", ".", "find_for_request", "(", "request", "=", "request", ")" ]
[ 177, 0 ]
[ 186, 49 ]
python
en
['en', 'error', 'th']
False
find_root_newton_method
(fun, grad, x0, eps=1e-6, learning_rate=2e-3, max_iter=1e5)
Newton's root finding method in conjunction with the adam optimizer Args: fun (callable): function f for which f(x) = 0 shall be solved grad (callable): gradient of f x0 (np.ndarray): initial value eps (float): tolerance learning_rate (float): learning rate of the optim...
Newton's root finding method in conjunction with the adam optimizer
def find_root_newton_method(fun, grad, x0, eps=1e-6, learning_rate=2e-3, max_iter=1e5): """ Newton's root finding method in conjunction with the adam optimizer Args: fun (callable): function f for which f(x) = 0 shall be solved grad (callable): gradient of f x0 (np.ndarray): initial...
[ "def", "find_root_newton_method", "(", "fun", ",", "grad", ",", "x0", ",", "eps", "=", "1e-6", ",", "learning_rate", "=", "2e-3", ",", "max_iter", "=", "1e5", ")", ":", "assert", "callable", "(", "fun", ")", "assert", "callable", "(", "grad", ")", "opt...
[ 77, 0 ]
[ 116, 12 ]
python
en
['en', 'error', 'th']
False
find_root_by_bounding
(fun, left, right, eps=1e-8, max_iter=1e4)
Root finding method that uses selective shrinking of a target interval bounded by left and right --> other than the newton method, this method only works for for vectorized univariate functions Args: fun (callable): function f for which f(x) = 0 shall be solved left: (np.ndarray): initial l...
Root finding method that uses selective shrinking of a target interval bounded by left and right --> other than the newton method, this method only works for for vectorized univariate functions Args: fun (callable): function f for which f(x) = 0 shall be solved left: (np.ndarray): initial l...
def find_root_by_bounding(fun, left, right, eps=1e-8, max_iter=1e4): """ Root finding method that uses selective shrinking of a target interval bounded by left and right --> other than the newton method, this method only works for for vectorized univariate functions Args: fun (callable): functio...
[ "def", "find_root_by_bounding", "(", "fun", ",", "left", ",", "right", ",", "eps", "=", "1e-8", ",", "max_iter", "=", "1e4", ")", ":", "assert", "callable", "(", "fun", ")", "n_iter", "=", "0", "approx_error", "=", "1e10", "while", "approx_error", ">", ...
[ 119, 0 ]
[ 152, 17 ]
python
en
['en', 'error', 'th']
False
AdamOptimizer.get_update
(self, params, grads)
params and grads are list of numpy arrays
params and grads are list of numpy arrays
def get_update(self, params, grads): """ params and grads are list of numpy arrays """ original_shapes = [x.shape for x in params] params = [x.flatten() for x in params] grads = [x.flatten() for x in grads] """ #TODO: implement clipping if hasattr(self, 'clipnorm...
[ "def", "get_update", "(", "self", ",", "params", ",", "grads", ")", ":", "original_shapes", "=", "[", "x", ".", "shape", "for", "x", "in", "params", "]", "params", "=", "[", "x", ".", "flatten", "(", ")", "for", "x", "in", "params", "]", "grads", ...
[ 33, 4 ]
[ 75, 18 ]
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
split_first
(s, delims)
.. deprecated:: 1.25 Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz', '?/=') ('foo', 'bar?baz',...
.. deprecated:: 1.25
def split_first(s, delims): """ .. deprecated:: 1.25 Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz'...
[ "def", "split_first", "(", "s", ",", "delims", ")", ":", "min_idx", "=", "None", "min_delim", "=", "None", "for", "d", "in", "delims", ":", "idx", "=", "s", ".", "find", "(", "d", ")", "if", "idx", "<", "0", ":", "continue", "if", "min_idx", "is"...
[ 174, 0 ]
[ 206, 51 ]
python
en
['en', 'error', 'th']
False
_encode_invalid_chars
(component, allowed_chars, encoding="utf-8")
Percent-encodes a URI component without reapplying onto an already percent-encoded component.
Percent-encodes a URI component without reapplying onto an already percent-encoded component.
def _encode_invalid_chars(component, allowed_chars, encoding="utf-8"): """Percent-encodes a URI component without reapplying onto an already percent-encoded component. """ if component is None: return component component = six.ensure_text(component) # Normalize existing percent-encoded...
[ "def", "_encode_invalid_chars", "(", "component", ",", "allowed_chars", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "component", "is", "None", ":", "return", "component", "component", "=", "six", ".", "ensure_text", "(", "component", ")", "# Normalize exi...
[ 209, 0 ]
[ 240, 45 ]
python
en
['en', 'en', 'en']
True
_encode_target
(target)
Percent-encodes a request target so that there are no invalid characters
Percent-encodes a request target so that there are no invalid characters
def _encode_target(target): """Percent-encodes a request target so that there are no invalid characters""" path, query = TARGET_RE.match(target).groups() target = _encode_invalid_chars(path, PATH_CHARS) query = _encode_invalid_chars(query, QUERY_CHARS) if query is not None: target += "?" + q...
[ "def", "_encode_target", "(", "target", ")", ":", "path", ",", "query", "=", "TARGET_RE", ".", "match", "(", "target", ")", ".", "groups", "(", ")", "target", "=", "_encode_invalid_chars", "(", "path", ",", "PATH_CHARS", ")", "query", "=", "_encode_invalid...
[ 319, 0 ]
[ 326, 17 ]
python
en
['en', 'en', 'en']
True
parse_url
(url)
Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant. The parser logic and helper functions are based heavily on work done in the ``rfc3986`` module. :param str url: URL to...
Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant.
def parse_url(url): """ Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant. The parser logic and helper functions are based heavily on work done in the ``rfc3986`` module. ...
[ "def", "parse_url", "(", "url", ")", ":", "if", "not", "url", ":", "# Empty", "return", "Url", "(", ")", "source_url", "=", "url", "if", "not", "SCHEME_RE", ".", "search", "(", "url", ")", ":", "url", "=", "\"//\"", "+", "url", "try", ":", "scheme"...
[ 329, 0 ]
[ 421, 5 ]
python
en
['en', 'error', 'th']
False
get_host
(url)
Deprecated. Use :func:`parse_url` instead.
Deprecated. Use :func:`parse_url` instead.
def get_host(url): """ Deprecated. Use :func:`parse_url` instead. """ p = parse_url(url) return p.scheme or "http", p.hostname, p.port
[ "def", "get_host", "(", "url", ")", ":", "p", "=", "parse_url", "(", "url", ")", "return", "p", ".", "scheme", "or", "\"http\"", ",", "p", ".", "hostname", ",", "p", ".", "port" ]
[ 424, 0 ]
[ 429, 49 ]
python
en
['en', 'error', 'th']
False
Url.hostname
(self)
For backwards-compatibility with urlparse. We're nice like that.
For backwards-compatibility with urlparse. We're nice like that.
def hostname(self): """For backwards-compatibility with urlparse. We're nice like that.""" return self.host
[ "def", "hostname", "(", "self", ")", ":", "return", "self", ".", "host" ]
[ 109, 4 ]
[ 111, 24 ]
python
en
['en', 'en', 'en']
True
Url.request_uri
(self)
Absolute path including the query string.
Absolute path including the query string.
def request_uri(self): """Absolute path including the query string.""" uri = self.path or "/" if self.query is not None: uri += "?" + self.query return uri
[ "def", "request_uri", "(", "self", ")", ":", "uri", "=", "self", ".", "path", "or", "\"/\"", "if", "self", ".", "query", "is", "not", "None", ":", "uri", "+=", "\"?\"", "+", "self", ".", "query", "return", "uri" ]
[ 114, 4 ]
[ 121, 18 ]
python
en
['en', 'en', 'en']
True
Url.netloc
(self)
Network location including host and port
Network location including host and port
def netloc(self): """Network location including host and port""" if self.port: return "%s:%d" % (self.host, self.port) return self.host
[ "def", "netloc", "(", "self", ")", ":", "if", "self", ".", "port", ":", "return", "\"%s:%d\"", "%", "(", "self", ".", "host", ",", "self", ".", "port", ")", "return", "self", ".", "host" ]
[ 124, 4 ]
[ 128, 24 ]
python
en
['en', 'en', 'en']
True
Url.url
(self)
Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port will have : removed). ...
Convert self into a url
def url(self): """ Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port w...
[ "def", "url", "(", "self", ")", ":", "scheme", ",", "auth", ",", "host", ",", "port", ",", "path", ",", "query", ",", "fragment", "=", "self", "url", "=", "u\"\"", "# We use \"is not None\" we want things to happen with empty strings (or 0 port)", "if", "scheme", ...
[ 131, 4 ]
[ 168, 18 ]
python
en
['en', 'error', 'th']
False
NotifiesTests.autocommit
(self, conn)
Set a connection in autocommit mode.
Set a connection in autocommit mode.
def autocommit(self, conn): """Set a connection in autocommit mode.""" conn.set_isolation_level(extensions.ISOLATION_LEVEL_AUTOCOMMIT)
[ "def", "autocommit", "(", "self", ",", "conn", ")", ":", "conn", ".", "set_isolation_level", "(", "extensions", ".", "ISOLATION_LEVEL_AUTOCOMMIT", ")" ]
[ 39, 4 ]
[ 41, 71 ]
python
en
['en', 'en', 'en']
True
NotifiesTests.listen
(self, name)
Start listening for a name on self.conn.
Start listening for a name on self.conn.
def listen(self, name): """Start listening for a name on self.conn.""" curs = self.conn.cursor() curs.execute("LISTEN " + name) curs.close()
[ "def", "listen", "(", "self", ",", "name", ")", ":", "curs", "=", "self", ".", "conn", ".", "cursor", "(", ")", "curs", ".", "execute", "(", "\"LISTEN \"", "+", "name", ")", "curs", ".", "close", "(", ")" ]
[ 43, 4 ]
[ 47, 20 ]
python
en
['en', 'en', 'en']
True
NotifiesTests.notify
(self, name, sec=0, payload=None)
Send a notification to the database, eventually after some time.
Send a notification to the database, eventually after some time.
def notify(self, name, sec=0, payload=None): """Send a notification to the database, eventually after some time.""" if payload is None: payload = '' else: payload = ", %r" % payload script = ("""\ import time time.sleep(%(sec)s) import %(module)s as psycopg2 impo...
[ "def", "notify", "(", "self", ",", "name", ",", "sec", "=", "0", ",", "payload", "=", "None", ")", ":", "if", "payload", "is", "None", ":", "payload", "=", "''", "else", ":", "payload", "=", "\", %r\"", "%", "payload", "script", "=", "(", "\"\"\"\\...
[ 49, 4 ]
[ 72, 80 ]
python
en
['en', 'en', 'en']
True
deserialize_structured_args
(args)
Deserialize structured arguments passed from the starlark rules. Args: args: dict of parsed command line arguments
Deserialize structured arguments passed from the starlark rules. Args: args: dict of parsed command line arguments
def deserialize_structured_args(args): """Deserialize structured arguments passed from the starlark rules. Args: args: dict of parsed command line arguments """ structured_args = ("extra_pip_args", "pip_data_exclude") for arg_name in structured_args: if args.get(arg_name) is ...
[ "def", "deserialize_structured_args", "(", "args", ")", ":", "structured_args", "=", "(", "\"extra_pip_args\"", ",", "\"pip_data_exclude\"", ")", "for", "arg_name", "in", "structured_args", ":", "if", "args", ".", "get", "(", "arg_name", ")", "is", "not", "None"...
[ 47, 0 ]
[ 58, 15 ]
python
en
['en', 'en', 'en']
True
generate_parsed_requirements_contents
(all_args: argparse.Namespace)
Parse each requirement from the requirements_lock file, and prepare arguments for each repository rule, which will represent the individual requirements. Generates a requirements.bzl file containing a macro (install_deps()) which instantiates a repository rule for each requirment in the lock file. ...
Parse each requirement from the requirements_lock file, and prepare arguments for each repository rule, which will represent the individual requirements.
def generate_parsed_requirements_contents(all_args: argparse.Namespace) -> str: """ Parse each requirement from the requirements_lock file, and prepare arguments for each repository rule, which will represent the individual requirements. Generates a requirements.bzl file containing a macro (install_dep...
[ "def", "generate_parsed_requirements_contents", "(", "all_args", ":", "argparse", ".", "Namespace", ")", "->", "str", ":", "args", "=", "dict", "(", "vars", "(", "all_args", ")", ")", "args", "=", "deserialize_structured_args", "(", "args", ")", "args", ".", ...
[ 61, 0 ]
[ 118, 9 ]
python
en
['en', 'error', 'th']
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
is_url
(name)
Return true if the name looks like a URL.
Return true if the name looks like a URL.
def is_url(name): # type: (Union[str, Text]) -> bool """ Return true if the name looks like a URL. """ scheme = get_url_scheme(name) if scheme is None: return False return scheme in ['http', 'https', 'file', 'ftp'] + vcs.all_schemes
[ "def", "is_url", "(", "name", ")", ":", "# type: (Union[str, Text]) -> bool", "scheme", "=", "get_url_scheme", "(", "name", ")", "if", "scheme", "is", "None", ":", "return", "False", "return", "scheme", "in", "[", "'http'", ",", "'https'", ",", "'file'", ","...
[ 61, 0 ]
[ 69, 71 ]
python
en
['en', 'error', 'th']
False
make_vcs_requirement_url
(repo_url, rev, project_name, subdir=None)
Return the URL for a VCS requirement. Args: repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+"). project_name: the (unescaped) project name.
Return the URL for a VCS requirement.
def make_vcs_requirement_url(repo_url, rev, project_name, subdir=None): # type: (str, str, str, Optional[str]) -> str """ Return the URL for a VCS requirement. Args: repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+"). project_name: the (unescaped) project name. """ ...
[ "def", "make_vcs_requirement_url", "(", "repo_url", ",", "rev", ",", "project_name", ",", "subdir", "=", "None", ")", ":", "# type: (str, str, str, Optional[str]) -> str", "egg_project_name", "=", "pkg_resources", ".", "to_filename", "(", "project_name", ")", "req", "...
[ 72, 0 ]
[ 86, 14 ]
python
en
['en', 'error', 'th']
False
call_subprocess
( cmd, # type: Union[List[str], CommandArgs] cwd=None, # type: Optional[str] extra_environ=None, # type: Optional[Mapping[str, Any]] extra_ok_returncodes=None, # type: Optional[Iterable[int]] log_failed_cmd=True # type: Optional[bool] )
Args: extra_ok_returncodes: an iterable of integer return codes that are acceptable, in addition to 0. Defaults to None, which means []. log_failed_cmd: if false, failed commands are not logged, only raised.
Args: extra_ok_returncodes: an iterable of integer return codes that are acceptable, in addition to 0. Defaults to None, which means []. log_failed_cmd: if false, failed commands are not logged, only raised.
def call_subprocess( cmd, # type: Union[List[str], CommandArgs] cwd=None, # type: Optional[str] extra_environ=None, # type: Optional[Mapping[str, Any]] extra_ok_returncodes=None, # type: Optional[Iterable[int]] log_failed_cmd=True # type: Optional[bool] ): # type: (...) -> Text """ ...
[ "def", "call_subprocess", "(", "cmd", ",", "# type: Union[List[str], CommandArgs]", "cwd", "=", "None", ",", "# type: Optional[str]", "extra_environ", "=", "None", ",", "# type: Optional[Mapping[str, Any]]", "extra_ok_returncodes", "=", "None", ",", "# type: Optional[Iterable...
[ 89, 0 ]
[ 174, 30 ]
python
en
['en', 'error', 'th']
False
find_path_to_setup_from_repo_root
(location, repo_root)
Find the path to `setup.py` by searching up the filesystem from `location`. Return the path to `setup.py` relative to `repo_root`. Return None if `setup.py` is in `repo_root` or cannot be found.
Find the path to `setup.py` by searching up the filesystem from `location`. Return the path to `setup.py` relative to `repo_root`. Return None if `setup.py` is in `repo_root` or cannot be found.
def find_path_to_setup_from_repo_root(location, repo_root): # type: (str, str) -> Optional[str] """ Find the path to `setup.py` by searching up the filesystem from `location`. Return the path to `setup.py` relative to `repo_root`. Return None if `setup.py` is in `repo_root` or cannot be found. "...
[ "def", "find_path_to_setup_from_repo_root", "(", "location", ",", "repo_root", ")", ":", "# type: (str, str) -> Optional[str]", "# find setup.py", "orig_location", "=", "location", "while", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join"...
[ 177, 0 ]
[ 202, 47 ]
python
en
['en', 'error', 'th']
False
RevOptions.__init__
( self, vc_class, # type: Type[VersionControl] rev=None, # type: Optional[str] extra_args=None, # type: Optional[CommandArgs] )
Args: vc_class: a VersionControl subclass. rev: the name of the revision to install. extra_args: a list of extra options.
Args: vc_class: a VersionControl subclass. rev: the name of the revision to install. extra_args: a list of extra options.
def __init__( self, vc_class, # type: Type[VersionControl] rev=None, # type: Optional[str] extra_args=None, # type: Optional[CommandArgs] ): # type: (...) -> None """ Args: vc_class: a VersionControl subclass. rev: the name of the revisi...
[ "def", "__init__", "(", "self", ",", "vc_class", ",", "# type: Type[VersionControl]", "rev", "=", "None", ",", "# type: Optional[str]", "extra_args", "=", "None", ",", "# type: Optional[CommandArgs]", ")", ":", "# type: (...) -> None", "if", "extra_args", "is", "None"...
[ 218, 4 ]
[ 237, 31 ]
python
en
['en', 'error', 'th']
False
RevOptions.to_args
(self)
Return the VCS-specific command arguments.
Return the VCS-specific command arguments.
def to_args(self): # type: () -> CommandArgs """ Return the VCS-specific command arguments. """ args = [] # type: CommandArgs rev = self.arg_rev if rev is not None: args += self.vc_class.get_base_rev_args(rev) args += self.extra_args ...
[ "def", "to_args", "(", "self", ")", ":", "# type: () -> CommandArgs", "args", "=", "[", "]", "# type: CommandArgs", "rev", "=", "self", ".", "arg_rev", "if", "rev", "is", "not", "None", ":", "args", "+=", "self", ".", "vc_class", ".", "get_base_rev_args", ...
[ 251, 4 ]
[ 262, 19 ]
python
en
['en', 'error', 'th']
False
RevOptions.make_new
(self, rev)
Make a copy of the current instance, but with a new rev. Args: rev: the name of the revision for the new object.
Make a copy of the current instance, but with a new rev.
def make_new(self, rev): # type: (str) -> RevOptions """ Make a copy of the current instance, but with a new rev. Args: rev: the name of the revision for the new object. """ return self.vc_class.make_rev_options(rev, extra_args=self.extra_args)
[ "def", "make_new", "(", "self", ",", "rev", ")", ":", "# type: (str) -> RevOptions", "return", "self", ".", "vc_class", ".", "make_rev_options", "(", "rev", ",", "extra_args", "=", "self", ".", "extra_args", ")" ]
[ 271, 4 ]
[ 279, 78 ]
python
en
['en', 'error', 'th']
False
VcsSupport.get_backend_for_dir
(self, location)
Return a VersionControl object if a repository of that type is found at the given directory.
Return a VersionControl object if a repository of that type is found at the given directory.
def get_backend_for_dir(self, location): # type: (str) -> Optional[VersionControl] """ Return a VersionControl object if a repository of that type is found at the given directory. """ vcs_backends = {} for vcs_backend in self._registry.values(): repo_p...
[ "def", "get_backend_for_dir", "(", "self", ",", "location", ")", ":", "# type: (str) -> Optional[VersionControl]", "vcs_backends", "=", "{", "}", "for", "vcs_backend", "in", "self", ".", "_registry", ".", "values", "(", ")", ":", "repo_path", "=", "vcs_backend", ...
[ 332, 4 ]
[ 355, 49 ]
python
en
['en', 'error', 'th']
False
VcsSupport.get_backend_for_scheme
(self, scheme)
Return a VersionControl object or None.
Return a VersionControl object or None.
def get_backend_for_scheme(self, scheme): # type: (str) -> Optional[VersionControl] """ Return a VersionControl object or None. """ for vcs_backend in self._registry.values(): if scheme in vcs_backend.schemes: return vcs_backend return None
[ "def", "get_backend_for_scheme", "(", "self", ",", "scheme", ")", ":", "# type: (str) -> Optional[VersionControl]", "for", "vcs_backend", "in", "self", ".", "_registry", ".", "values", "(", ")", ":", "if", "scheme", "in", "vcs_backend", ".", "schemes", ":", "ret...
[ 357, 4 ]
[ 365, 19 ]
python
en
['en', 'error', 'th']
False
VcsSupport.get_backend
(self, name)
Return a VersionControl object or None.
Return a VersionControl object or None.
def get_backend(self, name): # type: (str) -> Optional[VersionControl] """ Return a VersionControl object or None. """ name = name.lower() return self._registry.get(name)
[ "def", "get_backend", "(", "self", ",", "name", ")", ":", "# type: (str) -> Optional[VersionControl]", "name", "=", "name", ".", "lower", "(", ")", "return", "self", ".", "_registry", ".", "get", "(", "name", ")" ]
[ 367, 4 ]
[ 373, 39 ]
python
en
['en', 'error', 'th']
False
VersionControl.should_add_vcs_url_prefix
(cls, remote_url)
Return whether the vcs prefix (e.g. "git+") should be added to a repository's remote url when used in a requirement.
Return whether the vcs prefix (e.g. "git+") should be added to a repository's remote url when used in a requirement.
def should_add_vcs_url_prefix(cls, remote_url): # type: (str) -> bool """ Return whether the vcs prefix (e.g. "git+") should be added to a repository's remote url when used in a requirement. """ return not remote_url.lower().startswith('{}:'.format(cls.name))
[ "def", "should_add_vcs_url_prefix", "(", "cls", ",", "remote_url", ")", ":", "# type: (str) -> bool", "return", "not", "remote_url", ".", "lower", "(", ")", ".", "startswith", "(", "'{}:'", ".", "format", "(", "cls", ".", "name", ")", ")" ]
[ 390, 4 ]
[ 396, 72 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_subdirectory
(cls, location)
Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root.
Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root.
def get_subdirectory(cls, location): # type: (str) -> Optional[str] """ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. """ return None
[ "def", "get_subdirectory", "(", "cls", ",", "location", ")", ":", "# type: (str) -> Optional[str]", "return", "None" ]
[ 399, 4 ]
[ 405, 19 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_requirement_revision
(cls, repo_dir)
Return the revision string that should be used in a requirement.
Return the revision string that should be used in a requirement.
def get_requirement_revision(cls, repo_dir): # type: (str) -> str """ Return the revision string that should be used in a requirement. """ return cls.get_revision(repo_dir)
[ "def", "get_requirement_revision", "(", "cls", ",", "repo_dir", ")", ":", "# type: (str) -> str", "return", "cls", ".", "get_revision", "(", "repo_dir", ")" ]
[ 408, 4 ]
[ 413, 41 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_src_requirement
(cls, repo_dir, project_name)
Return the requirement string to use to redownload the files currently at the given repository directory. Args: project_name: the (unescaped) project name. The return value has a form similar to the following: {repository_url}@{revision}#egg={project_name} ...
Return the requirement string to use to redownload the files currently at the given repository directory.
def get_src_requirement(cls, repo_dir, project_name): # type: (str, str) -> Optional[str] """ Return the requirement string to use to redownload the files currently at the given repository directory. Args: project_name: the (unescaped) project name. The return...
[ "def", "get_src_requirement", "(", "cls", ",", "repo_dir", ",", "project_name", ")", ":", "# type: (str, str) -> Optional[str]", "repo_url", "=", "cls", ".", "get_remote_url", "(", "repo_dir", ")", "if", "repo_url", "is", "None", ":", "return", "None", "if", "cl...
[ 416, 4 ]
[ 441, 18 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_base_rev_args
(rev)
Return the base revision arguments for a vcs command. Args: rev: the name of a revision to install. Cannot be None.
Return the base revision arguments for a vcs command.
def get_base_rev_args(rev): # type: (str) -> List[str] """ Return the base revision arguments for a vcs command. Args: rev: the name of a revision to install. Cannot be None. """ raise NotImplementedError
[ "def", "get_base_rev_args", "(", "rev", ")", ":", "# type: (str) -> List[str]", "raise", "NotImplementedError" ]
[ 444, 4 ]
[ 452, 33 ]
python
en
['en', 'error', 'th']
False
VersionControl.is_immutable_rev_checkout
(self, url, dest)
Return true if the commit hash checked out at dest matches the revision in url. Always return False, if the VCS does not support immutable commit hashes. This method does not check if there are local uncommitted changes in dest after checkout, as pip currently has no u...
Return true if the commit hash checked out at dest matches the revision in url.
def is_immutable_rev_checkout(self, url, dest): # type: (str, str) -> bool """ Return true if the commit hash checked out at dest matches the revision in url. Always return False, if the VCS does not support immutable commit hashes. This method does not check if...
[ "def", "is_immutable_rev_checkout", "(", "self", ",", "url", ",", "dest", ")", ":", "# type: (str, str) -> bool", "return", "False" ]
[ 454, 4 ]
[ 466, 20 ]
python
en
['en', 'error', 'th']
False
VersionControl.make_rev_options
(cls, rev=None, extra_args=None)
Return a RevOptions object. Args: rev: the name of a revision to install. extra_args: a list of extra options.
Return a RevOptions object.
def make_rev_options(cls, rev=None, extra_args=None): # type: (Optional[str], Optional[CommandArgs]) -> RevOptions """ Return a RevOptions object. Args: rev: the name of a revision to install. extra_args: a list of extra options. """ return RevOptions...
[ "def", "make_rev_options", "(", "cls", ",", "rev", "=", "None", ",", "extra_args", "=", "None", ")", ":", "# type: (Optional[str], Optional[CommandArgs]) -> RevOptions", "return", "RevOptions", "(", "cls", ",", "rev", ",", "extra_args", "=", "extra_args", ")" ]
[ 469, 4 ]
[ 478, 58 ]
python
en
['en', 'error', 'th']
False
VersionControl._is_local_repository
(cls, repo)
posix absolute paths start with os.path.sep, win32 ones start with drive (like c:\\folder)
posix absolute paths start with os.path.sep, win32 ones start with drive (like c:\\folder)
def _is_local_repository(cls, repo): # type: (str) -> bool """ posix absolute paths start with os.path.sep, win32 ones start with drive (like c:\\folder) """ drive, tail = os.path.splitdrive(repo) return repo.startswith(os.path.sep) or bool(drive)
[ "def", "_is_local_repository", "(", "cls", ",", "repo", ")", ":", "# type: (str) -> bool", "drive", ",", "tail", "=", "os", ".", "path", ".", "splitdrive", "(", "repo", ")", "return", "repo", ".", "startswith", "(", "os", ".", "path", ".", "sep", ")", ...
[ 481, 4 ]
[ 488, 58 ]
python
en
['en', 'error', 'th']
False
VersionControl.export
(self, location, url)
Export the repository at the url to the destination location i.e. only download the files, without vcs informations :param url: the repository URL starting with a vcs prefix.
Export the repository at the url to the destination location i.e. only download the files, without vcs informations
def export(self, location, url): # type: (str, HiddenText) -> None """ Export the repository at the url to the destination location i.e. only download the files, without vcs informations :param url: the repository URL starting with a vcs prefix. """ raise NotImpl...
[ "def", "export", "(", "self", ",", "location", ",", "url", ")", ":", "# type: (str, HiddenText) -> None", "raise", "NotImplementedError" ]
[ 490, 4 ]
[ 498, 33 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_netloc_and_auth
(cls, netloc, scheme)
Parse the repository URL's netloc, and return the new netloc to use along with auth information. Args: netloc: the original repository URL netloc. scheme: the repository URL's scheme without the vcs prefix. This is mainly for the Subversion class to override, so th...
Parse the repository URL's netloc, and return the new netloc to use along with auth information.
def get_netloc_and_auth(cls, netloc, scheme): # type: (str, str) -> Tuple[str, Tuple[Optional[str], Optional[str]]] """ Parse the repository URL's netloc, and return the new netloc to use along with auth information. Args: netloc: the original repository URL netloc. ...
[ "def", "get_netloc_and_auth", "(", "cls", ",", "netloc", ",", "scheme", ")", ":", "# type: (str, str) -> Tuple[str, Tuple[Optional[str], Optional[str]]]", "return", "netloc", ",", "(", "None", ",", "None", ")" ]
[ 501, 4 ]
[ 518, 35 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_url_rev_and_auth
(cls, url)
Parse the repository URL to use, and return the URL, revision, and auth info to use. Returns: (url, rev, (username, password)).
Parse the repository URL to use, and return the URL, revision, and auth info to use.
def get_url_rev_and_auth(cls, url): # type: (str) -> Tuple[str, Optional[str], AuthInfo] """ Parse the repository URL to use, and return the URL, revision, and auth info to use. Returns: (url, rev, (username, password)). """ scheme, netloc, path, query, frag = ur...
[ "def", "get_url_rev_and_auth", "(", "cls", ",", "url", ")", ":", "# type: (str) -> Tuple[str, Optional[str], AuthInfo]", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "frag", "=", "urllib_parse", ".", "urlsplit", "(", "url", ")", "if", "'+'", "not", ...
[ 521, 4 ]
[ 549, 34 ]
python
en
['en', 'error', 'th']
False
VersionControl.make_rev_args
(username, password)
Return the RevOptions "extra arguments" to use in obtain().
Return the RevOptions "extra arguments" to use in obtain().
def make_rev_args(username, password): # type: (Optional[str], Optional[HiddenText]) -> CommandArgs """ Return the RevOptions "extra arguments" to use in obtain(). """ return []
[ "def", "make_rev_args", "(", "username", ",", "password", ")", ":", "# type: (Optional[str], Optional[HiddenText]) -> CommandArgs", "return", "[", "]" ]
[ 552, 4 ]
[ 557, 17 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_url_rev_options
(self, url)
Return the URL and RevOptions object to use in obtain() and in some cases export(), as a tuple (url, rev_options).
Return the URL and RevOptions object to use in obtain() and in some cases export(), as a tuple (url, rev_options).
def get_url_rev_options(self, url): # type: (HiddenText) -> Tuple[HiddenText, RevOptions] """ Return the URL and RevOptions object to use in obtain() and in some cases export(), as a tuple (url, rev_options). """ secret_url, rev, user_pass = self.get_url_rev_and_auth(url....
[ "def", "get_url_rev_options", "(", "self", ",", "url", ")", ":", "# type: (HiddenText) -> Tuple[HiddenText, RevOptions]", "secret_url", ",", "rev", ",", "user_pass", "=", "self", ".", "get_url_rev_and_auth", "(", "url", ".", "secret", ")", "username", ",", "secret_p...
[ 559, 4 ]
[ 573, 48 ]
python
en
['en', 'error', 'th']
False
VersionControl.normalize_url
(url)
Normalize a URL for comparison by unquoting it and removing any trailing slash.
Normalize a URL for comparison by unquoting it and removing any trailing slash.
def normalize_url(url): # type: (str) -> str """ Normalize a URL for comparison by unquoting it and removing any trailing slash. """ return urllib_parse.unquote(url).rstrip('/')
[ "def", "normalize_url", "(", "url", ")", ":", "# type: (str) -> str", "return", "urllib_parse", ".", "unquote", "(", "url", ")", ".", "rstrip", "(", "'/'", ")" ]
[ 576, 4 ]
[ 582, 52 ]
python
en
['en', 'error', 'th']
False
VersionControl.compare_urls
(cls, url1, url2)
Compare two repo URLs for identity, ignoring incidental differences.
Compare two repo URLs for identity, ignoring incidental differences.
def compare_urls(cls, url1, url2): # type: (str, str) -> bool """ Compare two repo URLs for identity, ignoring incidental differences. """ return (cls.normalize_url(url1) == cls.normalize_url(url2))
[ "def", "compare_urls", "(", "cls", ",", "url1", ",", "url2", ")", ":", "# type: (str, str) -> bool", "return", "(", "cls", ".", "normalize_url", "(", "url1", ")", "==", "cls", ".", "normalize_url", "(", "url2", ")", ")" ]
[ 585, 4 ]
[ 590, 67 ]
python
en
['en', 'error', 'th']
False
VersionControl.fetch_new
(self, dest, url, rev_options)
Fetch a revision from a repository, in the case that this is the first fetch from the repository. Args: dest: the directory to fetch the repository to. rev_options: a RevOptions object.
Fetch a revision from a repository, in the case that this is the first fetch from the repository.
def fetch_new(self, dest, url, rev_options): # type: (str, HiddenText, RevOptions) -> None """ Fetch a revision from a repository, in the case that this is the first fetch from the repository. Args: dest: the directory to fetch the repository to. rev_options:...
[ "def", "fetch_new", "(", "self", ",", "dest", ",", "url", ",", "rev_options", ")", ":", "# type: (str, HiddenText, RevOptions) -> None", "raise", "NotImplementedError" ]
[ 592, 4 ]
[ 602, 33 ]
python
en
['en', 'error', 'th']
False
VersionControl.switch
(self, dest, url, rev_options)
Switch the repo at ``dest`` to point to ``URL``. Args: rev_options: a RevOptions object.
Switch the repo at ``dest`` to point to ``URL``.
def switch(self, dest, url, rev_options): # type: (str, HiddenText, RevOptions) -> None """ Switch the repo at ``dest`` to point to ``URL``. Args: rev_options: a RevOptions object. """ raise NotImplementedError
[ "def", "switch", "(", "self", ",", "dest", ",", "url", ",", "rev_options", ")", ":", "# type: (str, HiddenText, RevOptions) -> None", "raise", "NotImplementedError" ]
[ 604, 4 ]
[ 612, 33 ]
python
en
['en', 'error', 'th']
False
VersionControl.update
(self, dest, url, rev_options)
Update an already-existing repo to the given ``rev_options``. Args: rev_options: a RevOptions object.
Update an already-existing repo to the given ``rev_options``.
def update(self, dest, url, rev_options): # type: (str, HiddenText, RevOptions) -> None """ Update an already-existing repo to the given ``rev_options``. Args: rev_options: a RevOptions object. """ raise NotImplementedError
[ "def", "update", "(", "self", ",", "dest", ",", "url", ",", "rev_options", ")", ":", "# type: (str, HiddenText, RevOptions) -> None", "raise", "NotImplementedError" ]
[ 614, 4 ]
[ 622, 33 ]
python
en
['en', 'error', 'th']
False
VersionControl.is_commit_id_equal
(cls, dest, name)
Return whether the id of the current commit equals the given name. Args: dest: the repository directory. name: a string name.
Return whether the id of the current commit equals the given name.
def is_commit_id_equal(cls, dest, name): # type: (str, Optional[str]) -> bool """ Return whether the id of the current commit equals the given name. Args: dest: the repository directory. name: a string name. """ raise NotImplementedError
[ "def", "is_commit_id_equal", "(", "cls", ",", "dest", ",", "name", ")", ":", "# type: (str, Optional[str]) -> bool", "raise", "NotImplementedError" ]
[ 625, 4 ]
[ 634, 33 ]
python
en
['en', 'error', 'th']
False
VersionControl.obtain
(self, dest, url)
Install or update in editable mode the package represented by this VersionControl object. :param dest: the repository directory in which to install or update. :param url: the repository URL starting with a vcs prefix.
Install or update in editable mode the package represented by this VersionControl object.
def obtain(self, dest, url): # type: (str, HiddenText) -> None """ Install or update in editable mode the package represented by this VersionControl object. :param dest: the repository directory in which to install or update. :param url: the repository URL starting with ...
[ "def", "obtain", "(", "self", ",", "dest", ",", "url", ")", ":", "# type: (str, HiddenText) -> None", "url", ",", "rev_options", "=", "self", ".", "get_url_rev_options", "(", "url", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "dest", ")", ":...
[ 636, 4 ]
[ 728, 47 ]
python
en
['en', 'error', 'th']
False
VersionControl.unpack
(self, location, url)
Clean up current location and download the url repository (and vcs infos) into location :param url: the repository URL starting with a vcs prefix.
Clean up current location and download the url repository (and vcs infos) into location
def unpack(self, location, url): # type: (str, HiddenText) -> None """ Clean up current location and download the url repository (and vcs infos) into location :param url: the repository URL starting with a vcs prefix. """ if os.path.exists(location): ...
[ "def", "unpack", "(", "self", ",", "location", ",", "url", ")", ":", "# type: (str, HiddenText) -> None", "if", "os", ".", "path", ".", "exists", "(", "location", ")", ":", "rmtree", "(", "location", ")", "self", ".", "obtain", "(", "location", ",", "url...
[ 730, 4 ]
[ 740, 38 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_remote_url
(cls, location)
Return the url used at location Raises RemoteNotFoundError if the repository does not have a remote url configured.
Return the url used at location
def get_remote_url(cls, location): # type: (str) -> str """ Return the url used at location Raises RemoteNotFoundError if the repository does not have a remote url configured. """ raise NotImplementedError
[ "def", "get_remote_url", "(", "cls", ",", "location", ")", ":", "# type: (str) -> str", "raise", "NotImplementedError" ]
[ 743, 4 ]
[ 751, 33 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_revision
(cls, location)
Return the current commit id of the files at the given location.
Return the current commit id of the files at the given location.
def get_revision(cls, location): # type: (str) -> str """ Return the current commit id of the files at the given location. """ raise NotImplementedError
[ "def", "get_revision", "(", "cls", ",", "location", ")", ":", "# type: (str) -> str", "raise", "NotImplementedError" ]
[ 754, 4 ]
[ 759, 33 ]
python
en
['en', 'error', 'th']
False
VersionControl.run_command
( cls, cmd, # type: Union[List[str], CommandArgs] cwd=None, # type: Optional[str] extra_environ=None, # type: Optional[Mapping[str, Any]] extra_ok_returncodes=None, # type: Optional[Iterable[int]] log_failed_cmd=True # type: bool )
Run a VCS subcommand This is simply a wrapper around call_subprocess that adds the VCS command name, and checks that the VCS is available
Run a VCS subcommand This is simply a wrapper around call_subprocess that adds the VCS command name, and checks that the VCS is available
def run_command( cls, cmd, # type: Union[List[str], CommandArgs] cwd=None, # type: Optional[str] extra_environ=None, # type: Optional[Mapping[str, Any]] extra_ok_returncodes=None, # type: Optional[Iterable[int]] log_failed_cmd=True # type: bool ): # type:...
[ "def", "run_command", "(", "cls", ",", "cmd", ",", "# type: Union[List[str], CommandArgs]", "cwd", "=", "None", ",", "# type: Optional[str]", "extra_environ", "=", "None", ",", "# type: Optional[Mapping[str, Any]]", "extra_ok_returncodes", "=", "None", ",", "# type: Optio...
[ 762, 4 ]
[ 791, 21 ]
python
en
['en', 'error', 'th']
False
VersionControl.is_repository_directory
(cls, path)
Return whether a directory path is a repository directory.
Return whether a directory path is a repository directory.
def is_repository_directory(cls, path): # type: (str) -> bool """ Return whether a directory path is a repository directory. """ logger.debug('Checking in %s for %s (%s)...', path, cls.dirname, cls.name) return os.path.exists(os.path.join(path, cls.di...
[ "def", "is_repository_directory", "(", "cls", ",", "path", ")", ":", "# type: (str) -> bool", "logger", ".", "debug", "(", "'Checking in %s for %s (%s)...'", ",", "path", ",", "cls", ".", "dirname", ",", "cls", ".", "name", ")", "return", "os", ".", "path", ...
[ 794, 4 ]
[ 801, 62 ]
python
en
['en', 'error', 'th']
False
VersionControl.get_repository_root
(cls, location)
Return the "root" (top-level) directory controlled by the vcs, or `None` if the directory is not in any. It is meant to be overridden to implement smarter detection mechanisms for specific vcs. This can do more than is_repository_directory() alone. For example, the Git...
Return the "root" (top-level) directory controlled by the vcs, or `None` if the directory is not in any.
def get_repository_root(cls, location): # type: (str) -> Optional[str] """ Return the "root" (top-level) directory controlled by the vcs, or `None` if the directory is not in any. It is meant to be overridden to implement smarter detection mechanisms for specific vcs. ...
[ "def", "get_repository_root", "(", "cls", ",", "location", ")", ":", "# type: (str) -> Optional[str]", "if", "cls", ".", "is_repository_directory", "(", "location", ")", ":", "return", "location", "return", "None" ]
[ 804, 4 ]
[ 818, 19 ]
python
en
['en', 'error', 'th']
False
run_benchmark
(rgi_version=None, rgi_reg=None, border=None, output_folder='', working_dir='', is_test=False, test_rgidf=None, test_intersects_file=None, test_topofile=None)
Does the actual job. Parameters ---------- rgi_version : str the RGI version to use (defaults to cfg.PARAMS) rgi_reg : str the RGI region to process border : int the number of pixels at the maps border output_folder : str path to the output folder (where to put t...
Does the actual job.
def run_benchmark(rgi_version=None, rgi_reg=None, border=None, output_folder='', working_dir='', is_test=False, test_rgidf=None, test_intersects_file=None, test_topofile=None): """Does the actual job. Parameters ---------- rgi_version : str ...
[ "def", "run_benchmark", "(", "rgi_version", "=", "None", ",", "rgi_reg", "=", "None", ",", "border", "=", "None", ",", "output_folder", "=", "''", ",", "working_dir", "=", "''", ",", "is_test", "=", "False", ",", "test_rgidf", "=", "None", ",", "test_int...
[ 30, 0 ]
[ 190, 44 ]
python
en
['en', 'en', 'en']
True
parse_args
(args)
Check input arguments and env variables
Check input arguments and env variables
def parse_args(args): """Check input arguments and env variables""" # CLI args description = ('Run an OGGM benchmark on a selected RGI Region. ' 'This writes a benchmark_{border}.txt file where ' 'the results are summarized') parser = argparse.ArgumentParser(descri...
[ "def", "parse_args", "(", "args", ")", ":", "# CLI args", "description", "=", "(", "'Run an OGGM benchmark on a selected RGI Region. '", "'This writes a benchmark_{border}.txt file where '", "'the results are summarized'", ")", "parser", "=", "argparse", ".", "ArgumentParser", ...
[ 193, 0 ]
[ 254, 59 ]
python
en
['en', 'en', 'en']
True
main
()
Script entry point
Script entry point
def main(): """Script entry point""" run_benchmark(**parse_args(sys.argv[1:]))
[ "def", "main", "(", ")", ":", "run_benchmark", "(", "*", "*", "parse_args", "(", "sys", ".", "argv", "[", "1", ":", "]", ")", ")" ]
[ 257, 0 ]
[ 260, 45 ]
python
en
['en', 'en', 'en']
True
get_supported
( version=None, # type: Optional[str] platforms=None, # type: Optional[List[str]] impl=None, # type: Optional[str] abis=None # type: Optional[List[str]] )
Return a list of supported tags for each version specified in `versions`. :param version: a string version, of the form "33" or "32", or None. The version will be assumed to support our ABI. :param platform: specify a list of platforms you want valid tags for, or None. If None, use the loca...
Return a list of supported tags for each version specified in `versions`.
def get_supported( version=None, # type: Optional[str] platforms=None, # type: Optional[List[str]] impl=None, # type: Optional[str] abis=None # type: Optional[List[str]] ): # type: (...) -> List[Tag] """Return a list of supported tags for each version specified in `versions`. :param...
[ "def", "get_supported", "(", "version", "=", "None", ",", "# type: Optional[str]", "platforms", "=", "None", ",", "# type: Optional[List[str]]", "impl", "=", "None", ",", "# type: Optional[str]", "abis", "=", "None", "# type: Optional[List[str]]", ")", ":", "# type: (...
[ 123, 0 ]
[ 177, 20 ]
python
en
['en', 'en', 'en']
True
ME4Entity.ContainmentTree
(self)
Adding StorageEnclosure , Enclosure and Volume to Scalable CompTree :return: JSON
Adding StorageEnclosure , Enclosure and Volume to Scalable CompTree :return: JSON
def ContainmentTree(self): """ Adding StorageEnclosure , Enclosure and Volume to Scalable CompTree :return: JSON """ device_json = self.get_json_device() ctree = self._build_ctree(self.protofactory.ctree, device_json) if self.is_scalable: systree = ctr...
[ "def", "ContainmentTree", "(", "self", ")", ":", "device_json", "=", "self", ".", "get_json_device", "(", ")", "ctree", "=", "self", ".", "_build_ctree", "(", "self", ".", "protofactory", ".", "ctree", ",", "device_json", ")", "if", "self", ".", "is_scalab...
[ 509, 4 ]
[ 523, 20 ]
python
en
['en', 'error', 'th']
False
ME4Entity._should_i_modify_component
(self, finalretjson, component)
This function is to add or modify the json data
This function is to add or modify the json data
def _should_i_modify_component(self, finalretjson, component): """ This function is to add or modify the json data""" try: if "ServiceTag" == component and "System" in finalretjson.keys(): if len(finalretjson[component]) == 1: finalretjson['System'][0]['se...
[ "def", "_should_i_modify_component", "(", "self", ",", "finalretjson", ",", "component", ")", ":", "try", ":", "if", "\"ServiceTag\"", "==", "component", "and", "\"System\"", "in", "finalretjson", ".", "keys", "(", ")", ":", "if", "len", "(", "finalretjson", ...
[ 569, 4 ]
[ 614, 19 ]
python
en
['en', 'en', 'en']
True
ME4Entity.remove_componet
(self, finalretjson)
this function remove all the unwanted json in case of scalable
this function remove all the unwanted json in case of scalable
def remove_componet(self, finalretjson): """this function remove all the unwanted json in case of scalable""" try: keys_list = [] for i, j in finalretjson.items(): keys_list.append(i) deep_key_list = keys_list[:] temp_comp_list = ['System',...
[ "def", "remove_componet", "(", "self", ",", "finalretjson", ")", ":", "try", ":", "keys_list", "=", "[", "]", "for", "i", ",", "j", "in", "finalretjson", ".", "items", "(", ")", ":", "keys_list", ".", "append", "(", "i", ")", "deep_key_list", "=", "k...
[ 661, 4 ]
[ 674, 26 ]
python
en
['en', 'en', 'en']
True
ME4Entity.calculate_health
(self, key, value, component)
this function calculate rollup health
this function calculate rollup health
def calculate_health(self, key, value, component): """this function calculate rollup health""" try: health_dict = ME4RestViews_FieldSpec[ME4CompEnum[component]] list_value = [] new_health_dict = {} for i, j in health_dict["health-numeric"]['Values'].items(...
[ "def", "calculate_health", "(", "self", ",", "key", ",", "value", ",", "component", ")", ":", "try", ":", "health_dict", "=", "ME4RestViews_FieldSpec", "[", "ME4CompEnum", "[", "component", "]", "]", "list_value", "=", "[", "]", "new_health_dict", "=", "{", ...
[ 677, 4 ]
[ 705, 28 ]
python
en
['en', 'en', 'en']
True
parse_blazemeter_test_link
(link)
ERROR: type should be string, got "\n https://a.blazemeter.com/app/#/accounts/97961/workspaces/89846/projects/229969/tests/5823512\n\n :param link:\n :return:\n "
ERROR: type should be string, got "\n https://a.blazemeter.com/app/#/accounts/97961/workspaces/89846/projects/229969/tests/5823512"
def parse_blazemeter_test_link(link): """ https://a.blazemeter.com/app/#/accounts/97961/workspaces/89846/projects/229969/tests/5823512 :param link: :return: """ if not isinstance(link, str): return None regex = r'https://a.blazemeter.com/app/#/accounts/(\d+)/workspaces/(\d+)/projec...
[ "def", "parse_blazemeter_test_link", "(", "link", ")", ":", "if", "not", "isinstance", "(", "link", ",", "str", ")", ":", "return", "None", "regex", "=", "r'https://a.blazemeter.com/app/#/accounts/(\\d+)/workspaces/(\\d+)/projects/(\\d+)/tests/(\\d+)(?:/\\w+)?'", "match", "...
[ 29, 0 ]
[ 45, 56 ]
python
en
['en', 'error', 'th']
False
TestApi.test_calculate_varmetric_region
(self)
Ra & Decl filtering
Ra & Decl filtering
def test_calculate_varmetric_region(self): """ Ra & Decl filtering """ r = tkp.db.alchemy.varmetric.calculate_varmetric(self.session, self.dataset1, ra_range=(0, 2), decl_ran...
[ "def", "test_calculate_varmetric_region", "(", "self", ")", ":", "r", "=", "tkp", ".", "db", ".", "alchemy", ".", "varmetric", ".", "calculate_varmetric", "(", "self", ".", "session", ",", "self", ".", "dataset1", ",", "ra_range", "=", "(", "0", ",", "2"...
[ 81, 4 ]
[ 93, 35 ]
python
en
['en', 'error', 'th']
False
TestApi.test_calculate_varmetric_cutoff
(self)
V_int & eta_int filtering
V_int & eta_int filtering
def test_calculate_varmetric_cutoff(self): """ V_int & eta_int filtering """ r = tkp.db.alchemy.varmetric.calculate_varmetric(self.session, self.dataset1, v_int_min=0, eta_in...
[ "def", "test_calculate_varmetric_cutoff", "(", "self", ")", ":", "r", "=", "tkp", ".", "db", ".", "alchemy", ".", "varmetric", ".", "calculate_varmetric", "(", "self", ".", "session", ",", "self", ".", "dataset1", ",", "v_int_min", "=", "0", ",", "eta_int_...
[ 95, 4 ]
[ 113, 35 ]
python
en
['en', 'error', 'th']
False
TestApi.test_calculate_varmetric_newsource
(self)
Ra & Decl filtering
Ra & Decl filtering
def test_calculate_varmetric_newsource(self): """ Ra & Decl filtering """ r = tkp.db.alchemy.varmetric.calculate_varmetric(self.session, self.dataset1, new_src_only=True).all() self.assertEqual(len(r), 2)
[ "def", "test_calculate_varmetric_newsource", "(", "self", ")", ":", "r", "=", "tkp", ".", "db", ".", "alchemy", ".", "varmetric", ".", "calculate_varmetric", "(", "self", ".", "session", ",", "self", ".", "dataset1", ",", "new_src_only", "=", "True", ")", ...
[ 115, 4 ]
[ 121, 35 ]
python
en
['en', 'error', 'th']
False
compress_kml
(kml)
Returns compressed KMZ from the given KML string.
Returns compressed KMZ from the given KML string.
def compress_kml(kml): "Returns compressed KMZ from the given KML string." kmz = BytesIO() with zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED) as zf: zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET)) kmz.seek(0) return kmz.read()
[ "def", "compress_kml", "(", "kml", ")", ":", "kmz", "=", "BytesIO", "(", ")", "with", "zipfile", ".", "ZipFile", "(", "kmz", ",", "'a'", ",", "zipfile", ".", "ZIP_DEFLATED", ")", "as", "zf", ":", "zf", ".", "writestr", "(", "'doc.kml'", ",", "kml", ...
[ 14, 0 ]
[ 20, 21 ]
python
en
['en', 'en', 'en']
True
render_to_kml
(*args, **kwargs)
Renders the response as KML (using the correct MIME type).
Renders the response as KML (using the correct MIME type).
def render_to_kml(*args, **kwargs): "Renders the response as KML (using the correct MIME type)." return HttpResponse( loader.render_to_string(*args, **kwargs), content_type='application/vnd.google-earth.kml+xml', )
[ "def", "render_to_kml", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "HttpResponse", "(", "loader", ".", "render_to_string", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "content_type", "=", "'application/vnd.google-earth.kml+xml'", ...
[ 23, 0 ]
[ 28, 5 ]
python
en
['en', 'en', 'en']
True
render_to_kmz
(*args, **kwargs)
Compresses the KML content and returns as KMZ (using the correct MIME type).
Compresses the KML content and returns as KMZ (using the correct MIME type).
def render_to_kmz(*args, **kwargs): """ Compresses the KML content and returns as KMZ (using the correct MIME type). """ return HttpResponse( compress_kml(loader.render_to_string(*args, **kwargs)), content_type='application/vnd.google-earth.kmz', )
[ "def", "render_to_kmz", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "HttpResponse", "(", "compress_kml", "(", "loader", ".", "render_to_string", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", ",", "content_type", "=", "'applicati...
[ 31, 0 ]
[ 39, 5 ]
python
en
['en', 'error', 'th']
False
render_to_text
(*args, **kwargs)
Renders the response using the MIME type for plain text.
Renders the response using the MIME type for plain text.
def render_to_text(*args, **kwargs): "Renders the response using the MIME type for plain text." return HttpResponse(loader.render_to_string(*args, **kwargs), content_type='text/plain')
[ "def", "render_to_text", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "HttpResponse", "(", "loader", ".", "render_to_string", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "content_type", "=", "'text/plain'", ")" ]
[ 42, 0 ]
[ 44, 92 ]
python
en
['en', 'en', 'en']
True
get_isolated_page
(request: HttpRequest)
Accept a GET param `?nav=no` to render an isolated, navless page.
Accept a GET param `?nav=no` to render an isolated, navless page.
def get_isolated_page(request: HttpRequest) -> bool: """Accept a GET param `?nav=no` to render an isolated, navless page.""" return request.GET.get("nav") == "no"
[ "def", "get_isolated_page", "(", "request", ":", "HttpRequest", ")", "->", "bool", ":", "return", "request", ".", "GET", ".", "get", "(", "\"nav\"", ")", "==", "\"no\"" ]
[ 97, 0 ]
[ 99, 41 ]
python
en
['en', 'en', 'en']
True
WSKaleConnection.close
(self, ban_time: int = 0, ws_close_code: WSCloseCode = WSCloseCode.OK, error: Optional[Err] = None)
Closes the connection, and finally calls the close_callback on the server, so the connections gets removed from the global list.
Closes the connection, and finally calls the close_callback on the server, so the connections gets removed from the global list.
async def close(self, ban_time: int = 0, ws_close_code: WSCloseCode = WSCloseCode.OK, error: Optional[Err] = None): """ Closes the connection, and finally calls the close_callback on the server, so the connections gets removed from the global list. """ if self.closed: ...
[ "async", "def", "close", "(", "self", ",", "ban_time", ":", "int", "=", "0", ",", "ws_close_code", ":", "WSCloseCode", "=", "WSCloseCode", ".", "OK", ",", "error", ":", "Optional", "[", "Err", "]", "=", "None", ")", ":", "if", "self", ".", "closed", ...
[ 164, 4 ]
[ 196, 43 ]
python
en
['en', 'error', 'th']
False
WSKaleConnection.send_message
(self, message: Message)
Send message sends a message with no tracking / callback.
Send message sends a message with no tracking / callback.
async def send_message(self, message: Message): """Send message sends a message with no tracking / callback.""" if self.closed: return None await self.outgoing_queue.put(message)
[ "async", "def", "send_message", "(", "self", ",", "message", ":", "Message", ")", ":", "if", "self", ".", "closed", ":", "return", "None", "await", "self", ".", "outgoing_queue", ".", "put", "(", "message", ")" ]
[ 239, 4 ]
[ 243, 46 ]
python
en
['en', 'en', 'en']
True
WSKaleConnection.create_request
(self, message_no_id: Message, timeout: int)
Sends a message and waits for a response.
Sends a message and waits for a response.
async def create_request(self, message_no_id: Message, timeout: int) -> Optional[Message]: """Sends a message and waits for a response.""" if self.closed: return None # We will wait for this event, it will be set either by the response, or the timeout event = asyncio.Event()...
[ "async", "def", "create_request", "(", "self", ",", "message_no_id", ":", "Message", ",", "timeout", ":", "int", ")", "->", "Optional", "[", "Message", "]", ":", "if", "self", ".", "closed", ":", "return", "None", "# We will wait for this event, it will be set e...
[ 278, 4 ]
[ 324, 21 ]
python
en
['en', 'en', 'en']
True
InterruptibleMixin.__init__
(self, *args, **kwargs)
Save the original SIGINT handler for later.
Save the original SIGINT handler for later.
def __init__(self, *args, **kwargs): # type: (List[Any], Dict[Any, Any]) -> None """ Save the original SIGINT handler for later. """ # https://github.com/python/mypy/issues/5887 super(InterruptibleMixin, self).__init__( # type: ignore *args, **kwa...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (List[Any], Dict[Any, Any]) -> None", "# https://github.com/python/mypy/issues/5887", "super", "(", "InterruptibleMixin", ",", "self", ")", ".", "__init__", "(", "# type: ign...
[ 75, 4 ]
[ 94, 55 ]
python
en
['en', 'error', 'th']
False
InterruptibleMixin.finish
(self)
Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted.
Restore the original SIGINT handler after finishing.
def finish(self): # type: () -> None """ Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted. """ super(InterruptibleMixin, self).finish() # type: ignore ...
[ "def", "finish", "(", "self", ")", ":", "# type: () -> None", "super", "(", "InterruptibleMixin", ",", "self", ")", ".", "finish", "(", ")", "# type: ignore", "signal", "(", "SIGINT", ",", "self", ".", "original_handler", ")" ]
[ 96, 4 ]
[ 105, 45 ]
python
en
['en', 'error', 'th']
False
InterruptibleMixin.handle_sigint
(self, signum, frame)
Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active.
Call self.finish() before delegating to the original SIGINT handler.
def handle_sigint(self, signum, frame): # type: ignore """ Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active. """ self.finish() self.original_handler(signum, frame)
[ "def", "handle_sigint", "(", "self", ",", "signum", ",", "frame", ")", ":", "# type: ignore", "self", ".", "finish", "(", ")", "self", ".", "original_handler", "(", "signum", ",", "frame", ")" ]
[ 107, 4 ]
[ 115, 44 ]
python
en
['en', 'error', 'th']
False
get_build_version
()
Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6.
Return the version of MSVC that was used to build Python.
def get_build_version(): """Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6. """ prefix = "MSC v." i = sys.version.find(prefix) if i == -1: return 6 ...
[ "def", "get_build_version", "(", ")", ":", "prefix", "=", "\"MSC v.\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "return", "6", "i", "=", "i", "+", "len", "(", "prefix", ")", "s", ",", "r...
[ 166, 0 ]
[ 189, 15 ]
python
en
['en', 'en', 'en']
True
normalize_and_reduce_paths
(paths)
Return a list of normalized paths with duplicates removed. The current order of paths is maintained.
Return a list of normalized paths with duplicates removed.
def normalize_and_reduce_paths(paths): """Return a list of normalized paths with duplicates removed. The current order of paths is maintained. """ # Paths are normalized so things like: /a and /a/ aren't both preserved. reduced_paths = [] for p in paths: np = os.path.normpath(p) ...
[ "def", "normalize_and_reduce_paths", "(", "paths", ")", ":", "# Paths are normalized so things like: /a and /a/ aren't both preserved.", "reduced_paths", "=", "[", "]", "for", "p", "in", "paths", ":", "np", "=", "os", ".", "path", ".", "normpath", "(", "p", ")", ...
[ 191, 0 ]
[ 203, 24 ]
python
en
['en', 'en', 'en']
True
removeDuplicates
(variable)
Remove duplicate values of an environment variable.
Remove duplicate values of an environment variable.
def removeDuplicates(variable): """Remove duplicate values of an environment variable. """ oldList = variable.split(os.pathsep) newList = [] for i in oldList: if i not in newList: newList.append(i) newVariable = os.pathsep.join(newList) return newVariable
[ "def", "removeDuplicates", "(", "variable", ")", ":", "oldList", "=", "variable", ".", "split", "(", "os", ".", "pathsep", ")", "newList", "=", "[", "]", "for", "i", "in", "oldList", ":", "if", "i", "not", "in", "newList", ":", "newList", ".", "appen...
[ 205, 0 ]
[ 214, 22 ]
python
en
['en', 'en', 'en']
True
find_vcvarsall
(version)
Find the vcvarsall.bat file At first it tries to find the productdir of VS 2008 in the registry. If that fails it falls back to the VS90COMNTOOLS env var.
Find the vcvarsall.bat file
def find_vcvarsall(version): """Find the vcvarsall.bat file At first it tries to find the productdir of VS 2008 in the registry. If that fails it falls back to the VS90COMNTOOLS env var. """ vsbase = VS_BASE % version try: productdir = Reg.get_value(r"%s\Setup\VC" % vsbase, ...
[ "def", "find_vcvarsall", "(", "version", ")", ":", "vsbase", "=", "VS_BASE", "%", "version", "try", ":", "productdir", "=", "Reg", ".", "get_value", "(", "r\"%s\\Setup\\VC\"", "%", "vsbase", ",", "\"productdir\"", ")", "except", "KeyError", ":", "log", ".", ...
[ 216, 0 ]
[ 249, 15 ]
python
en
['en', 'en', 'en']
True
query_vcvarsall
(version, arch="x86")
Launch vcvarsall.bat and read the settings from its environment
Launch vcvarsall.bat and read the settings from its environment
def query_vcvarsall(version, arch="x86"): """Launch vcvarsall.bat and read the settings from its environment """ vcvarsall = find_vcvarsall(version) interesting = {"include", "lib", "libpath", "path"} result = {} if vcvarsall is None: raise DistutilsPlatformError("Unable to find vcvarsa...
[ "def", "query_vcvarsall", "(", "version", ",", "arch", "=", "\"x86\"", ")", ":", "vcvarsall", "=", "find_vcvarsall", "(", "version", ")", "interesting", "=", "{", "\"include\"", ",", "\"lib\"", ",", "\"libpath\"", ",", "\"path\"", "}", "result", "=", "{", ...
[ 251, 0 ]
[ 289, 17 ]
python
en
['en', 'en', 'en']
True