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
dotted_netmask
(mask)
Converts mask from /xx format to xxx.xxx.xxx.xxx Example: if mask is 24 function returns 255.255.255.0 :rtype: str
Converts mask from /xx format to xxx.xxx.xxx.xxx
def dotted_netmask(mask): """Converts mask from /xx format to xxx.xxx.xxx.xxx Example: if mask is 24 function returns 255.255.255.0 :rtype: str """ bits = 0xffffffff ^ (1 << 32 - mask) - 1 return socket.inet_ntoa(struct.pack('>I', bits))
[ "def", "dotted_netmask", "(", "mask", ")", ":", "bits", "=", "0xffffffff", "^", "(", "1", "<<", "32", "-", "mask", ")", "-", "1", "return", "socket", ".", "inet_ntoa", "(", "struct", ".", "pack", "(", "'>I'", ",", "bits", ")", ")" ]
[ 636, 0 ]
[ 644, 52 ]
python
en
['en', 'pl', 'en']
True
is_ipv4_address
(string_ip)
:rtype: bool
:rtype: bool
def is_ipv4_address(string_ip): """ :rtype: bool """ try: socket.inet_aton(string_ip) except socket.error: return False return True
[ "def", "is_ipv4_address", "(", "string_ip", ")", ":", "try", ":", "socket", ".", "inet_aton", "(", "string_ip", ")", "except", "socket", ".", "error", ":", "return", "False", "return", "True" ]
[ 647, 0 ]
[ 655, 15 ]
python
en
['en', 'error', 'th']
False
is_valid_cidr
(string_network)
Very simple check of the cidr format in no_proxy variable. :rtype: bool
Very simple check of the cidr format in no_proxy variable.
def is_valid_cidr(string_network): """ Very simple check of the cidr format in no_proxy variable. :rtype: bool """ if string_network.count('/') == 1: try: mask = int(string_network.split('/')[1]) except ValueError: return False if mask < 1 or mask > ...
[ "def", "is_valid_cidr", "(", "string_network", ")", ":", "if", "string_network", ".", "count", "(", "'/'", ")", "==", "1", ":", "try", ":", "mask", "=", "int", "(", "string_network", ".", "split", "(", "'/'", ")", "[", "1", "]", ")", "except", "Value...
[ 658, 0 ]
[ 679, 15 ]
python
en
['en', 'error', 'th']
False
set_environ
(env_name, value)
Set the environment variable 'env_name' to 'value' Save previous value, yield, and then restore the previous value stored in the environment variable 'env_name'. If 'value' is None, do nothing
Set the environment variable 'env_name' to 'value'
def set_environ(env_name, value): """Set the environment variable 'env_name' to 'value' Save previous value, yield, and then restore the previous value stored in the environment variable 'env_name'. If 'value' is None, do nothing""" value_changed = value is not None if value_changed: o...
[ "def", "set_environ", "(", "env_name", ",", "value", ")", ":", "value_changed", "=", "value", "is", "not", "None", "if", "value_changed", ":", "old_value", "=", "os", ".", "environ", ".", "get", "(", "env_name", ")", "os", ".", "environ", "[", "env_name"...
[ 683, 0 ]
[ 701, 48 ]
python
en
['en', 'en', 'en']
True
should_bypass_proxies
(url, no_proxy)
Returns whether we should bypass proxies or not. :rtype: bool
Returns whether we should bypass proxies or not.
def should_bypass_proxies(url, no_proxy): """ Returns whether we should bypass proxies or not. :rtype: bool """ # Prioritize lowercase environment variables over uppercase # to keep a consistent behaviour with other http projects (curl, wget). get_proxy = lambda k: os.environ.get(k) or os.e...
[ "def", "should_bypass_proxies", "(", "url", ",", "no_proxy", ")", ":", "# Prioritize lowercase environment variables over uppercase", "# to keep a consistent behaviour with other http projects (curl, wget).", "get_proxy", "=", "lambda", "k", ":", "os", ".", "environ", ".", "get...
[ 704, 0 ]
[ 762, 16 ]
python
en
['en', 'error', 'th']
False
get_environ_proxies
(url, no_proxy=None)
Return a dict of environment proxies. :rtype: dict
Return a dict of environment proxies.
def get_environ_proxies(url, no_proxy=None): """ Return a dict of environment proxies. :rtype: dict """ if should_bypass_proxies(url, no_proxy=no_proxy): return {} else: return getproxies()
[ "def", "get_environ_proxies", "(", "url", ",", "no_proxy", "=", "None", ")", ":", "if", "should_bypass_proxies", "(", "url", ",", "no_proxy", "=", "no_proxy", ")", ":", "return", "{", "}", "else", ":", "return", "getproxies", "(", ")" ]
[ 765, 0 ]
[ 774, 27 ]
python
en
['en', 'error', 'th']
False
select_proxy
(url, proxies)
Select a proxy for the url, if applicable. :param url: The url being for the request :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
Select a proxy for the url, if applicable.
def select_proxy(url, proxies): """Select a proxy for the url, if applicable. :param url: The url being for the request :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs """ proxies = proxies or {} urlparts = urlparse(url) if urlparts.hostname is None: retur...
[ "def", "select_proxy", "(", "url", ",", "proxies", ")", ":", "proxies", "=", "proxies", "or", "{", "}", "urlparts", "=", "urlparse", "(", "url", ")", "if", "urlparts", ".", "hostname", "is", "None", ":", "return", "proxies", ".", "get", "(", "urlparts"...
[ 777, 0 ]
[ 800, 16 ]
python
en
['en', 'en', 'en']
True
default_user_agent
(name="python-requests")
Return a string representing the default user agent. :rtype: str
Return a string representing the default user agent.
def default_user_agent(name="python-requests"): """ Return a string representing the default user agent. :rtype: str """ return '%s/%s' % (name, __version__)
[ "def", "default_user_agent", "(", "name", "=", "\"python-requests\"", ")", ":", "return", "'%s/%s'", "%", "(", "name", ",", "__version__", ")" ]
[ 803, 0 ]
[ 809, 40 ]
python
en
['en', 'error', 'th']
False
default_headers
()
:rtype: requests.structures.CaseInsensitiveDict
:rtype: requests.structures.CaseInsensitiveDict
def default_headers(): """ :rtype: requests.structures.CaseInsensitiveDict """ return CaseInsensitiveDict({ 'User-Agent': default_user_agent(), 'Accept-Encoding': ', '.join(('gzip', 'deflate')), 'Accept': '*/*', 'Connection': 'keep-alive', })
[ "def", "default_headers", "(", ")", ":", "return", "CaseInsensitiveDict", "(", "{", "'User-Agent'", ":", "default_user_agent", "(", ")", ",", "'Accept-Encoding'", ":", "', '", ".", "join", "(", "(", "'gzip'", ",", "'deflate'", ")", ")", ",", "'Accept'", ":",...
[ 812, 0 ]
[ 821, 6 ]
python
en
['en', 'error', 'th']
False
parse_header_links
(value)
Return a list of parsed link headers proxies. i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg" :rtype: list
Return a list of parsed link headers proxies.
def parse_header_links(value): """Return a list of parsed link headers proxies. i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg" :rtype: list """ links = [] replace_chars = ' \'"' value = value.strip(replace_chars) if...
[ "def", "parse_header_links", "(", "value", ")", ":", "links", "=", "[", "]", "replace_chars", "=", "' \\'\"'", "value", "=", "value", ".", "strip", "(", "replace_chars", ")", "if", "not", "value", ":", "return", "links", "for", "val", "in", "re", ".", ...
[ 824, 0 ]
[ 858, 16 ]
python
en
['en', 'af', 'en']
True
guess_json_utf
(data)
:rtype: str
:rtype: str
def guess_json_utf(data): """ :rtype: str """ # JSON always starts with two ASCII characters, so detection is as # easy as counting the nulls and from their location and count # determine the encoding. Also detect a BOM, if present. sample = data[:4] if sample in (codecs.BOM_UTF32_LE, co...
[ "def", "guess_json_utf", "(", "data", ")", ":", "# JSON always starts with two ASCII characters, so detection is as", "# easy as counting the nulls and from their location and count", "# determine the encoding. Also detect a BOM, if present.", "sample", "=", "data", "[", ":", "4", "]",...
[ 867, 0 ]
[ 896, 15 ]
python
en
['en', 'error', 'th']
False
prepend_scheme_if_needed
(url, new_scheme)
Given a URL that may or may not have a scheme, prepend the given scheme. Does not replace a present scheme with the one provided as an argument. :rtype: str
Given a URL that may or may not have a scheme, prepend the given scheme. Does not replace a present scheme with the one provided as an argument.
def prepend_scheme_if_needed(url, new_scheme): """Given a URL that may or may not have a scheme, prepend the given scheme. Does not replace a present scheme with the one provided as an argument. :rtype: str """ scheme, netloc, path, params, query, fragment = urlparse(url, new_scheme) # urlpars...
[ "def", "prepend_scheme_if_needed", "(", "url", ",", "new_scheme", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "fragment", "=", "urlparse", "(", "url", ",", "new_scheme", ")", "# urlparse is a finicky beast, and sometimes decid...
[ 899, 0 ]
[ 913, 70 ]
python
en
['en', 'en', 'en']
True
get_auth_from_url
(url)
Given a url with authentication components, extract them into a tuple of username,password. :rtype: (str,str)
Given a url with authentication components, extract them into a tuple of username,password.
def get_auth_from_url(url): """Given a url with authentication components, extract them into a tuple of username,password. :rtype: (str,str) """ parsed = urlparse(url) try: auth = (unquote(parsed.username), unquote(parsed.password)) except (AttributeError, TypeError): auth ...
[ "def", "get_auth_from_url", "(", "url", ")", ":", "parsed", "=", "urlparse", "(", "url", ")", "try", ":", "auth", "=", "(", "unquote", "(", "parsed", ".", "username", ")", ",", "unquote", "(", "parsed", ".", "password", ")", ")", "except", "(", "Attr...
[ 916, 0 ]
[ 929, 15 ]
python
en
['en', 'en', 'en']
True
check_header_validity
(header)
Verifies that header value is a string which doesn't contain leading whitespace or return characters. This prevents unintended header injection. :param header: tuple, in the format (name, value).
Verifies that header value is a string which doesn't contain leading whitespace or return characters. This prevents unintended header injection.
def check_header_validity(header): """Verifies that header value is a string which doesn't contain leading whitespace or return characters. This prevents unintended header injection. :param header: tuple, in the format (name, value). """ name, value = header if isinstance(value, bytes): ...
[ "def", "check_header_validity", "(", "header", ")", ":", "name", ",", "value", "=", "header", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "pat", "=", "_CLEAN_HEADER_REGEX_BYTE", "else", ":", "pat", "=", "_CLEAN_HEADER_REGEX_STR", "try", ":", "i...
[ 937, 0 ]
[ 955, 73 ]
python
en
['en', 'en', 'en']
True
urldefragauth
(url)
Given a url remove the fragment and the authentication part. :rtype: str
Given a url remove the fragment and the authentication part.
def urldefragauth(url): """ Given a url remove the fragment and the authentication part. :rtype: str """ scheme, netloc, path, params, query, fragment = urlparse(url) # see func:`prepend_scheme_if_needed` if not netloc: netloc, path = path, netloc netloc = netloc.rsplit('@', 1...
[ "def", "urldefragauth", "(", "url", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "fragment", "=", "urlparse", "(", "url", ")", "# see func:`prepend_scheme_if_needed`", "if", "not", "netloc", ":", "netloc", ",", "path", ...
[ 958, 0 ]
[ 972, 64 ]
python
en
['en', 'error', 'th']
False
rewind_body
(prepared_request)
Move file pointer back to its recorded starting position so it can be read again on redirect.
Move file pointer back to its recorded starting position so it can be read again on redirect.
def rewind_body(prepared_request): """Move file pointer back to its recorded starting position so it can be read again on redirect. """ body_seek = getattr(prepared_request.body, 'seek', None) if body_seek is not None and isinstance(prepared_request._body_position, integer_types): try: ...
[ "def", "rewind_body", "(", "prepared_request", ")", ":", "body_seek", "=", "getattr", "(", "prepared_request", ".", "body", ",", "'seek'", ",", "None", ")", "if", "body_seek", "is", "not", "None", "and", "isinstance", "(", "prepared_request", ".", "_body_posit...
[ 975, 0 ]
[ 987, 82 ]
python
en
['en', 'en', 'en']
True
scantree
(root)
Recurse the given directory yielding (pathname, os.stat(pathname)) pairs
Recurse the given directory yielding (pathname, os.stat(pathname)) pairs
def scantree(root): """ Recurse the given directory yielding (pathname, os.stat(pathname)) pairs """ for entry in os.scandir(root): if entry.is_dir(): yield from scantree(entry.path) else: yield entry.path, entry.stat()
[ "def", "scantree", "(", "root", ")", ":", "for", "entry", "in", "os", ".", "scandir", "(", "root", ")", ":", "if", "entry", ".", "is_dir", "(", ")", ":", "yield", "from", "scantree", "(", "entry", ".", "path", ")", "else", ":", "yield", "entry", ...
[ 264, 0 ]
[ 272, 42 ]
python
en
['en', 'error', 'th']
False
WhiteNoise.url_is_canonical
(url)
Check that the URL path is in canonical format i.e. has normalised slashes and no path traversal elements
Check that the URL path is in canonical format i.e. has normalised slashes and no path traversal elements
def url_is_canonical(url): """ Check that the URL path is in canonical format i.e. has normalised slashes and no path traversal elements """ if "\\" in url: return False normalised = normpath(url) if url.endswith("/") and url != "/": normal...
[ "def", "url_is_canonical", "(", "url", ")", ":", "if", "\"\\\\\"", "in", "url", ":", "return", "False", "normalised", "=", "normpath", "(", "url", ")", "if", "url", ".", "endswith", "(", "\"/\"", ")", "and", "url", "!=", "\"/\"", ":", "normalised", "+=...
[ 181, 4 ]
[ 191, 32 ]
python
en
['en', 'error', 'th']
False
WhiteNoise.immutable_file_test
(self, path, url)
This should be implemented by sub-classes (see e.g. WhiteNoiseMiddleware) or by setting the `immutable_file_test` config option
This should be implemented by sub-classes (see e.g. WhiteNoiseMiddleware) or by setting the `immutable_file_test` config option
def immutable_file_test(self, path, url): """ This should be implemented by sub-classes (see e.g. WhiteNoiseMiddleware) or by setting the `immutable_file_test` config option """ return False
[ "def", "immutable_file_test", "(", "self", ",", "path", ",", "url", ")", ":", "return", "False" ]
[ 237, 4 ]
[ 242, 20 ]
python
en
['en', 'error', 'th']
False
WhiteNoise.redirect
(self, from_url, to_url)
Return a relative 302 redirect We use relative redirects as we don't know the absolute URL the app is being hosted under
Return a relative 302 redirect
def redirect(self, from_url, to_url): """ Return a relative 302 redirect We use relative redirects as we don't know the absolute URL the app is being hosted under """ if to_url == from_url + "/": relative_url = from_url.split("/")[-1] + "/" elif from_...
[ "def", "redirect", "(", "self", ",", "from_url", ",", "to_url", ")", ":", "if", "to_url", "==", "from_url", "+", "\"/\"", ":", "relative_url", "=", "from_url", ".", "split", "(", "\"/\"", ")", "[", "-", "1", "]", "+", "\"/\"", "elif", "from_url", "==...
[ 244, 4 ]
[ 261, 54 ]
python
en
['en', 'error', 'th']
False
ConditionalGetMiddleware.needs_etag
(self, response)
Return True if an ETag header should be added to response.
Return True if an ETag header should be added to response.
def needs_etag(self, response): """ Return True if an ETag header should be added to response. """ cache_control_headers = cc_delim_re.split(response.get('Cache-Control', '')) return all(header.lower() != 'no-store' for header in cache_control_headers)
[ "def", "needs_etag", "(", "self", ",", "response", ")", ":", "cache_control_headers", "=", "cc_delim_re", ".", "split", "(", "response", ".", "get", "(", "'Cache-Control'", ",", "''", ")", ")", "return", "all", "(", "header", ".", "lower", "(", ")", "!="...
[ 39, 4 ]
[ 44, 84 ]
python
en
['en', 'error', 'th']
False
_group_matching
(tlist, cls)
Groups Tokens that have beginning and end.
Groups Tokens that have beginning and end.
def _group_matching(tlist, cls): """Groups Tokens that have beginning and end.""" opens = [] tidx_offset = 0 for idx, token in enumerate(list(tlist)): tidx = idx - tidx_offset if token.is_whitespace: # ~50% of tokens will be whitespace. Will checking early # for ...
[ "def", "_group_matching", "(", "tlist", ",", "cls", ")", ":", "opens", "=", "[", "]", "tidx_offset", "=", "0", "for", "idx", ",", "token", "in", "enumerate", "(", "list", "(", "tlist", ")", ")", ":", "tidx", "=", "idx", "-", "tidx_offset", "if", "t...
[ 16, 0 ]
[ 48, 47 ]
python
en
['en', 'en', 'en']
True
group_order
(tlist)
Group together Identifier and Asc/Desc token
Group together Identifier and Asc/Desc token
def group_order(tlist): """Group together Identifier and Asc/Desc token""" tidx, token = tlist.token_next_by(t=T.Keyword.Order) while token: pidx, prev_ = tlist.token_prev(tidx) if imt(prev_, i=sql.Identifier, t=T.Number): tlist.group_tokens(sql.Identifier, pidx, tidx) ...
[ "def", "group_order", "(", "tlist", ")", ":", "tidx", ",", "token", "=", "tlist", ".", "token_next_by", "(", "t", "=", "T", ".", "Keyword", ".", "Order", ")", "while", "token", ":", "pidx", ",", "prev_", "=", "tlist", ".", "token_prev", "(", "tidx", ...
[ 352, 0 ]
[ 360, 70 ]
python
en
['en', 'en', 'en']
True
_group
(tlist, cls, match, valid_prev=lambda t: True, valid_next=lambda t: True, post=None, extend=True, recurse=True )
Groups together tokens that are joined by a middle token. i.e. x < y
Groups together tokens that are joined by a middle token. i.e. x < y
def _group(tlist, cls, match, valid_prev=lambda t: True, valid_next=lambda t: True, post=None, extend=True, recurse=True ): """Groups together tokens that are joined by a middle token. i.e. x < y""" tidx_offset = 0 pidx, prev_ = None, None ...
[ "def", "_group", "(", "tlist", ",", "cls", ",", "match", ",", "valid_prev", "=", "lambda", "t", ":", "True", ",", "valid_next", "=", "lambda", "t", ":", "True", ",", "post", "=", "None", ",", "extend", "=", "True", ",", "recurse", "=", "True", ")",...
[ 421, 0 ]
[ 453, 33 ]
python
en
['en', 'en', 'en']
True
openfile
(fname, openMode="r", compress=False, readfile=True, skipComments=False, commentChar="#", debugLineLimit=0)
open and optionally read a gzipped or uncompressed file If the file is read, return the read data. If the file is just opened, return the filehandle.
open and optionally read a gzipped or uncompressed file If the file is read, return the read data. If the file is just opened, return the filehandle.
def openfile(fname, openMode="r", compress=False, readfile=True, skipComments=False, commentChar="#", debugLineLimit=0): """ open and optionally read a gzipped or uncompressed file If the file is read, return the read data. If the file is just opened, return the filehandle.""" ...
[ "def", "openfile", "(", "fname", ",", "openMode", "=", "\"r\"", ",", "compress", "=", "False", ",", "readfile", "=", "True", ",", "skipComments", "=", "False", ",", "commentChar", "=", "\"#\"", ",", "debugLineLimit", "=", "0", ")", ":", "import", "gzip",...
[ 27, 0 ]
[ 89, 26 ]
python
en
['en', 'en', 'en']
True
generic_set_region
(region_rep, start=None, stop=None, strand=None, generated_by=None)
Returns the input region, or builds one from the input details This is used in several of the parsers including the annotation, and wigData classes
Returns the input region, or builds one from the input details This is used in several of the parsers including the annotation, and wigData classes
def generic_set_region(region_rep, start=None, stop=None, strand=None, generated_by=None): ''' Returns the input region, or builds one from the input details This is used in several of the parsers including the annotation, and wigData classes ''' general_msg = "Inva...
[ "def", "generic_set_region", "(", "region_rep", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "strand", "=", "None", ",", "generated_by", "=", "None", ")", ":", "general_msg", "=", "\"Invalid region specification. Regions should be either a \"", "\"valid...
[ 406, 0 ]
[ 485, 40 ]
python
en
['en', 'en', 'en']
True
makeStructuredArray
(data, dtype, delimiter="\t")
makes a structured array from delimited data with a column mapping
makes a structured array from delimited data with a column mapping
def makeStructuredArray(data, dtype, delimiter="\t"): ''' makes a structured array from delimited data with a column mapping ''' this_array = numpy.zeros(len(data), dtype=dtype) rec_count=0 i=0 while i<len(data): line = data[i] linedata = line.strip().split(delimiter) if...
[ "def", "makeStructuredArray", "(", "data", ",", "dtype", ",", "delimiter", "=", "\"\\t\"", ")", ":", "this_array", "=", "numpy", ".", "zeros", "(", "len", "(", "data", ")", ",", "dtype", "=", "dtype", ")", "rec_count", "=", "0", "i", "=", "0", "while...
[ 487, 0 ]
[ 505, 22 ]
python
en
['en', 'en', 'en']
True
getDataFromFormat
(filename, dataformat, available_formats, skip_comments=True, logger=None, verbose=False, slen=100)
reads a file in a particular format and gets the file data
reads a file in a particular format and gets the file data
def getDataFromFormat(filename, dataformat, available_formats, skip_comments=True, logger=None, verbose=False, slen=100): """reads a file in a particular format and gets the file data """ # type checks if type(filename) is not str: raise TypeError("The specified...
[ "def", "getDataFromFormat", "(", "filename", ",", "dataformat", ",", "available_formats", ",", "skip_comments", "=", "True", ",", "logger", "=", "None", ",", "verbose", "=", "False", ",", "slen", "=", "100", ")", ":", "# type checks", "if", "type", "(", "f...
[ 507, 0 ]
[ 643, 28 ]
python
en
['en', 'en', 'en']
True
addStructuredArrayfield
(a, descr, logger=None, verbose=False)
Return a new array that is like "a", but has additional fields. Arguments: a -- a structured numpy array descr -- a numpy type description of the new fields The contents of "a" are copied over to the appropriate fields in the new array, whereas the new fields are uninitialized. The ar...
Return a new array that is like "a", but has additional fields.
def addStructuredArrayfield(a, descr, logger=None, verbose=False): """Return a new array that is like "a", but has additional fields. Arguments: a -- a structured numpy array descr -- a numpy type description of the new fields The contents of "a" are copied over to the appropriate fie...
[ "def", "addStructuredArrayfield", "(", "a", ",", "descr", ",", "logger", "=", "None", ",", "verbose", "=", "False", ")", ":", "if", "a", ".", "dtype", ".", "fields", "is", "None", ":", "raise", "ValueError", "(", "\"`A' must be a structured numpy array\"", "...
[ 645, 0 ]
[ 691, 12 ]
python
en
['en', 'en', 'en']
True
computeIntrons
(exon_regions, logger=None, generated_by=None, verbose=False)
takes an set of exon regions and computes the corresponding introns Basically, place each exon in order and create the intron spaces, labelling the appropriately. All generic labels common to the exon set will be applied to the introns. In addition, the feature type will be intron and the introns ...
takes an set of exon regions and computes the corresponding introns Basically, place each exon in order and create the intron spaces, labelling the appropriately. All generic labels common to the exon set will be applied to the introns. In addition, the feature type will be intron and the introns ...
def computeIntrons(exon_regions, logger=None, generated_by=None, verbose=False): """ takes an set of exon regions and computes the corresponding introns Basically, place each exon in order and create the intron spaces, labelling the appropriately. All generic labels common to the exon set will be ...
[ "def", "computeIntrons", "(", "exon_regions", ",", "logger", "=", "None", ",", "generated_by", "=", "None", ",", "verbose", "=", "False", ")", ":", "if", "verbose", ":", "logger", ".", "info", "(", "\"Identifying exon common description items...\"", ")", "dellis...
[ 693, 0 ]
[ 739, 19 ]
python
en
['en', 'en', 'en']
True
region.__init__
(self, region_name, chrid, start, stop, strand=None, seq=None, seqtype=None, desc=None, generated_by=None)
class contrustor: this requires name and chromosome id as strings, start and stop and ints, and optionally strand, sequence and description as strings
class contrustor: this requires name and chromosome id as strings, start and stop and ints, and optionally strand, sequence and description as strings
def __init__(self, region_name, chrid, start, stop, strand=None, seq=None, seqtype=None, desc=None, generated_by=None): """ class contrustor: this requires name and chromosome id as strings, start and stop and ints, and optionally strand, sequence and descrip...
[ "def", "__init__", "(", "self", ",", "region_name", ",", "chrid", ",", "start", ",", "stop", ",", "strand", "=", "None", ",", "seq", "=", "None", ",", "seqtype", "=", "None", ",", "desc", "=", "None", ",", "generated_by", "=", "None", ")", ":", "se...
[ 95, 4 ]
[ 178, 50 ]
python
en
['en', 'en', 'en']
True
region.get_length
(self)
get the length (start-stop) of the feature
get the length (start-stop) of the feature
def get_length(self): """ get the length (start-stop) of the feature """ return(1+(self.stop-self.start))
[ "def", "get_length", "(", "self", ")", ":", "return", "(", "1", "+", "(", "self", ".", "stop", "-", "self", ".", "start", ")", ")" ]
[ 180, 4 ]
[ 184, 40 ]
python
en
['en', 'en', 'en']
True
region.get_positions_str
(self)
get the chr:start-stop of the feature
get the chr:start-stop of the feature
def get_positions_str(self): """ get the chr:start-stop of the feature """ pos_str = "%s:%s-%s" % (str(self.chrid), str(self.start), str(self.stop)) return(pos_str)
[ "def", "get_positions_str", "(", "self", ")", ":", "pos_str", "=", "\"%s:%s-%s\"", "%", "(", "str", "(", "self", ".", "chrid", ")", ",", "str", "(", "self", ".", "start", ")", ",", "str", "(", "self", ".", "stop", ")", ")", "return", "(", "pos_str"...
[ 186, 4 ]
[ 192, 23 ]
python
en
['en', 'en', 'en']
True
region.get_desc_str
(self)
get the desc of the feature as a csv string
get the desc of the feature as a csv string
def get_desc_str(self): """ get the desc of the feature as a csv string""" desc_str_list=[] for key in self.desc.keys(): desc_str = u"%s:%s" % (key, self.desc[key]) try: desc_str_list.append(desc_str.encode('ascii', 'ignore')) ...
[ "def", "get_desc_str", "(", "self", ")", ":", "desc_str_list", "=", "[", "]", "for", "key", "in", "self", ".", "desc", ".", "keys", "(", ")", ":", "desc_str", "=", "u\"%s:%s\"", "%", "(", "key", ",", "self", ".", "desc", "[", "key", "]", ")", "tr...
[ 194, 4 ]
[ 210, 30 ]
python
en
['en', 'en', 'en']
True
region.get_gff3line
(self)
gets the current region as a gff3 format line. The format is specified here http://www.sequenceontology.org/gff3.shtml
gets the current region as a gff3 format line. The format is specified here http://www.sequenceontology.org/gff3.shtml
def get_gff3line(self): """ gets the current region as a gff3 format line. The format is specified here http://www.sequenceontology.org/gff3.shtml """ redundant_keys = ["score", "phase", "type"] replace_keys = [("source", "original_source"), ("i...
[ "def", "get_gff3line", "(", "self", ")", ":", "redundant_keys", "=", "[", "\"score\"", ",", "\"phase\"", ",", "\"type\"", "]", "replace_keys", "=", "[", "(", "\"source\"", ",", "\"original_source\"", ")", ",", "(", "\"id\"", ",", "\"ID\"", ")", "]", "this_...
[ 212, 4 ]
[ 269, 24 ]
python
en
['en', 'en', 'en']
True
region.get_gtfline
(self, gene_id=None, transcript_id=None, verbose=False)
gets the current region as a gtf2 format line. http://www.ensembl.org/info/website/upload/gff.html
gets the current region as a gtf2 format line. http://www.ensembl.org/info/website/upload/gff.html
def get_gtfline(self, gene_id=None, transcript_id=None, verbose=False): """ gets the current region as a gtf2 format line. http://www.ensembl.org/info/website/upload/gff.html """ redundant_keys = ["score", "phase", "type"] replace_keys = [("source", "or...
[ "def", "get_gtfline", "(", "self", ",", "gene_id", "=", "None", ",", "transcript_id", "=", "None", ",", "verbose", "=", "False", ")", ":", "redundant_keys", "=", "[", "\"score\"", ",", "\"phase\"", ",", "\"type\"", "]", "replace_keys", "=", "[", "(", "\"...
[ 271, 4 ]
[ 360, 23 ]
python
en
['en', 'en', 'en']
True
region.get_bed6line
(self)
gets the current region as a bed6 format line. The format is specified here http://https://genome.ucsc.edu/FAQ/FAQformat.html
gets the current region as a bed6 format line. The format is specified here http://https://genome.ucsc.edu/FAQ/FAQformat.html
def get_bed6line(self): """ gets the current region as a bed6 format line. The format is specified here http://https://genome.ucsc.edu/FAQ/FAQformat.html """ this_attributes={} if self.desc is not None: this_attributes = copy.deepcop...
[ "def", "get_bed6line", "(", "self", ")", ":", "this_attributes", "=", "{", "}", "if", "self", ".", "desc", "is", "not", "None", ":", "this_attributes", "=", "copy", ".", "deepcopy", "(", "self", ".", "desc", ")", "this_score", "=", "\".\"", "if", "\"sc...
[ 362, 4 ]
[ 398, 24 ]
python
en
['en', 'en', 'en']
True
TestArchiveMessagesGeneral.test_expired_messages_in_each_realm
(self)
General test for archiving expired messages properly with multiple realms involved
General test for archiving expired messages properly with multiple realms involved
def test_expired_messages_in_each_realm(self) -> None: """General test for archiving expired messages properly with multiple realms involved""" # Make some expired messages in MIT: expired_mit_msg_ids = self._make_mit_messages( 5, timezone_now() - timedelta(days=M...
[ "def", "test_expired_messages_in_each_realm", "(", "self", ")", "->", "None", ":", "# Make some expired messages in MIT:", "expired_mit_msg_ids", "=", "self", ".", "_make_mit_messages", "(", "5", ",", "timezone_now", "(", ")", "-", "timedelta", "(", "days", "=", "MI...
[ 206, 4 ]
[ 235, 72 ]
python
en
['en', 'en', 'en']
True
TestArchiveMessagesGeneral.test_expired_messages_in_one_realm
(self)
Test with a retention policy set for only the MIT realm
Test with a retention policy set for only the MIT realm
def test_expired_messages_in_one_realm(self) -> None: """Test with a retention policy set for only the MIT realm""" self._set_realm_message_retention_value(self.zulip_realm, -1) # Make some expired messages in MIT: expired_mit_msg_ids = self._make_mit_messages( 5, ...
[ "def", "test_expired_messages_in_one_realm", "(", "self", ")", "->", "None", ":", "self", ".", "_set_realm_message_retention_value", "(", "self", ".", "zulip_realm", ",", "-", "1", ")", "# Make some expired messages in MIT:", "expired_mit_msg_ids", "=", "self", ".", "...
[ 237, 4 ]
[ 271, 83 ]
python
en
['en', 'en', 'en']
True
TestArchiveMessagesGeneral.test_cross_realm_personal_message_archiving
(self)
Check that cross-realm personal messages get correctly archived.
Check that cross-realm personal messages get correctly archived.
def test_cross_realm_personal_message_archiving(self) -> None: """Check that cross-realm personal messages get correctly archived.""" msg_ids = [self._send_cross_realm_personal_message() for i in range(1, 7)] usermsg_ids = self._get_usermessage_ids(msg_ids) # Make the message expired on ...
[ "def", "test_cross_realm_personal_message_archiving", "(", "self", ")", "->", "None", ":", "msg_ids", "=", "[", "self", ".", "_send_cross_realm_personal_message", "(", ")", "for", "i", "in", "range", "(", "1", ",", "7", ")", "]", "usermsg_ids", "=", "self", ...
[ 299, 4 ]
[ 307, 55 ]
python
en
['en', 'en', 'en']
True
TestArchiveMessagesGeneral.test_archiving_interrupted
(self)
Check that queries get rolled back to a consistent state if archiving gets interrupted in the middle of processing a chunk.
Check that queries get rolled back to a consistent state if archiving gets interrupted in the middle of processing a chunk.
def test_archiving_interrupted(self) -> None: """Check that queries get rolled back to a consistent state if archiving gets interrupted in the middle of processing a chunk.""" expired_msg_ids = self._make_expired_zulip_messages(7) expired_usermsg_ids = self._get_usermessage_ids(expired_m...
[ "def", "test_archiving_interrupted", "(", "self", ")", "->", "None", ":", "expired_msg_ids", "=", "self", ".", "_make_expired_zulip_messages", "(", "7", ")", "expired_usermsg_ids", "=", "self", ".", "_get_usermessage_ids", "(", "expired_msg_ids", ")", "# Insert an exc...
[ 309, 4 ]
[ 335, 13 ]
python
en
['en', 'en', 'en']
True
TestArchiveMessagesGeneral.test_archive_message_tool
(self)
End-to-end test of the archiving tool, directly calling archive_messages.
End-to-end test of the archiving tool, directly calling archive_messages.
def test_archive_message_tool(self) -> None: """End-to-end test of the archiving tool, directly calling archive_messages.""" # Make some expired messages in MIT: expired_mit_msg_ids = self._make_mit_messages( 5, timezone_now() - timedelta(days=MIT_REALM_DAYS + 1),...
[ "def", "test_archive_message_tool", "(", "self", ")", "->", "None", ":", "# Make some expired messages in MIT:", "expired_mit_msg_ids", "=", "self", ".", "_make_mit_messages", "(", "5", ",", "timezone_now", "(", ")", "-", "timedelta", "(", "days", "=", "MIT_REALM_DA...
[ 337, 4 ]
[ 366, 72 ]
python
en
['en', 'en', 'en']
True
TestArchiveMessagesGeneral.test_archiving_attachments
(self)
End-to-end test for the logic for archiving attachments. This test is hard to read without first reading _send_messages_with_attachments
End-to-end test for the logic for archiving attachments. This test is hard to read without first reading _send_messages_with_attachments
def test_archiving_attachments(self) -> None: """End-to-end test for the logic for archiving attachments. This test is hard to read without first reading _send_messages_with_attachments""" msgs_ids = self._send_messages_with_attachments() # First, confirm deleting the oldest message ...
[ "def", "test_archiving_attachments", "(", "self", ")", "->", "None", ":", "msgs_ids", "=", "self", ".", "_send_messages_with_attachments", "(", ")", "# First, confirm deleting the oldest message", "# (`expired_message_id`) creates ArchivedAttachment objects", "# and associates that...
[ 368, 4 ]
[ 428, 9 ]
python
en
['en', 'en', 'en']
True
MoveMessageToArchiveGeneral.test_archiving_messages_multiple_realms
(self)
Verifies that move_messages_to_archive works correctly if called on messages in multiple realms.
Verifies that move_messages_to_archive works correctly if called on messages in multiple realms.
def test_archiving_messages_multiple_realms(self) -> None: """ Verifies that move_messages_to_archive works correctly if called on messages in multiple realms. """ iago = self.example_user("iago") othello = self.example_user("othello") cordelia = self.lear_user("...
[ "def", "test_archiving_messages_multiple_realms", "(", "self", ")", "->", "None", ":", "iago", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "othello", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "cordelia", "=", "self", ".", "lear_use...
[ 628, 4 ]
[ 649, 56 ]
python
en
['en', 'error', 'th']
False
TestGetRealmAndStreamsForArchiving.fix_ordering_of_result
(self, result: List[Tuple[Realm, List[Stream]]])
This is a helper for giving the structure returned by get_realms_and_streams_for_archiving a consistent ordering.
This is a helper for giving the structure returned by get_realms_and_streams_for_archiving a consistent ordering.
def fix_ordering_of_result(self, result: List[Tuple[Realm, List[Stream]]]) -> None: """ This is a helper for giving the structure returned by get_realms_and_streams_for_archiving a consistent ordering. """ # Sort the list of tuples by realm id: result.sort(key=lambda x: x...
[ "def", "fix_ordering_of_result", "(", "self", ",", "result", ":", "List", "[", "Tuple", "[", "Realm", ",", "List", "[", "Stream", "]", "]", "]", ")", "->", "None", ":", "# Sort the list of tuples by realm id:", "result", ".", "sort", "(", "key", "=", "lamb...
[ 894, 4 ]
[ 904, 59 ]
python
en
['en', 'error', 'th']
False
TestGetRealmAndStreamsForArchiving.simple_get_realms_and_streams_for_archiving
(self)
This is an implementation of the function we're testing, but using the obvious, unoptimized algorithm. We can use this for additional verification of correctness, by comparing the output of the two implementations.
This is an implementation of the function we're testing, but using the obvious, unoptimized algorithm. We can use this for additional verification of correctness, by comparing the output of the two implementations.
def simple_get_realms_and_streams_for_archiving(self) -> List[Tuple[Realm, List[Stream]]]: """ This is an implementation of the function we're testing, but using the obvious, unoptimized algorithm. We can use this for additional verification of correctness, by comparing the output of the...
[ "def", "simple_get_realms_and_streams_for_archiving", "(", "self", ")", "->", "List", "[", "Tuple", "[", "Realm", ",", "List", "[", "Stream", "]", "]", "]", ":", "result", "=", "[", "]", "for", "realm", "in", "Realm", ".", "objects", ".", "all", "(", "...
[ 906, 4 ]
[ 927, 21 ]
python
en
['en', 'error', 'th']
False
TestDoDeleteMessages.test_old_event_format_processed_correctly
(self)
do_delete_messages used to send events with users in dict format {"id": <int>}. We have a block in process_notification to deal with that old format, that should be deleted in a later release. This test is meant to ensure correctness of that block.
do_delete_messages used to send events with users in dict format {"id": <int>}. We have a block in process_notification to deal with that old format, that should be deleted in a later release. This test is meant to ensure correctness of that block.
def test_old_event_format_processed_correctly(self) -> None: """ do_delete_messages used to send events with users in dict format {"id": <int>}. We have a block in process_notification to deal with that old format, that should be deleted in a later release. This test is meant to ensure c...
[ "def", "test_old_event_format_processed_correctly", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "cordelia", "=", "self", ".", "example_user", "(", "\"cordelia\"", ")", "hamlet", "=", "self", ".", "example_user", "(", ...
[ 1064, 4 ]
[ 1087, 74 ]
python
en
['en', 'error', 'th']
False
last_arg_byref
(args)
Returns the last C argument's value by reference.
Returns the last C argument's value by reference.
def last_arg_byref(args): "Returns the last C argument's value by reference." return args[-1]._obj.value
[ "def", "last_arg_byref", "(", "args", ")", ":", "return", "args", "[", "-", "1", "]", ".", "_obj", ".", "value" ]
[ 14, 0 ]
[ 16, 30 ]
python
en
['en', 'en', 'en']
True
check_dbl
(result, func, cargs)
Checks the status code and returns the double value passed in by reference.
Checks the status code and returns the double value passed in by reference.
def check_dbl(result, func, cargs): "Checks the status code and returns the double value passed in by reference." # Checking the status code if result != 1: return None # Double passed in by reference, return its value. return last_arg_byref(cargs)
[ "def", "check_dbl", "(", "result", ",", "func", ",", "cargs", ")", ":", "# Checking the status code", "if", "result", "!=", "1", ":", "return", "None", "# Double passed in by reference, return its value.", "return", "last_arg_byref", "(", "cargs", ")" ]
[ 19, 0 ]
[ 25, 32 ]
python
en
['en', 'en', 'en']
True
check_geom
(result, func, cargs)
Error checking on routines that return Geometries.
Error checking on routines that return Geometries.
def check_geom(result, func, cargs): "Error checking on routines that return Geometries." if not result: raise GEOSException('Error encountered checking Geometry returned from GEOS C function "%s".' % func.__name__) return result
[ "def", "check_geom", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "not", "result", ":", "raise", "GEOSException", "(", "'Error encountered checking Geometry returned from GEOS C function \"%s\".'", "%", "func", ".", "__name__", ")", "return", "result" ]
[ 28, 0 ]
[ 32, 17 ]
python
en
['en', 'el-Latn', 'en']
True
check_minus_one
(result, func, cargs)
Error checking on routines that should not return -1.
Error checking on routines that should not return -1.
def check_minus_one(result, func, cargs): "Error checking on routines that should not return -1." if result == -1: raise GEOSException('Error encountered in GEOS C function "%s".' % func.__name__) else: return result
[ "def", "check_minus_one", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "result", "==", "-", "1", ":", "raise", "GEOSException", "(", "'Error encountered in GEOS C function \"%s\".'", "%", "func", ".", "__name__", ")", "else", ":", "return", "resul...
[ 35, 0 ]
[ 40, 21 ]
python
en
['en', 'en', 'en']
True
check_predicate
(result, func, cargs)
Error checking for unary/binary predicate functions.
Error checking for unary/binary predicate functions.
def check_predicate(result, func, cargs): "Error checking for unary/binary predicate functions." val = ord(result) # getting the ordinal from the character if val == 1: return True elif val == 0: return False else: raise GEOSException('Error encountered on GEOS C predicate f...
[ "def", "check_predicate", "(", "result", ",", "func", ",", "cargs", ")", ":", "val", "=", "ord", "(", "result", ")", "# getting the ordinal from the character", "if", "val", "==", "1", ":", "return", "True", "elif", "val", "==", "0", ":", "return", "False"...
[ 43, 0 ]
[ 51, 99 ]
python
en
['en', 'en', 'en']
True
check_sized_string
(result, func, cargs)
Error checking for routines that return explicitly sized strings. This frees the memory allocated by GEOS at the result pointer.
Error checking for routines that return explicitly sized strings.
def check_sized_string(result, func, cargs): """ Error checking for routines that return explicitly sized strings. This frees the memory allocated by GEOS at the result pointer. """ if not result: raise GEOSException('Invalid string pointer returned by GEOS C function "%s"' % func.__name__)...
[ "def", "check_sized_string", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "not", "result", ":", "raise", "GEOSException", "(", "'Invalid string pointer returned by GEOS C function \"%s\"'", "%", "func", ".", "__name__", ")", "# A c_size_t object is passed i...
[ 54, 0 ]
[ 68, 12 ]
python
en
['en', 'error', 'th']
False
check_string
(result, func, cargs)
Error checking for routines that return strings. This frees the memory allocated by GEOS at the result pointer.
Error checking for routines that return strings.
def check_string(result, func, cargs): """ Error checking for routines that return strings. This frees the memory allocated by GEOS at the result pointer. """ if not result: raise GEOSException('Error encountered checking string return value in GEOS C function "%s".' % func.__name__) # ...
[ "def", "check_string", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "not", "result", ":", "raise", "GEOSException", "(", "'Error encountered checking string return value in GEOS C function \"%s\".'", "%", "func", ".", "__name__", ")", "# Getting the string ...
[ 71, 0 ]
[ 83, 12 ]
python
en
['en', 'error', 'th']
False
check_zero
(result, func, cargs)
Error checking on routines that should not return 0.
Error checking on routines that should not return 0.
def check_zero(result, func, cargs): "Error checking on routines that should not return 0." if result == 0: raise GEOSException('Error encountered in GEOS C function "%s".' % func.__name__) else: return result
[ "def", "check_zero", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "result", "==", "0", ":", "raise", "GEOSException", "(", "'Error encountered in GEOS C function \"%s\".'", "%", "func", ".", "__name__", ")", "else", ":", "return", "result" ]
[ 86, 0 ]
[ 91, 21 ]
python
en
['en', 'en', 'en']
True
deepmerge
(a, b)
Merge dict structures and return the result. >>> a = {'first': {'all_rows': {'pass': 'dog', 'number': '1'}}} >>> b = {'first': {'all_rows': {'fail': 'cat', 'number': '5'}}} >>> import pprint; pprint.pprint(deepmerge(a, b)) {'first': {'all_rows': {'fail': 'cat', 'number': '5', 'pass': 'dog'}}}
Merge dict structures and return the result.
def deepmerge(a, b): """ Merge dict structures and return the result. >>> a = {'first': {'all_rows': {'pass': 'dog', 'number': '1'}}} >>> b = {'first': {'all_rows': {'fail': 'cat', 'number': '5'}}} >>> import pprint; pprint.pprint(deepmerge(a, b)) {'first': {'all_rows': {'fail': 'cat', 'number'...
[ "def", "deepmerge", "(", "a", ",", "b", ")", ":", "if", "isinstance", "(", "a", ",", "dict", ")", "and", "isinstance", "(", "b", ",", "dict", ")", ":", "return", "dict", "(", "[", "(", "k", ",", "deepmerge", "(", "a", ".", "get", "(", "k", ")...
[ 17, 0 ]
[ 31, 16 ]
python
en
['en', 'error', 'th']
False
timeout
(timeout: float, func: Callable[[], ResultT])
Call the function in a separate thread. Return its return value, or raise an exception, within approximately 'timeout' seconds. The function may receive a TimeoutExpired exception anywhere in its code, which could have arbitrary unsafe effects (resources not released, etc.). It might also fail ...
Call the function in a separate thread. Return its return value, or raise an exception, within approximately 'timeout' seconds.
def timeout(timeout: float, func: Callable[[], ResultT]) -> ResultT: """Call the function in a separate thread. Return its return value, or raise an exception, within approximately 'timeout' seconds. The function may receive a TimeoutExpired exception anywhere in its code, which could have arbitrar...
[ "def", "timeout", "(", "timeout", ":", "float", ",", "func", ":", "Callable", "[", "[", "]", ",", "ResultT", "]", ")", "->", "ResultT", ":", "class", "TimeoutThread", "(", "threading", ".", "Thread", ")", ":", "def", "__init__", "(", "self", ")", "->...
[ 20, 0 ]
[ 95, 24 ]
python
en
['en', 'en', 'en']
True
_have_cython
()
Return True if Cython can be imported.
Return True if Cython can be imported.
def _have_cython(): """ Return True if Cython can be imported. """ cython_impl = 'Cython.Distutils.build_ext' try: # from (cython_impl) import build_ext __import__(cython_impl, fromlist=['build_ext']).build_ext return True except Exception: pass return False
[ "def", "_have_cython", "(", ")", ":", "cython_impl", "=", "'Cython.Distutils.build_ext'", "try", ":", "# from (cython_impl) import build_ext", "__import__", "(", "cython_impl", ",", "fromlist", "=", "[", "'build_ext'", "]", ")", ".", "build_ext", "return", "True", "...
[ 9, 0 ]
[ 20, 16 ]
python
en
['en', 'error', 'th']
False
Extension._convert_pyx_sources_to_lang
(self)
Replace sources with .pyx extensions to sources with the target language extension. This mechanism allows language authors to supply pre-converted sources but to prefer the .pyx sources.
Replace sources with .pyx extensions to sources with the target language extension. This mechanism allows language authors to supply pre-converted sources but to prefer the .pyx sources.
def _convert_pyx_sources_to_lang(self): """ Replace sources with .pyx extensions to sources with the target language extension. This mechanism allows language authors to supply pre-converted sources but to prefer the .pyx sources. """ if _have_cython(): # the ...
[ "def", "_convert_pyx_sources_to_lang", "(", "self", ")", ":", "if", "_have_cython", "(", ")", ":", "# the build has Cython, so allow it to compile the .pyx files", "return", "lang", "=", "self", ".", "language", "or", "''", "target_ext", "=", "'.cpp'", "if", "lang", ...
[ 38, 4 ]
[ 50, 51 ]
python
en
['en', 'error', 'th']
False
double_output
(func, argtypes, errcheck=False, strarg=False, cpl=False)
Generates a ctypes function that returns a double value.
Generates a ctypes function that returns a double value.
def double_output(func, argtypes, errcheck=False, strarg=False, cpl=False): "Generates a ctypes function that returns a double value." func.argtypes = argtypes func.restype = c_double if errcheck: func.errcheck = partial(check_arg_errcode, cpl=cpl) if strarg: func.errcheck = check_st...
[ "def", "double_output", "(", "func", ",", "argtypes", ",", "errcheck", "=", "False", ",", "strarg", "=", "False", ",", "cpl", "=", "False", ")", ":", "func", ".", "argtypes", "=", "argtypes", "func", ".", "restype", "=", "c_double", "if", "errcheck", "...
[ 17, 0 ]
[ 25, 15 ]
python
en
['en', 'en', 'en']
True
geom_output
(func, argtypes, offset=None)
Generates a function that returns a Geometry either by reference or directly (if the return_geom keyword is set to True).
Generates a function that returns a Geometry either by reference or directly (if the return_geom keyword is set to True).
def geom_output(func, argtypes, offset=None): """ Generates a function that returns a Geometry either by reference or directly (if the return_geom keyword is set to True). """ # Setting the argument types func.argtypes = argtypes if not offset: # When a geometry pointer is directly ...
[ "def", "geom_output", "(", "func", ",", "argtypes", ",", "offset", "=", "None", ")", ":", "# Setting the argument types", "func", ".", "argtypes", "=", "argtypes", "if", "not", "offset", ":", "# When a geometry pointer is directly returned.", "func", ".", "restype",...
[ 28, 0 ]
[ 48, 15 ]
python
en
['en', 'error', 'th']
False
int_output
(func, argtypes, errcheck=None)
Generates a ctypes function that returns an integer value.
Generates a ctypes function that returns an integer value.
def int_output(func, argtypes, errcheck=None): "Generates a ctypes function that returns an integer value." func.argtypes = argtypes func.restype = c_int if errcheck: func.errcheck = errcheck return func
[ "def", "int_output", "(", "func", ",", "argtypes", ",", "errcheck", "=", "None", ")", ":", "func", ".", "argtypes", "=", "argtypes", "func", ".", "restype", "=", "c_int", "if", "errcheck", ":", "func", ".", "errcheck", "=", "errcheck", "return", "func" ]
[ 51, 0 ]
[ 57, 15 ]
python
en
['en', 'en', 'en']
True
int64_output
(func, argtypes)
Generates a ctypes function that returns a 64-bit integer value.
Generates a ctypes function that returns a 64-bit integer value.
def int64_output(func, argtypes): "Generates a ctypes function that returns a 64-bit integer value." func.argtypes = argtypes func.restype = c_int64 return func
[ "def", "int64_output", "(", "func", ",", "argtypes", ")", ":", "func", ".", "argtypes", "=", "argtypes", "func", ".", "restype", "=", "c_int64", "return", "func" ]
[ 60, 0 ]
[ 64, 15 ]
python
en
['en', 'en', 'en']
True
srs_output
(func, argtypes)
Generates a ctypes prototype for the given function with the given C arguments that returns a pointer to an OGR Spatial Reference System.
Generates a ctypes prototype for the given function with the given C arguments that returns a pointer to an OGR Spatial Reference System.
def srs_output(func, argtypes): """ Generates a ctypes prototype for the given function with the given C arguments that returns a pointer to an OGR Spatial Reference System. """ func.argtypes = argtypes func.restype = c_void_p func.errcheck = check_srs return func
[ "def", "srs_output", "(", "func", ",", "argtypes", ")", ":", "func", ".", "argtypes", "=", "argtypes", "func", ".", "restype", "=", "c_void_p", "func", ".", "errcheck", "=", "check_srs", "return", "func" ]
[ 67, 0 ]
[ 76, 15 ]
python
en
['en', 'error', 'th']
False
string_output
(func, argtypes, offset=-1, str_result=False, decoding=None)
Generates a ctypes prototype for the given function with the given argument types that returns a string from a GDAL pointer. The `const` flag indicates whether the allocated pointer should be freed via the GDAL library routine VSIFree -- but only applies only when `str_result` is True.
Generates a ctypes prototype for the given function with the given argument types that returns a string from a GDAL pointer. The `const` flag indicates whether the allocated pointer should be freed via the GDAL library routine VSIFree -- but only applies only when `str_result` is True.
def string_output(func, argtypes, offset=-1, str_result=False, decoding=None): """ Generates a ctypes prototype for the given function with the given argument types that returns a string from a GDAL pointer. The `const` flag indicates whether the allocated pointer should be freed via the GDAL librar...
[ "def", "string_output", "(", "func", ",", "argtypes", ",", "offset", "=", "-", "1", ",", "str_result", "=", "False", ",", "decoding", "=", "None", ")", ":", "func", ".", "argtypes", "=", "argtypes", "if", "str_result", ":", "# Use subclass of c_char_p so the...
[ 96, 0 ]
[ 121, 15 ]
python
en
['en', 'error', 'th']
False
void_output
(func, argtypes, errcheck=True, cpl=False)
For functions that don't only return an error code that needs to be examined.
For functions that don't only return an error code that needs to be examined.
def void_output(func, argtypes, errcheck=True, cpl=False): """ For functions that don't only return an error code that needs to be examined. """ if argtypes: func.argtypes = argtypes if errcheck: # `errcheck` keyword may be set to False for routines that # return void, ra...
[ "def", "void_output", "(", "func", ",", "argtypes", ",", "errcheck", "=", "True", ",", "cpl", "=", "False", ")", ":", "if", "argtypes", ":", "func", ".", "argtypes", "=", "argtypes", "if", "errcheck", ":", "# `errcheck` keyword may be set to False for routines t...
[ 124, 0 ]
[ 139, 15 ]
python
en
['en', 'error', 'th']
False
voidptr_output
(func, argtypes, errcheck=True)
For functions that return c_void_p.
For functions that return c_void_p.
def voidptr_output(func, argtypes, errcheck=True): "For functions that return c_void_p." func.argtypes = argtypes func.restype = c_void_p if errcheck: func.errcheck = check_pointer return func
[ "def", "voidptr_output", "(", "func", ",", "argtypes", ",", "errcheck", "=", "True", ")", ":", "func", ".", "argtypes", "=", "argtypes", "func", ".", "restype", "=", "c_void_p", "if", "errcheck", ":", "func", ".", "errcheck", "=", "check_pointer", "return"...
[ 142, 0 ]
[ 148, 15 ]
python
en
['en', 'en', 'en']
True
Git.get_current_branch
(cls, location)
Return the current branch, or None if HEAD isn't at a branch (e.g. detached HEAD).
Return the current branch, or None if HEAD isn't at a branch (e.g. detached HEAD).
def get_current_branch(cls, location): """ Return the current branch, or None if HEAD isn't at a branch (e.g. detached HEAD). """ # git-symbolic-ref exits with empty stdout if "HEAD" is a detached # HEAD rather than a symbolic ref. In addition, the -q causes the ...
[ "def", "get_current_branch", "(", "cls", ",", "location", ")", ":", "# git-symbolic-ref exits with empty stdout if \"HEAD\" is a detached", "# HEAD rather than a symbolic ref. In addition, the -q causes the", "# command to exit with status code 1 instead of 128 in this case", "# and to suppre...
[ 93, 4 ]
[ 111, 19 ]
python
en
['en', 'error', 'th']
False
Git.export
(self, location, url)
Export the Git repository at the url to the destination location
Export the Git repository at the url to the destination location
def export(self, location, url): # type: (str, HiddenText) -> None """Export the Git repository at the url to the destination location""" if not location.endswith('/'): location = location + '/' with TempDirectory(kind="export") as temp_dir: self.unpack(temp_dir....
[ "def", "export", "(", "self", ",", "location", ",", "url", ")", ":", "# type: (str, HiddenText) -> None", "if", "not", "location", ".", "endswith", "(", "'/'", ")", ":", "location", "=", "location", "+", "'/'", "with", "TempDirectory", "(", "kind", "=", "\...
[ 113, 4 ]
[ 124, 13 ]
python
en
['en', 'en', 'en']
True
Git.get_revision_sha
(cls, dest, rev)
Return (sha_or_none, is_branch), where sha_or_none is a commit hash if the revision names a remote branch or tag, otherwise None. Args: dest: the repository directory. rev: the revision name.
Return (sha_or_none, is_branch), where sha_or_none is a commit hash if the revision names a remote branch or tag, otherwise None.
def get_revision_sha(cls, dest, rev): """ Return (sha_or_none, is_branch), where sha_or_none is a commit hash if the revision names a remote branch or tag, otherwise None. Args: dest: the repository directory. rev: the revision name. """ # Pass rev to...
[ "def", "get_revision_sha", "(", "cls", ",", "dest", ",", "rev", ")", ":", "# Pass rev to pre-filter the list.", "output", "=", "''", "try", ":", "output", "=", "cls", ".", "run_command", "(", "[", "'show-ref'", ",", "rev", "]", ",", "cwd", "=", "dest", "...
[ 127, 4 ]
[ 164, 27 ]
python
en
['en', 'error', 'th']
False
Git._should_fetch
(cls, dest, rev)
Return true if rev is a ref or is a commit that we don't have locally. Branches and tags are not considered in this method because they are assumed to be always available locally (which is a normal outcome of ``git clone`` and ``git fetch --tags``).
Return true if rev is a ref or is a commit that we don't have locally.
def _should_fetch(cls, dest, rev): """ Return true if rev is a ref or is a commit that we don't have locally. Branches and tags are not considered in this method because they are assumed to be always available locally (which is a normal outcome of ``git clone`` and ``git fetch -...
[ "def", "_should_fetch", "(", "cls", ",", "dest", ",", "rev", ")", ":", "if", "rev", ".", "startswith", "(", "\"refs/\"", ")", ":", "# Always fetch remote refs.", "return", "True", "if", "not", "looks_like_hash", "(", "rev", ")", ":", "# Git fetch would fail wi...
[ 167, 4 ]
[ 187, 19 ]
python
en
['en', 'error', 'th']
False
Git.resolve_revision
(cls, dest, url, rev_options)
Resolve a revision to a new RevOptions object with the SHA1 of the branch, tag, or ref if found. Args: rev_options: a RevOptions object.
Resolve a revision to a new RevOptions object with the SHA1 of the branch, tag, or ref if found.
def resolve_revision(cls, dest, url, rev_options): # type: (str, HiddenText, RevOptions) -> RevOptions """ Resolve a revision to a new RevOptions object with the SHA1 of the branch, tag, or ref if found. Args: rev_options: a RevOptions object. """ rev =...
[ "def", "resolve_revision", "(", "cls", ",", "dest", ",", "url", ",", "rev_options", ")", ":", "# type: (str, HiddenText, RevOptions) -> RevOptions", "rev", "=", "rev_options", ".", "arg_rev", "# The arg_rev property's implementation for Git ensures that the", "# rev return valu...
[ 190, 4 ]
[ 232, 26 ]
python
en
['en', 'error', 'th']
False
Git.is_commit_id_equal
(cls, dest, name)
Return whether the current commit hash equals the given name. Args: dest: the repository directory. name: a string name.
Return whether the current commit hash equals the given name.
def is_commit_id_equal(cls, dest, name): """ Return whether the current commit hash equals the given name. Args: dest: the repository directory. name: a string name. """ if not name: # Then avoid an unnecessary subprocess call. return ...
[ "def", "is_commit_id_equal", "(", "cls", ",", "dest", ",", "name", ")", ":", "if", "not", "name", ":", "# Then avoid an unnecessary subprocess call.", "return", "False", "return", "cls", ".", "get_revision", "(", "dest", ")", "==", "name" ]
[ 235, 4 ]
[ 247, 45 ]
python
en
['en', 'error', 'th']
False
Git.get_remote_url
(cls, location)
Return URL of the first remote encountered. Raises RemoteNotFoundError if the repository does not have a remote url configured.
Return URL of the first remote encountered.
def get_remote_url(cls, location): """ Return URL of the first remote encountered. Raises RemoteNotFoundError if the repository does not have a remote url configured. """ # We need to pass 1 for extra_ok_returncodes since the command # exits with return code 1 if...
[ "def", "get_remote_url", "(", "cls", ",", "location", ")", ":", "# We need to pass 1 for extra_ok_returncodes since the command", "# exits with return code 1 if there are no matching lines.", "stdout", "=", "cls", ".", "run_command", "(", "[", "'config'", ",", "'--get-regexp'",...
[ 306, 4 ]
[ 330, 26 ]
python
en
['en', 'error', 'th']
False
Git.has_commit
(cls, location, rev)
Check if rev is a commit that is available in the local repository.
Check if rev is a commit that is available in the local repository.
def has_commit(cls, location, rev): """ Check if rev is a commit that is available in the local repository. """ try: cls.run_command( ['rev-parse', '-q', '--verify', "sha^" + rev], cwd=location ) except SubProcessError: return F...
[ "def", "has_commit", "(", "cls", ",", "location", ",", "rev", ")", ":", "try", ":", "cls", ".", "run_command", "(", "[", "'rev-parse'", ",", "'-q'", ",", "'--verify'", ",", "\"sha^\"", "+", "rev", "]", ",", "cwd", "=", "location", ")", "except", "Sub...
[ 333, 4 ]
[ 344, 23 ]
python
en
['en', 'error', 'th']
False
Git.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): """ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. """ # find the repo root git_dir = cls.run_command( ['rev-parse', '--git-dir'], cwd=location).strip() ...
[ "def", "get_subdirectory", "(", "cls", ",", "location", ")", ":", "# find the repo root", "git_dir", "=", "cls", ".", "run_command", "(", "[", "'rev-parse'", ",", "'--git-dir'", "]", ",", "cwd", "=", "location", ")", ".", "strip", "(", ")", "if", "not", ...
[ 356, 4 ]
[ 368, 69 ]
python
en
['en', 'error', 'th']
False
Git.get_url_rev_and_auth
(cls, url)
Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'. That's required because although they use SSH they sometimes don't work with a ssh:// scheme (e.g. GitHub). But we need a scheme for parsing. Hence we remove it again afterwards and return it as a stub.
Prefixes stub URLs like 'user
def get_url_rev_and_auth(cls, url): # type: (str) -> Tuple[str, Optional[str], AuthInfo] """ Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'. That's required because although they use SSH they sometimes don't work with a ssh:// scheme (e.g. GitHub). But we nee...
[ "def", "get_url_rev_and_auth", "(", "cls", ",", "url", ")", ":", "# type: (str) -> Tuple[str, Optional[str], AuthInfo]", "# Works around an apparent Git bug", "# (see https://article.gmane.org/gmane.comp.version-control.git/146500)", "scheme", ",", "netloc", ",", "path", ",", "quer...
[ 371, 4 ]
[ 402, 34 ]
python
en
['en', 'error', 'th']
False
finder
(package)
Return a resource finder for a package. :param package: The name of the package. :return: A :class:`ResourceFinder` instance for the package.
Return a resource finder for a package. :param package: The name of the package. :return: A :class:`ResourceFinder` instance for the package.
def finder(package): """ Return a resource finder for a package. :param package: The name of the package. :return: A :class:`ResourceFinder` instance for the package. """ if package in _finder_cache: result = _finder_cache[package] else: if package not in sys.modules: ...
[ "def", "finder", "(", "package", ")", ":", "if", "package", "in", "_finder_cache", ":", "result", "=", "_finder_cache", "[", "package", "]", "else", ":", "if", "package", "not", "in", "sys", ".", "modules", ":", "__import__", "(", "package", ")", "module...
[ 309, 0 ]
[ 331, 17 ]
python
en
['en', 'error', 'th']
False
finder_for_path
(path)
Return a resource finder for a path, which should represent a container. :param path: The path. :return: A :class:`ResourceFinder` instance for the path.
Return a resource finder for a path, which should represent a container.
def finder_for_path(path): """ Return a resource finder for a path, which should represent a container. :param path: The path. :return: A :class:`ResourceFinder` instance for the path. """ result = None # calls any path hooks, gets importer into cache pkgutil.get_importer(path) load...
[ "def", "finder_for_path", "(", "path", ")", ":", "result", "=", "None", "# calls any path hooks, gets importer into cache", "pkgutil", ".", "get_importer", "(", "path", ")", "loader", "=", "sys", ".", "path_importer_cache", ".", "get", "(", "path", ")", "finder", ...
[ 337, 0 ]
[ 354, 17 ]
python
en
['en', 'error', 'th']
False
ResourceCache.is_stale
(self, resource, path)
Is the cache stale for the given resource? :param resource: The :class:`Resource` being cached. :param path: The path of the resource in the cache. :return: True if the cache is stale.
Is the cache stale for the given resource?
def is_stale(self, resource, path): """ Is the cache stale for the given resource? :param resource: The :class:`Resource` being cached. :param path: The path of the resource in the cache. :return: True if the cache is stale. """ # Cache invalidation is a hard pro...
[ "def", "is_stale", "(", "self", ",", "resource", ",", "path", ")", ":", "# Cache invalidation is a hard problem :-)", "return", "True" ]
[ 34, 4 ]
[ 43, 19 ]
python
en
['en', 'error', 'th']
False
ResourceCache.get
(self, resource)
Get a resource into the cache, :param resource: A :class:`Resource` instance. :return: The pathname of the resource in the cache.
Get a resource into the cache,
def get(self, resource): """ Get a resource into the cache, :param resource: A :class:`Resource` instance. :return: The pathname of the resource in the cache. """ prefix, path = resource.finder.get_cache_info(resource) if prefix is None: result = path...
[ "def", "get", "(", "self", ",", "resource", ")", ":", "prefix", ",", "path", "=", "resource", ".", "finder", ".", "get_cache_info", "(", "resource", ")", "if", "prefix", "is", "None", ":", "result", "=", "path", "else", ":", "result", "=", "os", ".",...
[ 45, 4 ]
[ 68, 21 ]
python
en
['en', 'error', 'th']
False
Resource.as_stream
(self)
Get the resource as a stream. This is not a property to make it obvious that it returns a new stream each time.
Get the resource as a stream.
def as_stream(self): """ Get the resource as a stream. This is not a property to make it obvious that it returns a new stream each time. """ return self.finder.get_stream(self)
[ "def", "as_stream", "(", "self", ")", ":", "return", "self", ".", "finder", ".", "get_stream", "(", "self", ")" ]
[ 85, 4 ]
[ 92, 43 ]
python
en
['en', 'error', 'th']
False
WagtailTestUtils.create_test_user
()
Override this method to return an instance of your custom user model
Override this method to return an instance of your custom user model
def create_test_user(): """ Override this method to return an instance of your custom user model """ user_model = get_user_model() # Create a user user_data = dict() user_data[user_model.USERNAME_FIELD] = 'test@email.com' user_data['email'] = 'test@email.c...
[ "def", "create_test_user", "(", ")", ":", "user_model", "=", "get_user_model", "(", ")", "# Create a user", "user_data", "=", "dict", "(", ")", "user_data", "[", "user_model", ".", "USERNAME_FIELD", "]", "=", "'test@email.com'", "user_data", "[", "'email'", "]",...
[ 11, 4 ]
[ 26, 63 ]
python
en
['en', 'error', 'th']
False
handle_var
(value, context)
Handle template tag variable.
Handle template tag variable.
def handle_var(value, context): """Handle template tag variable.""" # Resolve FilterExpression and Variable immediately if isinstance(value, FilterExpression) or isinstance(value, Variable): return value.resolve(context) # Return quoted strings unquoted # http://djangosnippets.org/snippets/8...
[ "def", "handle_var", "(", "value", ",", "context", ")", ":", "# Resolve FilterExpression and Variable immediately", "if", "isinstance", "(", "value", ",", "FilterExpression", ")", "or", "isinstance", "(", "value", ",", "Variable", ")", ":", "return", "value", ".",...
[ 19, 0 ]
[ 33, 20 ]
python
en
['nl', 'en', 'en']
True
parse_token_contents
(parser, token)
Parse template tag contents.
Parse template tag contents.
def parse_token_contents(parser, token): """Parse template tag contents.""" bits = token.split_contents() tag = bits.pop(0) args = [] kwargs = {} asvar = None if len(bits) >= 2 and bits[-2] == "as": asvar = bits[-1] bits = bits[:-2] for bit in bits: match = kwarg_...
[ "def", "parse_token_contents", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "tag", "=", "bits", ".", "pop", "(", "0", ")", "args", "=", "[", "]", "kwargs", "=", "{", "}", "asvar", "=", "None", "if", ...
[ 36, 0 ]
[ 55, 71 ]
python
en
['de', 'en', 'en']
True
split_css_classes
(css_classes)
Turn string into a list of CSS classes.
Turn string into a list of CSS classes.
def split_css_classes(css_classes): """Turn string into a list of CSS classes.""" classes_list = text_value(css_classes).split(" ") return [c for c in classes_list if c]
[ "def", "split_css_classes", "(", "css_classes", ")", ":", "classes_list", "=", "text_value", "(", "css_classes", ")", ".", "split", "(", "\" \"", ")", "return", "[", "c", "for", "c", "in", "classes_list", "if", "c", "]" ]
[ 58, 0 ]
[ 61, 41 ]
python
en
['en', 'en', 'en']
True
add_css_class
(css_classes, css_class, prepend=False)
Add a CSS class to a string of CSS classes.
Add a CSS class to a string of CSS classes.
def add_css_class(css_classes, css_class, prepend=False): """Add a CSS class to a string of CSS classes.""" classes_list = split_css_classes(css_classes) classes_to_add = [c for c in split_css_classes(css_class) if c not in classes_list] if prepend: classes_list = classes_to_add + classes_list ...
[ "def", "add_css_class", "(", "css_classes", ",", "css_class", ",", "prepend", "=", "False", ")", ":", "classes_list", "=", "split_css_classes", "(", "css_classes", ")", "classes_to_add", "=", "[", "c", "for", "c", "in", "split_css_classes", "(", "css_class", "...
[ 64, 0 ]
[ 72, 33 ]
python
en
['en', 'en', 'en']
True
remove_css_class
(css_classes, css_class)
Remove a CSS class from a string of CSS classes.
Remove a CSS class from a string of CSS classes.
def remove_css_class(css_classes, css_class): """Remove a CSS class from a string of CSS classes.""" remove = set(split_css_classes(css_class)) classes_list = [c for c in split_css_classes(css_classes) if c not in remove] return " ".join(classes_list)
[ "def", "remove_css_class", "(", "css_classes", ",", "css_class", ")", ":", "remove", "=", "set", "(", "split_css_classes", "(", "css_class", ")", ")", "classes_list", "=", "[", "c", "for", "c", "in", "split_css_classes", "(", "css_classes", ")", "if", "c", ...
[ 75, 0 ]
[ 79, 33 ]
python
en
['en', 'en', 'en']
True
render_script_tag
(url)
Build a script tag.
Build a script tag.
def render_script_tag(url): """Build a script tag.""" url_dict = url_to_attrs_dict(url, url_attr="src") return render_tag("script", url_dict)
[ "def", "render_script_tag", "(", "url", ")", ":", "url_dict", "=", "url_to_attrs_dict", "(", "url", ",", "url_attr", "=", "\"src\"", ")", "return", "render_tag", "(", "\"script\"", ",", "url_dict", ")" ]
[ 82, 0 ]
[ 85, 41 ]
python
en
['en', 'ca', 'en']
True
render_link_tag
(url, rel="stylesheet", media=None)
Build a link tag.
Build a link tag.
def render_link_tag(url, rel="stylesheet", media=None): """Build a link tag.""" url_dict = url_to_attrs_dict(url, url_attr="href") url_dict.setdefault("href", url_dict.pop("url", None)) url_dict["rel"] = rel if media: url_dict["media"] = media return render_tag("link", attrs=url_dict, cl...
[ "def", "render_link_tag", "(", "url", ",", "rel", "=", "\"stylesheet\"", ",", "media", "=", "None", ")", ":", "url_dict", "=", "url_to_attrs_dict", "(", "url", ",", "url_attr", "=", "\"href\"", ")", "url_dict", ".", "setdefault", "(", "\"href\"", ",", "url...
[ 88, 0 ]
[ 95, 58 ]
python
en
['en', 'en', 'en']
True
render_tag
(tag, attrs=None, content=None, close=True)
Render a HTML tag.
Render a HTML tag.
def render_tag(tag, attrs=None, content=None, close=True): """Render a HTML tag.""" builder = "<{tag}{attrs}>{content}" if content or close: builder += "</{tag}>" return format_html(builder, tag=tag, attrs=mark_safe(flatatt(attrs)) if attrs else "", content=text_value(content))
[ "def", "render_tag", "(", "tag", ",", "attrs", "=", "None", ",", "content", "=", "None", ",", "close", "=", "True", ")", ":", "builder", "=", "\"<{tag}{attrs}>{content}\"", "if", "content", "or", "close", ":", "builder", "+=", "\"</{tag}>\"", "return", "fo...
[ 98, 0 ]
[ 103, 119 ]
python
en
['en', 'en', 'en']
True
render_template_file
(template, context=None)
Render a Template to unicode.
Render a Template to unicode.
def render_template_file(template, context=None): """Render a Template to unicode.""" template = get_template(template) return template.render(context)
[ "def", "render_template_file", "(", "template", ",", "context", "=", "None", ")", ":", "template", "=", "get_template", "(", "template", ")", "return", "template", ".", "render", "(", "context", ")" ]
[ 106, 0 ]
[ 109, 35 ]
python
en
['en', 'en', 'en']
True
url_replace_param
(url, name, value)
Replace a GET parameter in an URL.
Replace a GET parameter in an URL.
def url_replace_param(url, name, value): """Replace a GET parameter in an URL.""" url_components = urlparse(force_str(url)) query_params = parse_qs(url_components.query) query_params[name] = value query = urlencode(query_params, doseq=True) return force_str( urlunparse( [ ...
[ "def", "url_replace_param", "(", "url", ",", "name", ",", "value", ")", ":", "url_components", "=", "urlparse", "(", "force_str", "(", "url", ")", ")", "query_params", "=", "parse_qs", "(", "url_components", ".", "query", ")", "query_params", "[", "name", ...
[ 112, 0 ]
[ 129, 5 ]
python
en
['en', 'en', 'en']
True
url_to_attrs_dict
(url, url_attr)
Sanitize url dict as used in django-bootstrap3 settings.
Sanitize url dict as used in django-bootstrap3 settings.
def url_to_attrs_dict(url, url_attr): """Sanitize url dict as used in django-bootstrap3 settings.""" result = dict() # If url is not a string, it should be a dict if isinstance(url, str): url_value = url else: try: url_value = url["url"] except TypeError: ...
[ "def", "url_to_attrs_dict", "(", "url", ",", "url_attr", ")", ":", "result", "=", "dict", "(", ")", "# If url is not a string, it should be a dict", "if", "isinstance", "(", "url", ",", "str", ")", ":", "url_value", "=", "url", "else", ":", "try", ":", "url_...
[ 132, 0 ]
[ 150, 17 ]
python
en
['en', 'en', 'en']
True
workflow_dag_1
(wf_node_generator)
r''' 0 /\ S / \ / \ 1 | | | F | | S | | 3 | \ | F \ | \/ 2
r''' 0 /\ S / \ / \ 1 | | | F | | S | | 3 | \ | F \ | \/ 2
def workflow_dag_1(wf_node_generator): g = WorkflowDAG() nodes = [wf_node_generator() for i in range(4)] for n in nodes: g.add_node(n) r''' 0 /\ S / \ / \ 1 | | | F | | S | | 3 | \ ...
[ "def", "workflow_dag_1", "(", "wf_node_generator", ")", ":", "g", "=", "WorkflowDAG", "(", ")", "nodes", "=", "[", "wf_node_generator", "(", ")", "for", "i", "in", "range", "(", "4", ")", "]", "for", "n", "in", "nodes", ":", "g", ".", "add_node", "("...
[ 37, 0 ]
[ 62, 21 ]
python
cy
['en', 'cy', 'hi']
False
TestWorkflowDAG.workflow_dag_root_children
(self, wf_node_generator)
Pair up a root node with a single child via an edge R1 R2 ... Rx | | | | | | C1 C2 Cx
Pair up a root node with a single child via an edge
def workflow_dag_root_children(self, wf_node_generator): g = WorkflowDAG() wf_root_nodes = [wf_node_generator() for i in range(0, 10)] wf_leaf_nodes = [wf_node_generator() for i in range(0, 10)] for n in wf_root_nodes + wf_leaf_nodes: g.add_node(n) ''' Pair ...
[ "def", "workflow_dag_root_children", "(", "self", ",", "wf_node_generator", ")", ":", "g", "=", "WorkflowDAG", "(", ")", "wf_root_nodes", "=", "[", "wf_node_generator", "(", ")", "for", "i", "in", "range", "(", "0", ",", "10", ")", "]", "wf_leaf_nodes", "=...
[ 67, 4 ]
[ 85, 48 ]
python
en
['en', 'error', 'th']
False
TestDNR.test_mark_dnr_nodes
(self, workflow_dag_1)
r''' 0 /\ S / \ / \ 1 | | | F | | S | | 3 | \ | F \ | \/ 2
r''' 0 /\ S / \ / \ 1 | | | F | | S | | 3 | \ | F \ | \/ 2
def test_mark_dnr_nodes(self, workflow_dag_1): (g, nodes) = workflow_dag_1 r''' 0 /\ S / \ / \ 1 | | | F | | S | | 3 | \ | F \ | ...
[ "def", "test_mark_dnr_nodes", "(", "self", ",", "workflow_dag_1", ")", ":", "(", "g", ",", "nodes", ")", "=", "workflow_dag_1", "nodes", "[", "0", "]", ".", "job", "=", "Job", "(", "status", "=", "'successful'", ")", "do_not_run_nodes", "=", "g", ".", ...
[ 93, 4 ]
[ 133, 46 ]
python
cy
['en', 'cy', 'hi']
False
TestAllWorkflowNodes.workflow_all_converge_1
(self, wf_node_generator)
r''' 0 |\ F | \ S| 1 | / |/ A 2
r''' 0 |\ F | \ S| 1 | / |/ A 2
def workflow_all_converge_1(self, wf_node_generator): g = WorkflowDAG() nodes = [wf_node_generator() for i in range(3)] for n in nodes: g.add_node(n) r''' 0 |\ F | \ S| 1 | / |/ A ...
[ "def", "workflow_all_converge_1", "(", "self", ",", "wf_node_generator", ")", ":", "g", "=", "WorkflowDAG", "(", ")", "nodes", "=", "[", "wf_node_generator", "(", ")", "for", "i", "in", "range", "(", "3", ")", "]", "for", "n", "in", "nodes", ":", "g", ...
[ 177, 4 ]
[ 196, 25 ]
python
cy
['en', 'cy', 'hi']
False
TestAllWorkflowNodes.workflow_all_converge_2
(self, wf_node_generator)
The ordering of _1 and this test, _2, is _slightly_ different. The hope is that topological sorting results in 2 being processed before 3 and/or 3 before 2.
The ordering of _1 and this test, _2, is _slightly_ different. The hope is that topological sorting results in 2 being processed before 3 and/or 3 before 2.
def workflow_all_converge_2(self, wf_node_generator): """The ordering of _1 and this test, _2, is _slightly_ different. The hope is that topological sorting results in 2 being processed before 3 and/or 3 before 2. """ g = WorkflowDAG() nodes = [wf_node_generator() for i i...
[ "def", "workflow_all_converge_2", "(", "self", ",", "wf_node_generator", ")", ":", "g", "=", "WorkflowDAG", "(", ")", "nodes", "=", "[", "wf_node_generator", "(", ")", "for", "i", "in", "range", "(", "3", ")", "]", "for", "n", "in", "nodes", ":", "g", ...
[ 209, 4 ]
[ 232, 25 ]
python
en
['en', 'en', 'en']
True
TestAllWorkflowNodes.workflow_all_converge_will_run
(self, wf_node_generator)
r''' 0 1 2 S \ F | / S \ | / \ | / \|/ | 3
r''' 0 1 2 S \ F | / S \ | / \ | / \|/ | 3
def workflow_all_converge_will_run(self, wf_node_generator): g = WorkflowDAG() nodes = [wf_node_generator() for i in range(4)] for n in nodes: g.add_node(n) r''' 0 1 2 S \ F | / S \ | / \ | / ...
[ "def", "workflow_all_converge_will_run", "(", "self", ",", "wf_node_generator", ")", ":", "g", "=", "WorkflowDAG", "(", ")", "nodes", "=", "[", "wf_node_generator", "(", ")", "for", "i", "in", "range", "(", "4", ")", "]", "for", "n", "in", "nodes", ":", ...
[ 245, 4 ]
[ 267, 25 ]
python
cy
['en', 'cy', 'hi']
False