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
parse_date
(value)
Parse one of the following date formats into a datetime object: .. sourcecode:: text Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format If parsing fail...
Parse one of the following date formats into a datetime object:
def parse_date(value): """Parse one of the following date formats into a datetime object: .. sourcecode:: text Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime...
[ "def", "parse_date", "(", "value", ")", ":", "if", "value", ":", "t", "=", "parsedate_tz", "(", "value", ".", "strip", "(", ")", ")", "if", "t", "is", "not", "None", ":", "try", ":", "year", "=", "t", "[", "0", "]", "# unfortunately that function doe...
[ 779, 0 ]
[ 808, 27 ]
python
en
['en', 'en', 'en']
True
_dump_date
(d, delim)
Used for `http_date` and `cookie_date`.
Used for `http_date` and `cookie_date`.
def _dump_date(d, delim): """Used for `http_date` and `cookie_date`.""" if d is None: d = gmtime() elif isinstance(d, datetime): d = d.utctimetuple() elif isinstance(d, (integer_types, float)): d = gmtime(d) return "%s, %02d%s%s%s%s %02d:%02d:%02d GMT" % ( ("Mon", "Tu...
[ "def", "_dump_date", "(", "d", ",", "delim", ")", ":", "if", "d", "is", "None", ":", "d", "=", "gmtime", "(", ")", "elif", "isinstance", "(", "d", ",", "datetime", ")", ":", "d", "=", "d", ".", "utctimetuple", "(", ")", "elif", "isinstance", "(",...
[ 811, 0 ]
[ 842, 5 ]
python
en
['en', 'en', 'en']
True
cookie_date
(expires=None)
Formats the time to ensure compatibility with Netscape's cookie standard. Accepts a floating point number expressed in seconds since the epoch in, a datetime object or a timetuple. All times in UTC. The :func:`parse_date` function can be used to parse such a date. Outputs a string in the format ...
Formats the time to ensure compatibility with Netscape's cookie standard.
def cookie_date(expires=None): """Formats the time to ensure compatibility with Netscape's cookie standard. Accepts a floating point number expressed in seconds since the epoch in, a datetime object or a timetuple. All times in UTC. The :func:`parse_date` function can be used to parse such a date...
[ "def", "cookie_date", "(", "expires", "=", "None", ")", ":", "return", "_dump_date", "(", "expires", ",", "\"-\"", ")" ]
[ 845, 0 ]
[ 857, 35 ]
python
en
['en', 'en', 'en']
True
http_date
(timestamp=None)
Formats the time to match the RFC1123 date format. Accepts a floating point number expressed in seconds since the epoch in, a datetime object or a timetuple. All times in UTC. The :func:`parse_date` function can be used to parse such a date. Outputs a string in the format ``Wdy, DD Mon YYYY HH:MM:SS...
Formats the time to match the RFC1123 date format.
def http_date(timestamp=None): """Formats the time to match the RFC1123 date format. Accepts a floating point number expressed in seconds since the epoch in, a datetime object or a timetuple. All times in UTC. The :func:`parse_date` function can be used to parse such a date. Outputs a string in ...
[ "def", "http_date", "(", "timestamp", "=", "None", ")", ":", "return", "_dump_date", "(", "timestamp", ",", "\" \"", ")" ]
[ 860, 0 ]
[ 871, 37 ]
python
en
['en', 'en', 'en']
True
parse_age
(value=None)
Parses a base-10 integer count of seconds into a timedelta. If parsing fails, the return value is `None`. :param value: a string consisting of an integer represented in base-10 :return: a :class:`datetime.timedelta` object or `None`.
Parses a base-10 integer count of seconds into a timedelta.
def parse_age(value=None): """Parses a base-10 integer count of seconds into a timedelta. If parsing fails, the return value is `None`. :param value: a string consisting of an integer represented in base-10 :return: a :class:`datetime.timedelta` object or `None`. """ if not value: retu...
[ "def", "parse_age", "(", "value", "=", "None", ")", ":", "if", "not", "value", ":", "return", "None", "try", ":", "seconds", "=", "int", "(", "value", ")", "except", "ValueError", ":", "return", "None", "if", "seconds", "<", "0", ":", "return", "None...
[ 874, 0 ]
[ 893, 19 ]
python
en
['en', 'en', 'en']
True
dump_age
(age=None)
Formats the duration as a base-10 integer. :param age: should be an integer number of seconds, a :class:`datetime.timedelta` object, or, if the age is unknown, `None` (default).
Formats the duration as a base-10 integer.
def dump_age(age=None): """Formats the duration as a base-10 integer. :param age: should be an integer number of seconds, a :class:`datetime.timedelta` object, or, if the age is unknown, `None` (default). """ if age is None: return if isinstance(age, timedelt...
[ "def", "dump_age", "(", "age", "=", "None", ")", ":", "if", "age", "is", "None", ":", "return", "if", "isinstance", "(", "age", ",", "timedelta", ")", ":", "# do the equivalent of Python 2.7's timedelta.total_seconds(),", "# but disregarding fractional seconds", "age"...
[ 896, 0 ]
[ 914, 19 ]
python
en
['en', 'en', 'en']
True
is_resource_modified
( environ, etag=None, data=None, last_modified=None, ignore_if_range=True )
Convenience method for conditional requests. :param environ: the WSGI environment of the request to be checked. :param etag: the etag for the response for comparison. :param data: or alternatively the data of the response to automatically generate an etag using :func:`generate_etag`. :...
Convenience method for conditional requests.
def is_resource_modified( environ, etag=None, data=None, last_modified=None, ignore_if_range=True ): """Convenience method for conditional requests. :param environ: the WSGI environment of the request to be checked. :param etag: the etag for the response for comparison. :param data: or alternativel...
[ "def", "is_resource_modified", "(", "environ", ",", "etag", "=", "None", ",", "data", "=", "None", ",", "last_modified", "=", "None", ",", "ignore_if_range", "=", "True", ")", ":", "if", "etag", "is", "None", "and", "data", "is", "not", "None", ":", "e...
[ 917, 0 ]
[ 981, 25 ]
python
en
['en', 'en', 'en']
True
remove_entity_headers
(headers, allowed=("expires", "content-location"))
Remove all entity headers from a list or :class:`Headers` object. This operation works in-place. `Expires` and `Content-Location` headers are by default not removed. The reason for this is :rfc:`2616` section 10.3.5 which specifies some entity headers that should be sent. .. versionchanged:: 0.5 ...
Remove all entity headers from a list or :class:`Headers` object. This operation works in-place. `Expires` and `Content-Location` headers are by default not removed. The reason for this is :rfc:`2616` section 10.3.5 which specifies some entity headers that should be sent.
def remove_entity_headers(headers, allowed=("expires", "content-location")): """Remove all entity headers from a list or :class:`Headers` object. This operation works in-place. `Expires` and `Content-Location` headers are by default not removed. The reason for this is :rfc:`2616` section 10.3.5 which...
[ "def", "remove_entity_headers", "(", "headers", ",", "allowed", "=", "(", "\"expires\"", ",", "\"content-location\"", ")", ")", ":", "allowed", "=", "set", "(", "x", ".", "lower", "(", ")", "for", "x", "in", "allowed", ")", "headers", "[", ":", "]", "=...
[ 984, 0 ]
[ 1002, 5 ]
python
en
['en', 'en', 'en']
True
remove_hop_by_hop_headers
(headers)
Remove all HTTP/1.1 "Hop-by-Hop" headers from a list or :class:`Headers` object. This operation works in-place. .. versionadded:: 0.5 :param headers: a list or :class:`Headers` object.
Remove all HTTP/1.1 "Hop-by-Hop" headers from a list or :class:`Headers` object. This operation works in-place.
def remove_hop_by_hop_headers(headers): """Remove all HTTP/1.1 "Hop-by-Hop" headers from a list or :class:`Headers` object. This operation works in-place. .. versionadded:: 0.5 :param headers: a list or :class:`Headers` object. """ headers[:] = [ (key, value) for key, value in headers...
[ "def", "remove_hop_by_hop_headers", "(", "headers", ")", ":", "headers", "[", ":", "]", "=", "[", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "headers", "if", "not", "is_hop_by_hop_header", "(", "key", ")", "]" ]
[ 1005, 0 ]
[ 1015, 5 ]
python
en
['en', 'en', 'en']
True
is_entity_header
(header)
Check if a header is an entity header. .. versionadded:: 0.5 :param header: the header to test. :return: `True` if it's an entity header, `False` otherwise.
Check if a header is an entity header.
def is_entity_header(header): """Check if a header is an entity header. .. versionadded:: 0.5 :param header: the header to test. :return: `True` if it's an entity header, `False` otherwise. """ return header.lower() in _entity_headers
[ "def", "is_entity_header", "(", "header", ")", ":", "return", "header", ".", "lower", "(", ")", "in", "_entity_headers" ]
[ 1018, 0 ]
[ 1026, 44 ]
python
en
['en', 'en', 'en']
True
is_hop_by_hop_header
(header)
Check if a header is an HTTP/1.1 "Hop-by-Hop" header. .. versionadded:: 0.5 :param header: the header to test. :return: `True` if it's an HTTP/1.1 "Hop-by-Hop" header, `False` otherwise.
Check if a header is an HTTP/1.1 "Hop-by-Hop" header.
def is_hop_by_hop_header(header): """Check if a header is an HTTP/1.1 "Hop-by-Hop" header. .. versionadded:: 0.5 :param header: the header to test. :return: `True` if it's an HTTP/1.1 "Hop-by-Hop" header, `False` otherwise. """ return header.lower() in _hop_by_hop_headers
[ "def", "is_hop_by_hop_header", "(", "header", ")", ":", "return", "header", ".", "lower", "(", ")", "in", "_hop_by_hop_headers" ]
[ 1029, 0 ]
[ 1037, 48 ]
python
en
['en', 'en', 'en']
True
parse_cookie
(header, charset="utf-8", errors="replace", cls=None)
Parse a cookie. Either from a string or WSGI environ. Per default encoding errors are ignored. If you want a different behavior you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a :exc:`HTTPUnicodeError` is raised. .. versionchanged:: 0.5 This function now returns a :clas...
Parse a cookie. Either from a string or WSGI environ.
def parse_cookie(header, charset="utf-8", errors="replace", cls=None): """Parse a cookie. Either from a string or WSGI environ. Per default encoding errors are ignored. If you want a different behavior you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a :exc:`HTTPUnicodeError` is...
[ "def", "parse_cookie", "(", "header", ",", "charset", "=", "\"utf-8\"", ",", "errors", "=", "\"replace\"", ",", "cls", "=", "None", ")", ":", "if", "isinstance", "(", "header", ",", "dict", ")", ":", "header", "=", "header", ".", "get", "(", "\"HTTP_CO...
[ 1040, 0 ]
[ 1082, 30 ]
python
en
['en', 'en', 'en']
True
dump_cookie
( key, value="", max_age=None, expires=None, path="/", domain=None, secure=False, httponly=False, charset="utf-8", sync_expires=True, max_size=4093, samesite=None, )
Creates a new Set-Cookie header without the ``Set-Cookie`` prefix The parameters are the same as in the cookie Morsel object in the Python standard library but it accepts unicode data, too. On Python 3 the return value of this function will be a unicode string, on Python 2 it will be a native string. ...
Creates a new Set-Cookie header without the ``Set-Cookie`` prefix The parameters are the same as in the cookie Morsel object in the Python standard library but it accepts unicode data, too.
def dump_cookie( key, value="", max_age=None, expires=None, path="/", domain=None, secure=False, httponly=False, charset="utf-8", sync_expires=True, max_size=4093, samesite=None, ): """Creates a new Set-Cookie header without the ``Set-Cookie`` prefix The parameter...
[ "def", "dump_cookie", "(", "key", ",", "value", "=", "\"\"", ",", "max_age", "=", "None", ",", "expires", "=", "None", ",", "path", "=", "\"/\"", ",", "domain", "=", "None", ",", "secure", "=", "False", ",", "httponly", "=", "False", ",", "charset", ...
[ 1085, 0 ]
[ 1220, 13 ]
python
en
['en', 'en', 'en']
True
is_byte_range_valid
(start, stop, length)
Checks if a given byte content range is valid for the given length. .. versionadded:: 0.7
Checks if a given byte content range is valid for the given length.
def is_byte_range_valid(start, stop, length): """Checks if a given byte content range is valid for the given length. .. versionadded:: 0.7 """ if (start is None) != (stop is None): return False elif start is None: return length is None or length >= 0 elif length is None: ...
[ "def", "is_byte_range_valid", "(", "start", ",", "stop", ",", "length", ")", ":", "if", "(", "start", "is", "None", ")", "!=", "(", "stop", "is", "None", ")", ":", "return", "False", "elif", "start", "is", "None", ":", "return", "length", "is", "None...
[ 1223, 0 ]
[ 1236, 30 ]
python
en
['en', 'en', 'en']
True
OracleGeometryColumns.table_name_col
(cls)
Return the name of the metadata column used to store the feature table name.
Return the name of the metadata column used to store the feature table name.
def table_name_col(cls): """ Return the name of the metadata column used to store the feature table name. """ return 'table_name'
[ "def", "table_name_col", "(", "cls", ")", ":", "return", "'table_name'" ]
[ 29, 4 ]
[ 34, 27 ]
python
en
['en', 'error', 'th']
False
OracleGeometryColumns.geom_col_name
(cls)
Return the name of the metadata column used to store the feature geometry column.
Return the name of the metadata column used to store the feature geometry column.
def geom_col_name(cls): """ Return the name of the metadata column used to store the feature geometry column. """ return 'column_name'
[ "def", "geom_col_name", "(", "cls", ")", ":", "return", "'column_name'" ]
[ 37, 4 ]
[ 42, 28 ]
python
en
['en', 'error', 'th']
False
install_editable
( install_options, # type: List[str] global_options, # type: Sequence[str] prefix, # type: Optional[str] home, # type: Optional[str] use_user_site, # type: bool name, # type: str setup_py_path, # type: str isolated, # type: bool build_env, # type: BuildEnvironment unpack...
Install a package in editable mode. Most arguments are pass-through to setuptools.
Install a package in editable mode. Most arguments are pass-through to setuptools.
def install_editable( install_options, # type: List[str] global_options, # type: Sequence[str] prefix, # type: Optional[str] home, # type: Optional[str] use_user_site, # type: bool name, # type: str setup_py_path, # type: str isolated, # type: bool build_env, # type: BuildEn...
[ "def", "install_editable", "(", "install_options", ",", "# type: List[str]", "global_options", ",", "# type: Sequence[str]", "prefix", ",", "# type: Optional[str]", "home", ",", "# type: Optional[str]", "use_user_site", ",", "# type: bool", "name", ",", "# type: str", "setu...
[ 13, 0 ]
[ 46, 13 ]
python
en
['en', 'en', 'en']
True
_dnsname_match
(dn, hostname, max_wildcards=1)
Matching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3
Matching according to RFC 6125, section 6.4.3
def _dnsname_match(dn, hostname, max_wildcards=1): """Matching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 """ pats = [] if not dn: return False # Ported from python3-syntax: # leftmost, *remainder = dn.split(r'.') parts = dn.split(r"."...
[ "def", "_dnsname_match", "(", "dn", ",", "hostname", ",", "max_wildcards", "=", "1", ")", ":", "pats", "=", "[", "]", "if", "not", "dn", ":", "return", "False", "# Ported from python3-syntax:", "# leftmost, *remainder = dn.split(r'.')", "parts", "=", "dn", ".", ...
[ 24, 0 ]
[ 75, 30 ]
python
en
['en', 'en', 'en']
True
_ipaddress_match
(ipname, host_ip)
Exact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope").
Exact matching of IP addresses.
def _ipaddress_match(ipname, host_ip): """Exact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope"). """ # OpenSSL may add a trailing newline to a subjectAltName's IP address # Divergence from upstream: ipaddress can't handle byte ...
[ "def", "_ipaddress_match", "(", "ipname", ",", "host_ip", ")", ":", "# OpenSSL may add a trailing newline to a subjectAltName's IP address", "# Divergence from upstream: ipaddress can't handle byte str", "ip", "=", "ipaddress", ".", "ip_address", "(", "_to_unicode", "(", "ipname"...
[ 84, 0 ]
[ 93, 24 ]
python
en
['en', 'sn', 'en']
True
match_hostname
(cert, hostname)
Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function returns nothing.
Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*.
def match_hostname(cert, hostname): """Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function r...
[ "def", "match_hostname", "(", "cert", ",", "hostname", ")", ":", "if", "not", "cert", ":", "raise", "ValueError", "(", "\"empty or no certificate, match_hostname needs a \"", "\"SSL socket or SSL context with either \"", "\"CERT_OPTIONAL or CERT_REQUIRED\"", ")", "try", ":", ...
[ 96, 0 ]
[ 159, 9 ]
python
en
['en', 'en', 'en']
True
vary_on_headers
(*headers)
A view decorator that adds the specified headers to the Vary header of the response. Usage: @vary_on_headers('Cookie', 'Accept-language') def index(request): ... Note that the header names are not case-sensitive.
A view decorator that adds the specified headers to the Vary header of the response. Usage:
def vary_on_headers(*headers): """ A view decorator that adds the specified headers to the Vary header of the response. Usage: @vary_on_headers('Cookie', 'Accept-language') def index(request): ... Note that the header names are not case-sensitive. """ def decorator(fun...
[ "def", "vary_on_headers", "(", "*", "headers", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "func", "(", "*", "args",...
[ 5, 0 ]
[ 23, 20 ]
python
en
['en', 'error', 'th']
False
vary_on_cookie
(func)
A view decorator that adds "Cookie" to the Vary header of a response. This indicates that a page's contents depends on cookies. Usage: @vary_on_cookie def index(request): ...
A view decorator that adds "Cookie" to the Vary header of a response. This indicates that a page's contents depends on cookies. Usage:
def vary_on_cookie(func): """ A view decorator that adds "Cookie" to the Vary header of a response. This indicates that a page's contents depends on cookies. Usage: @vary_on_cookie def index(request): ... """ @wraps(func) def inner_func(*args, **kwargs): resp...
[ "def", "vary_on_cookie", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "patch_vary_headers", ...
[ 26, 0 ]
[ 40, 21 ]
python
en
['en', 'error', 'th']
False
command_btc
(bot, user, channel, args)
Display current BTC exchange rates from mtgox. Usage: btc [<currencycode>...].
Display current BTC exchange rates from mtgox. Usage: btc [<currencycode>...].
def command_btc(bot, user, channel, args): """Display current BTC exchange rates from mtgox. Usage: btc [<currencycode>...].""" currencies = ["EUR"] if args: currencies = args.split() return bot.say(channel, get_coin_value(bot, "BTC", currencies))
[ "def", "command_btc", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "currencies", "=", "[", "\"EUR\"", "]", "if", "args", ":", "currencies", "=", "args", ".", "split", "(", ")", "return", "bot", ".", "say", "(", "channel", ",", "g...
[ 7, 0 ]
[ 15, 67 ]
python
en
['en', 'en', 'en']
True
_SendRecv
()
Communicate with the Developer Shell server socket.
Communicate with the Developer Shell server socket.
def _SendRecv(): """Communicate with the Developer Shell server socket.""" port = int(os.getenv(DEVSHELL_ENV, 0)) if port == 0: raise NoDevshellServer() sock = socket.socket() sock.connect(('localhost', port)) data = CREDENTIAL_INFO_REQUEST_JSON msg = '{0}\n{1}'.format(len(data), ...
[ "def", "_SendRecv", "(", ")", ":", "port", "=", "int", "(", "os", ".", "getenv", "(", "DEVSHELL_ENV", ",", "0", ")", ")", "if", "port", "==", "0", ":", "raise", "NoDevshellServer", "(", ")", "sock", "=", "socket", ".", "socket", "(", ")", "sock", ...
[ 71, 0 ]
[ 93, 43 ]
python
en
['en', 'no', 'en']
True
CredentialInfoResponse.__init__
(self, json_string)
Initialize the response data from JSON PBLite array.
Initialize the response data from JSON PBLite array.
def __init__(self, json_string): """Initialize the response data from JSON PBLite array.""" pbl = json.loads(json_string) if not isinstance(pbl, list): raise ValueError('Not a list: ' + str(pbl)) pbl_len = len(pbl) self.user_email = pbl[0] if pbl_len > 0 else None ...
[ "def", "__init__", "(", "self", ",", "json_string", ")", ":", "pbl", "=", "json", ".", "loads", "(", "json_string", ")", "if", "not", "isinstance", "(", "pbl", ",", "list", ")", ":", "raise", "ValueError", "(", "'Not a list: '", "+", "str", "(", "pbl",...
[ 59, 4 ]
[ 68, 57 ]
python
en
['en', 'en', 'en']
True
DevshellCredentials._refresh
(self, http)
Refreshes the access token. Args: http: unused HTTP object
Refreshes the access token.
def _refresh(self, http): """Refreshes the access token. Args: http: unused HTTP object """ self.devshell_response = _SendRecv() self.access_token = self.devshell_response.access_token expires_in = self.devshell_response.expires_in if expires_in is no...
[ "def", "_refresh", "(", "self", ",", "http", ")", ":", "self", ".", "devshell_response", "=", "_SendRecv", "(", ")", "self", ".", "access_token", "=", "self", ".", "devshell_response", ".", "access_token", "expires_in", "=", "self", ".", "devshell_response", ...
[ 120, 4 ]
[ 133, 36 ]
python
en
['en', 'en', 'en']
True
hello_monkey
()
Respond to incoming calls with a simple text message.
Respond to incoming calls with a simple text message.
def hello_monkey(): """Respond to incoming calls with a simple text message.""" resp = MessagingResponse() msg = Message()\ .body("Hello, Mobile Monkey")\ .media("https://demo.twilio.com/owl.png") resp.append(msg) return str(resp) if __name__ == "__main__": app.run(deb...
[ "def", "hello_monkey", "(", ")", ":", "resp", "=", "MessagingResponse", "(", ")", "msg", "=", "Message", "(", ")", ".", "body", "(", "\"Hello, Mobile Monkey\"", ")", ".", "media", "(", "\"https://demo.twilio.com/owl.png\"", ")", "resp", ".", "append", "(", "...
[ 8, 0 ]
[ 20, 27 ]
python
en
['en', 'en', 'en']
True
Config.from_envvar
(self, variable_name, silent=False)
Loads a configuration from an environment variable pointing to a configuration file. This is basically just a shortcut with nicer error messages for this line of code:: app.config.from_pyfile(os.environ['YOURAPPLICATION_SETTINGS']) :param variable_name: name of the environment var...
Loads a configuration from an environment variable pointing to a configuration file. This is basically just a shortcut with nicer error messages for this line of code::
def from_envvar(self, variable_name, silent=False): """Loads a configuration from an environment variable pointing to a configuration file. This is basically just a shortcut with nicer error messages for this line of code:: app.config.from_pyfile(os.environ['YOURAPPLICATION_SETTING...
[ "def", "from_envvar", "(", "self", ",", "variable_name", ",", "silent", "=", "False", ")", ":", "rv", "=", "os", ".", "environ", ".", "get", "(", "variable_name", ")", "if", "not", "rv", ":", "if", "silent", ":", "return", "False", "raise", "RuntimeErr...
[ 87, 4 ]
[ 108, 50 ]
python
en
['en', 'en', 'en']
True
Config.from_pyfile
(self, filename, silent=False)
Updates the values in the config from a Python file. This function behaves as if the file was imported as module with the :meth:`from_object` function. :param filename: the filename of the config. This can either be an absolute filename or a filename relative to the ...
Updates the values in the config from a Python file. This function behaves as if the file was imported as module with the :meth:`from_object` function.
def from_pyfile(self, filename, silent=False): """Updates the values in the config from a Python file. This function behaves as if the file was imported as module with the :meth:`from_object` function. :param filename: the filename of the config. This can either be an ...
[ "def", "from_pyfile", "(", "self", ",", "filename", ",", "silent", "=", "False", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "root_path", ",", "filename", ")", "d", "=", "types", ".", "ModuleType", "(", "'config'", ")...
[ 110, 4 ]
[ 136, 19 ]
python
en
['en', 'en', 'en']
True
Config.from_object
(self, obj)
Updates the values from the given object. An object can be of one of the following two types: - a string: in this case the object with that name will be imported - an actual object reference: that object is used directly Objects are usually either modules or classes. :meth:`from_o...
Updates the values from the given object. An object can be of one of the following two types:
def from_object(self, obj): """Updates the values from the given object. An object can be of one of the following two types: - a string: in this case the object with that name will be imported - an actual object reference: that object is used directly Objects are usually e...
[ "def", "from_object", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "string_types", ")", ":", "obj", "=", "import_string", "(", "obj", ")", "for", "key", "in", "dir", "(", "obj", ")", ":", "if", "key", ".", "isupper", "(",...
[ 138, 4 ]
[ 170, 45 ]
python
en
['en', 'en', 'en']
True
Config.from_json
(self, filename, silent=False)
Updates the values in the config from a JSON file. This function behaves as if the JSON object was a dictionary and passed to the :meth:`from_mapping` function. :param filename: the filename of the JSON file. This can either be an absolute filename or a filename relati...
Updates the values in the config from a JSON file. This function behaves as if the JSON object was a dictionary and passed to the :meth:`from_mapping` function.
def from_json(self, filename, silent=False): """Updates the values in the config from a JSON file. This function behaves as if the JSON object was a dictionary and passed to the :meth:`from_mapping` function. :param filename: the filename of the JSON file. This can either be an ...
[ "def", "from_json", "(", "self", ",", "filename", ",", "silent", "=", "False", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "root_path", ",", "filename", ")", "try", ":", "with", "open", "(", "filename", ")", "as", "...
[ 172, 4 ]
[ 195, 37 ]
python
en
['en', 'en', 'en']
True
Config.from_mapping
(self, *mapping, **kwargs)
Updates the config like :meth:`update` ignoring items with non-upper keys. .. versionadded:: 0.11
Updates the config like :meth:`update` ignoring items with non-upper keys.
def from_mapping(self, *mapping, **kwargs): """Updates the config like :meth:`update` ignoring items with non-upper keys. .. versionadded:: 0.11 """ mappings = [] if len(mapping) == 1: if hasattr(mapping[0], 'items'): mappings.append(mapping[0...
[ "def", "from_mapping", "(", "self", ",", "*", "mapping", ",", "*", "*", "kwargs", ")", ":", "mappings", "=", "[", "]", "if", "len", "(", "mapping", ")", "==", "1", ":", "if", "hasattr", "(", "mapping", "[", "0", "]", ",", "'items'", ")", ":", "...
[ 197, 4 ]
[ 218, 19 ]
python
en
['en', 'en', 'en']
True
Config.get_namespace
(self, namespace, lowercase=True, trim_namespace=True)
Returns a dictionary containing a subset of configuration options that match the specified namespace/prefix. Example usage:: app.config['IMAGE_STORE_TYPE'] = 'fs' app.config['IMAGE_STORE_PATH'] = '/var/app/images' app.config['IMAGE_STORE_BASE_URL'] = 'http://img.website.com'...
Returns a dictionary containing a subset of configuration options that match the specified namespace/prefix. Example usage::
def get_namespace(self, namespace, lowercase=True, trim_namespace=True): """Returns a dictionary containing a subset of configuration options that match the specified namespace/prefix. Example usage:: app.config['IMAGE_STORE_TYPE'] = 'fs' app.config['IMAGE_STORE_PATH'] = '/var/a...
[ "def", "get_namespace", "(", "self", ",", "namespace", ",", "lowercase", "=", "True", ",", "trim_namespace", "=", "True", ")", ":", "rv", "=", "{", "}", "for", "k", ",", "v", "in", "iteritems", "(", "self", ")", ":", "if", "not", "k", ".", "startsw...
[ 220, 4 ]
[ 259, 17 ]
python
en
['en', 'en', 'en']
True
get_capability_token
()
Respond to incoming requests.
Respond to incoming requests.
def get_capability_token(): """Respond to incoming requests.""" # Find these values at twilio.com/console # To set up environmental variables, see http://twil.io/secure account_sid = os.environ['TWILIO_ACCOUNT_SID'] auth_token = os.environ['TWILIO_AUTH_TOKEN'] capability = ClientCapabilityToken(ac...
[ "def", "get_capability_token", "(", ")", ":", "# Find these values at twilio.com/console", "# To set up environmental variables, see http://twil.io/secure", "account_sid", "=", "os", ".", "environ", "[", "'TWILIO_ACCOUNT_SID'", "]", "auth_token", "=", "os", ".", "environ", "[...
[ 8, 0 ]
[ 24, 54 ]
python
en
['en', 'en', 'en']
True
Composable.as_string
(self, context)
Return the string value of the object. :param context: the context to evaluate the string into. :type context: `connection` or `cursor` The method is automatically invoked by `~cursor.execute()`, `~cursor.executemany()`, `~cursor.copy_expert()` if a `!Composable` is pa...
Return the string value of the object.
def as_string(self, context): """ Return the string value of the object. :param context: the context to evaluate the string into. :type context: `connection` or `cursor` The method is automatically invoked by `~cursor.execute()`, `~cursor.executemany()`, `~cursor.copy_e...
[ "def", "as_string", "(", "self", ",", "context", ")", ":", "raise", "NotImplementedError" ]
[ 54, 4 ]
[ 65, 33 ]
python
en
['en', 'error', 'th']
False
Composed.seq
(self)
The list of the content of the `!Composed`.
The list of the content of the `!Composed`.
def seq(self): """The list of the content of the `!Composed`.""" return list(self._wrapped)
[ "def", "seq", "(", "self", ")", ":", "return", "list", "(", "self", ".", "_wrapped", ")" ]
[ 114, 4 ]
[ 116, 34 ]
python
en
['en', 'en', 'en']
True
Composed.join
(self, joiner)
Return a new `!Composed` interposing the *joiner* with the `!Composed` items. The *joiner* must be a `SQL` or a string which will be interpreted as an `SQL`. Example:: >>> fields = sql.Identifier('foo') + sql.Identifier('bar') # a Composed >>> print(fields.jo...
Return a new `!Composed` interposing the *joiner* with the `!Composed` items.
def join(self, joiner): """ Return a new `!Composed` interposing the *joiner* with the `!Composed` items. The *joiner* must be a `SQL` or a string which will be interpreted as an `SQL`. Example:: >>> fields = sql.Identifier('foo') + sql.Identifier('bar') # a Compo...
[ "def", "join", "(", "self", ",", "joiner", ")", ":", "if", "isinstance", "(", "joiner", ",", "str", ")", ":", "joiner", "=", "SQL", "(", "joiner", ")", "elif", "not", "isinstance", "(", "joiner", ",", "SQL", ")", ":", "raise", "TypeError", "(", "\"...
[ 135, 4 ]
[ 155, 32 ]
python
en
['en', 'error', 'th']
False
SQL.string
(self)
The string wrapped by the `!SQL` object.
The string wrapped by the `!SQL` object.
def string(self): """The string wrapped by the `!SQL` object.""" return self._wrapped
[ "def", "string", "(", "self", ")", ":", "return", "self", ".", "_wrapped" ]
[ 186, 4 ]
[ 188, 28 ]
python
en
['en', 'en', 'en']
True
SQL.format
(self, *args, **kwargs)
Merge `Composable` objects into a template. :param `Composable` args: parameters to replace to numbered (``{0}``, ``{1}``) or auto-numbered (``{}``) placeholders :param `Composable` kwargs: parameters to replace to named (``{name}``) placeholders :return: the un...
Merge `Composable` objects into a template.
def format(self, *args, **kwargs): """ Merge `Composable` objects into a template. :param `Composable` args: parameters to replace to numbered (``{0}``, ``{1}``) or auto-numbered (``{}``) placeholders :param `Composable` kwargs: parameters to replace to named (``{name}``) ...
[ "def", "format", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "rv", "=", "[", "]", "autonum", "=", "0", "for", "pre", ",", "name", ",", "spec", ",", "conv", "in", "_formatter", ".", "parse", "(", "self", ".", "_wrapped", ")...
[ 193, 4 ]
[ 255, 27 ]
python
en
['en', 'error', 'th']
False
SQL.join
(self, seq)
Join a sequence of `Composable`. :param seq: the elements to join. :type seq: iterable of `!Composable` Use the `!SQL` object's *string* to separate the elements in *seq*. Note that `Composed` objects are iterable too, so they can be used as argument for this method. ...
Join a sequence of `Composable`.
def join(self, seq): """ Join a sequence of `Composable`. :param seq: the elements to join. :type seq: iterable of `!Composable` Use the `!SQL` object's *string* to separate the elements in *seq*. Note that `Composed` objects are iterable too, so they can be used as ...
[ "def", "join", "(", "self", ",", "seq", ")", ":", "rv", "=", "[", "]", "it", "=", "iter", "(", "seq", ")", "try", ":", "rv", ".", "append", "(", "next", "(", "it", ")", ")", "except", "StopIteration", ":", "pass", "else", ":", "for", "i", "in...
[ 257, 4 ]
[ 286, 27 ]
python
en
['en', 'error', 'th']
False
Identifier.strings
(self)
A tuple with the strings wrapped by the `Identifier`.
A tuple with the strings wrapped by the `Identifier`.
def strings(self): """A tuple with the strings wrapped by the `Identifier`.""" return self._wrapped
[ "def", "strings", "(", "self", ")", ":", "return", "self", ".", "_wrapped" ]
[ 331, 4 ]
[ 333, 28 ]
python
en
['en', 'en', 'en']
True
Identifier.string
(self)
The string wrapped by the `Identifier`.
The string wrapped by the `Identifier`.
def string(self): """The string wrapped by the `Identifier`. """ if len(self._wrapped) == 1: return self._wrapped[0] else: raise AttributeError( "the Identifier wraps more than one than one string")
[ "def", "string", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_wrapped", ")", "==", "1", ":", "return", "self", ".", "_wrapped", "[", "0", "]", "else", ":", "raise", "AttributeError", "(", "\"the Identifier wraps more than one than one string\"", "...
[ 336, 4 ]
[ 343, 69 ]
python
en
['en', 'en', 'en']
True
Literal.wrapped
(self)
The object wrapped by the `!Literal`.
The object wrapped by the `!Literal`.
def wrapped(self): """The object wrapped by the `!Literal`.""" return self._wrapped
[ "def", "wrapped", "(", "self", ")", ":", "return", "self", ".", "_wrapped" ]
[ 373, 4 ]
[ 375, 28 ]
python
en
['en', 'en', 'en']
True
Placeholder.name
(self)
The name of the `!Placeholder`.
The name of the `!Placeholder`.
def name(self): """The name of the `!Placeholder`.""" return self._wrapped
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_wrapped" ]
[ 435, 4 ]
[ 437, 28 ]
python
en
['en', 'en', 'en']
True
LogFormatter.__init__
(self, color=True, datefmt=None)
r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the level if color support is on. :arg dict colors...
r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the level if color support is on. :arg dict colors...
def __init__(self, color=True, datefmt=None): r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the ...
[ "def", "__init__", "(", "self", ",", "color", "=", "True", ",", "datefmt", "=", "None", ")", ":", "logging", ".", "Formatter", ".", "__init__", "(", "self", ",", "datefmt", "=", "datefmt", ")", "self", ".", "_colors", "=", "{", "}", "if", "color", ...
[ 49, 4 ]
[ 90, 31 ]
python
cy
['en', 'cy', 'hi']
False
get_token
(h: torch.tensor, x: torch.tensor, token: int)
Get specific token embedding (e.g. [CLS])
Get specific token embedding (e.g. [CLS])
def get_token(h: torch.tensor, x: torch.tensor, token: int): """ Get specific token embedding (e.g. [CLS]) """ emb_size = h.shape[-1] token_h = h.view(-1, emb_size) flat = x.contiguous().view(-1) # get contextualized embedding of given token token_h = token_h[flat == token, :] return toke...
[ "def", "get_token", "(", "h", ":", "torch", ".", "tensor", ",", "x", ":", "torch", ".", "tensor", ",", "token", ":", "int", ")", ":", "emb_size", "=", "h", ".", "shape", "[", "-", "1", "]", "token_h", "=", "h", ".", "view", "(", "-", "1", ","...
[ 10, 0 ]
[ 20, 18 ]
python
en
['en', 'de', 'en']
True
_best_version
(fields)
Detect the best version depending on the fields used.
Detect the best version depending on the fields used.
def _best_version(fields): """Detect the best version depending on the fields used.""" def _has_marker(keys, markers): for marker in markers: if marker in keys: return True return False keys = [] for key, value in fields.items(): if value in ([], 'UNK...
[ "def", "_best_version", "(", "fields", ")", ":", "def", "_has_marker", "(", "keys", ",", "markers", ")", ":", "for", "marker", "in", "markers", ":", "if", "marker", "in", "keys", ":", "return", "True", "return", "False", "keys", "=", "[", "]", "for", ...
[ 127, 0 ]
[ 196, 16 ]
python
en
['en', 'en', 'en']
True
_get_name_and_version
(name, version, for_filename=False)
Return the distribution name with version. If for_filename is true, return a filename-escaped form.
Return the distribution name with version.
def _get_name_and_version(name, version, for_filename=False): """Return the distribution name with version. If for_filename is true, return a filename-escaped form.""" if for_filename: # For both name and version any runs of non-alphanumeric or '.' # characters are replaced with a single '-...
[ "def", "_get_name_and_version", "(", "name", ",", "version", ",", "for_filename", "=", "False", ")", ":", "if", "for_filename", ":", "# For both name and version any runs of non-alphanumeric or '.'", "# characters are replaced with a single '-'. Additionally any", "# spaces in the...
[ 224, 0 ]
[ 234, 36 ]
python
en
['en', 'en', 'en']
True
LegacyMetadata.get_fullname
(self, filesafe=False)
Return the distribution name with version. If filesafe is true, return a filename-escaped form.
Return the distribution name with version.
def get_fullname(self, filesafe=False): """Return the distribution name with version. If filesafe is true, return a filename-escaped form.""" return _get_name_and_version(self['Name'], self['Version'], filesafe)
[ "def", "get_fullname", "(", "self", ",", "filesafe", "=", "False", ")", ":", "return", "_get_name_and_version", "(", "self", "[", "'Name'", "]", ",", "self", "[", "'Version'", "]", ",", "filesafe", ")" ]
[ 316, 4 ]
[ 320, 77 ]
python
en
['en', 'en', 'en']
True
LegacyMetadata.is_field
(self, name)
return True if name is a valid metadata key
return True if name is a valid metadata key
def is_field(self, name): """return True if name is a valid metadata key""" name = self._convert_name(name) return name in _ALL_FIELDS
[ "def", "is_field", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_convert_name", "(", "name", ")", "return", "name", "in", "_ALL_FIELDS" ]
[ 322, 4 ]
[ 325, 34 ]
python
en
['en', 'et', 'en']
True
LegacyMetadata.read
(self, filepath)
Read the metadata values from a file path.
Read the metadata values from a file path.
def read(self, filepath): """Read the metadata values from a file path.""" fp = codecs.open(filepath, 'r', encoding='utf-8') try: self.read_file(fp) finally: fp.close()
[ "def", "read", "(", "self", ",", "filepath", ")", ":", "fp", "=", "codecs", ".", "open", "(", "filepath", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "try", ":", "self", ".", "read_file", "(", "fp", ")", "finally", ":", "fp", ".", "close", ...
[ 331, 4 ]
[ 337, 22 ]
python
en
['en', 'en', 'en']
True
LegacyMetadata.read_file
(self, fileob)
Read the metadata values from a file object.
Read the metadata values from a file object.
def read_file(self, fileob): """Read the metadata values from a file object.""" msg = message_from_file(fileob) self._fields['Metadata-Version'] = msg['metadata-version'] # When reading, get all the fields we can for field in _ALL_FIELDS: if field not in msg: ...
[ "def", "read_file", "(", "self", ",", "fileob", ")", ":", "msg", "=", "message_from_file", "(", "fileob", ")", "self", ".", "_fields", "[", "'Metadata-Version'", "]", "=", "msg", "[", "'metadata-version'", "]", "# When reading, get all the fields we can", "for", ...
[ 339, 4 ]
[ 363, 67 ]
python
en
['en', 'en', 'en']
True
LegacyMetadata.write
(self, filepath, skip_unknown=False)
Write the metadata fields to filepath.
Write the metadata fields to filepath.
def write(self, filepath, skip_unknown=False): """Write the metadata fields to filepath.""" fp = codecs.open(filepath, 'w', encoding='utf-8') try: self.write_file(fp, skip_unknown) finally: fp.close()
[ "def", "write", "(", "self", ",", "filepath", ",", "skip_unknown", "=", "False", ")", ":", "fp", "=", "codecs", ".", "open", "(", "filepath", ",", "'w'", ",", "encoding", "=", "'utf-8'", ")", "try", ":", "self", ".", "write_file", "(", "fp", ",", "...
[ 367, 4 ]
[ 373, 22 ]
python
en
['en', 'el-Latn', 'en']
True
LegacyMetadata.write_file
(self, fileobject, skip_unknown=False)
Write the PKG-INFO format data to a file object.
Write the PKG-INFO format data to a file object.
def write_file(self, fileobject, skip_unknown=False): """Write the PKG-INFO format data to a file object.""" self.set_metadata_version() for field in _version2fieldlist(self['Metadata-Version']): values = self.get(field) if skip_unknown and values in ('UNKNOWN', [], ['UN...
[ "def", "write_file", "(", "self", ",", "fileobject", ",", "skip_unknown", "=", "False", ")", ":", "self", ".", "set_metadata_version", "(", ")", "for", "field", "in", "_version2fieldlist", "(", "self", "[", "'Metadata-Version'", "]", ")", ":", "values", "=",...
[ 375, 4 ]
[ 398, 59 ]
python
en
['en', 'en', 'en']
True
LegacyMetadata.update
(self, other=None, **kwargs)
Set metadata values from the given iterable `other` and kwargs. Behavior is like `dict.update`: If `other` has a ``keys`` method, they are looped over and ``self[key]`` is assigned ``other[key]``. Else, ``other`` is an iterable of ``(key, value)`` iterables. Keys that don't match a met...
Set metadata values from the given iterable `other` and kwargs.
def update(self, other=None, **kwargs): """Set metadata values from the given iterable `other` and kwargs. Behavior is like `dict.update`: If `other` has a ``keys`` method, they are looped over and ``self[key]`` is assigned ``other[key]``. Else, ``other`` is an iterable of ``(key, value...
[ "def", "update", "(", "self", ",", "other", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "_set", "(", "key", ",", "value", ")", ":", "if", "key", "in", "_ATTR2FIELD", "and", "value", ":", "self", ".", "set", "(", "self", ".", "_convert_...
[ 400, 4 ]
[ 426, 26 ]
python
en
['en', 'en', 'en']
True
LegacyMetadata.set
(self, name, value)
Control then set a metadata field.
Control then set a metadata field.
def set(self, name, value): """Control then set a metadata field.""" name = self._convert_name(name) if ((name in _ELEMENTSFIELD or name == 'Platform') and not isinstance(value, (list, tuple))): if isinstance(value, string_types): value = [v.strip() for v...
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "name", "=", "self", ".", "_convert_name", "(", "name", ")", "if", "(", "(", "name", "in", "_ELEMENTSFIELD", "or", "name", "==", "'Platform'", ")", "and", "not", "isinstance", "(", "valu...
[ 428, 4 ]
[ 470, 34 ]
python
en
['en', 'lb', 'en']
True
LegacyMetadata.get
(self, name, default=_MISSING)
Get a metadata field.
Get a metadata field.
def get(self, name, default=_MISSING): """Get a metadata field.""" name = self._convert_name(name) if name not in self._fields: if default is _MISSING: default = self._default_value(name) return default if name in _UNICODEFIELDS: value ...
[ "def", "get", "(", "self", ",", "name", ",", "default", "=", "_MISSING", ")", ":", "name", "=", "self", ".", "_convert_name", "(", "name", ")", "if", "name", "not", "in", "self", ".", "_fields", ":", "if", "default", "is", "_MISSING", ":", "default",...
[ 472, 4 ]
[ 499, 33 ]
python
en
['ro', 'lb', 'en']
False
LegacyMetadata.check
(self, strict=False)
Check if the metadata is compliant. If strict is True then raise if no Name or Version are provided
Check if the metadata is compliant. If strict is True then raise if no Name or Version are provided
def check(self, strict=False): """Check if the metadata is compliant. If strict is True then raise if no Name or Version are provided""" self.set_metadata_version() # XXX should check the versions (if the file was loaded) missing, warnings = [], [] for attr in ('Name', ...
[ "def", "check", "(", "self", ",", "strict", "=", "False", ")", ":", "self", ".", "set_metadata_version", "(", ")", "# XXX should check the versions (if the file was loaded)", "missing", ",", "warnings", "=", "[", "]", ",", "[", "]", "for", "attr", "in", "(", ...
[ 501, 4 ]
[ 543, 32 ]
python
en
['en', 'en', 'en']
True
LegacyMetadata.todict
(self, skip_missing=False)
Return fields as a dict. Field names will be converted to use the underscore-lowercase style instead of hyphen-mixed case (i.e. home_page instead of Home-page). This is as per https://www.python.org/dev/peps/pep-0566/#id17.
Return fields as a dict.
def todict(self, skip_missing=False): """Return fields as a dict. Field names will be converted to use the underscore-lowercase style instead of hyphen-mixed case (i.e. home_page instead of Home-page). This is as per https://www.python.org/dev/peps/pep-0566/#id17. """ se...
[ "def", "todict", "(", "self", ",", "skip_missing", "=", "False", ")", ":", "self", ".", "set_metadata_version", "(", ")", "fields", "=", "_version2fieldlist", "(", "self", "[", "'Metadata-Version'", "]", ")", "data", "=", "{", "}", "for", "field_name", "in...
[ 545, 4 ]
[ 566, 19 ]
python
en
['en', 'en', 'en']
True
Metadata.get_requirements
(self, reqts, extras=None, env=None)
Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. :param extras: A list of optional components being requested. ...
Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. :param extras: A list of optional components being requested. ...
def get_requirements(self, reqts, extras=None, env=None): """ Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. ...
[ "def", "get_requirements", "(", "self", ",", "reqts", ",", "extras", "=", "None", ",", "env", "=", "None", ")", ":", "if", "self", ".", "_legacy", ":", "result", "=", "reqts", "else", ":", "result", "=", "[", "]", "extras", "=", "get_extras", "(", ...
[ 826, 4 ]
[ 866, 21 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor._is_referenced_by_fk_constraint
(self, table_name, column_name=None, ignore_self=False)
Return whether or not the provided table name is referenced by another one. If `column_name` is specified, only references pointing to that column are considered. If `ignore_self` is True, self-referential constraints are ignored.
Return whether or not the provided table name is referenced by another one. If `column_name` is specified, only references pointing to that column are considered. If `ignore_self` is True, self-referential constraints are ignored.
def _is_referenced_by_fk_constraint(self, table_name, column_name=None, ignore_self=False): """ Return whether or not the provided table name is referenced by another one. If `column_name` is specified, only references pointing to that column are considered. If `ignore_self` is True, sel...
[ "def", "_is_referenced_by_fk_constraint", "(", "self", ",", "table_name", ",", "column_name", "=", "None", ",", "ignore_self", "=", "False", ")", ":", "with", "self", ".", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "for", "other_table", "in"...
[ 66, 4 ]
[ 83, 20 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor._remake_table
(self, model, create_field=None, delete_field=None, alter_field=None)
Shortcut to transform a model from old_model into new_model This follows the correct procedure to perform non-rename or column addition operations based on SQLite's documentation https://www.sqlite.org/lang_altertable.html#caution The essential steps are: 1. Create ...
Shortcut to transform a model from old_model into new_model
def _remake_table(self, model, create_field=None, delete_field=None, alter_field=None): """ Shortcut to transform a model from old_model into new_model This follows the correct procedure to perform non-rename or column addition operations based on SQLite's documentation https:/...
[ "def", "_remake_table", "(", "self", ",", "model", ",", "create_field", "=", "None", ",", "delete_field", "=", "None", ",", "alter_field", "=", "None", ")", ":", "# Self-referential fields must be recreated rather than copied from", "# the old model to ensure their remote_f...
[ 141, 4 ]
[ 306, 47 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor.add_field
(self, model, field)
Create a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields).
Create a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields).
def add_field(self, model, field): """ Create a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields). """ # Special-case implicit M2M tables if field.many_to_many and field.remote_field.through._meta.auto_created: ...
[ "def", "add_field", "(", "self", ",", "model", ",", "field", ")", ":", "# Special-case implicit M2M tables", "if", "field", ".", "many_to_many", "and", "field", ".", "remote_field", ".", "through", ".", "_meta", ".", "auto_created", ":", "return", "self", ".",...
[ 321, 4 ]
[ 329, 53 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor.remove_field
(self, model, field)
Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table.
Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table.
def remove_field(self, model, field): """ Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table. """ # M2M fields are a special case if field.many_to_many: # For implicit M2M tables, delete the auto-created ...
[ "def", "remove_field", "(", "self", ",", "model", ",", "field", ")", ":", "# M2M fields are a special case", "if", "field", ".", "many_to_many", ":", "# For implicit M2M tables, delete the auto-created table", "if", "field", ".", "remote_field", ".", "through", ".", "...
[ 331, 4 ]
[ 347, 57 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor._alter_field
(self, model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict=False)
Perform a "physical" (non-ManyToMany) field update.
Perform a "physical" (non-ManyToMany) field update.
def _alter_field(self, model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict=False): """Perform a "physical" (non-ManyToMany) field update.""" # Use "ALTER TABLE ... RENAME COLUMN" if only the column name # changed and there aren't any constra...
[ "def", "_alter_field", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "old_type", ",", "new_type", ",", "old_db_params", ",", "new_db_params", ",", "strict", "=", "False", ")", ":", "# Use \"ALTER TABLE ... RENAME COLUMN\" if only the column name"...
[ 349, 4 ]
[ 383, 49 ]
python
en
['en', 'en', 'en']
True
DatabaseSchemaEditor._alter_many_to_many
(self, model, old_field, new_field, strict)
Alter M2Ms to repoint their to= endpoints.
Alter M2Ms to repoint their to= endpoints.
def _alter_many_to_many(self, model, old_field, new_field, strict): """Alter M2Ms to repoint their to= endpoints.""" if old_field.remote_field.through._meta.db_table == new_field.remote_field.through._meta.db_table: # The field name didn't change, but some options did; we have to propagate t...
[ "def", "_alter_many_to_many", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "strict", ")", ":", "if", "old_field", ".", "remote_field", ".", "through", ".", "_meta", ".", "db_table", "==", "new_field", ".", "remote_field", ".", "through...
[ 385, 4 ]
[ 418, 57 ]
python
en
['en', 'en', 'en']
True
NameAliasMixin.get_real_name
(self)
Returns the real name (object name) of this identifier.
Returns the real name (object name) of this identifier.
def get_real_name(self): """Returns the real name (object name) of this identifier.""" # a.b dot_idx, _ = self.token_next_by(m=(T.Punctuation, '.')) return self._get_first_name(dot_idx, real_name=True)
[ "def", "get_real_name", "(", "self", ")", ":", "# a.b", "dot_idx", ",", "_", "=", "self", ".", "token_next_by", "(", "m", "=", "(", "T", ".", "Punctuation", ",", "'.'", ")", ")", "return", "self", ".", "_get_first_name", "(", "dot_idx", ",", "real_name...
[ 18, 4 ]
[ 22, 60 ]
python
en
['en', 'en', 'en']
True
NameAliasMixin.get_alias
(self)
Returns the alias for this identifier or ``None``.
Returns the alias for this identifier or ``None``.
def get_alias(self): """Returns the alias for this identifier or ``None``.""" # "name AS alias" kw_idx, kw = self.token_next_by(m=(T.Keyword, 'AS')) if kw is not None: return self._get_first_name(kw_idx + 1, keywords=True) # "name alias" or "complicated column expre...
[ "def", "get_alias", "(", "self", ")", ":", "# \"name AS alias\"", "kw_idx", ",", "kw", "=", "self", ".", "token_next_by", "(", "m", "=", "(", "T", ".", "Keyword", ",", "'AS'", ")", ")", "if", "kw", "is", "not", "None", ":", "return", "self", ".", "...
[ 24, 4 ]
[ 35, 53 ]
python
en
['en', 'en', 'en']
True
Token.flatten
(self)
Resolve subgroups.
Resolve subgroups.
def flatten(self): """Resolve subgroups.""" yield self
[ "def", "flatten", "(", "self", ")", ":", "yield", "self" ]
[ 83, 4 ]
[ 85, 18 ]
python
en
['et', 'la', 'en']
False
Token.match
(self, ttype, values, regex=False)
Checks whether the token matches the given arguments. *ttype* is a token type. If this token doesn't match the given token type. *values* is a list of possible values for this token. The values are OR'ed together so if only one of the values matches ``True`` is returned. Except ...
Checks whether the token matches the given arguments.
def match(self, ttype, values, regex=False): """Checks whether the token matches the given arguments. *ttype* is a token type. If this token doesn't match the given token type. *values* is a list of possible values for this token. The values are OR'ed together so if only one of ...
[ "def", "match", "(", "self", ",", "ttype", ",", "values", ",", "regex", "=", "False", ")", ":", "type_matched", "=", "self", ".", "ttype", "is", "ttype", "if", "not", "type_matched", "or", "values", "is", "None", ":", "return", "type_matched", "if", "i...
[ 87, 4 ]
[ 119, 40 ]
python
en
['en', 'en', 'en']
True
Token.within
(self, group_cls)
Returns ``True`` if this token is within *group_cls*. Use this method for example to check if an identifier is within a function: ``t.within(sql.Function)``.
Returns ``True`` if this token is within *group_cls*.
def within(self, group_cls): """Returns ``True`` if this token is within *group_cls*. Use this method for example to check if an identifier is within a function: ``t.within(sql.Function)``. """ parent = self.parent while parent: if isinstance(parent, group_cl...
[ "def", "within", "(", "self", ",", "group_cls", ")", ":", "parent", "=", "self", ".", "parent", "while", "parent", ":", "if", "isinstance", "(", "parent", ",", "group_cls", ")", ":", "return", "True", "parent", "=", "parent", ".", "parent", "return", "...
[ 121, 4 ]
[ 132, 20 ]
python
en
['en', 'en', 'en']
True
Token.is_child_of
(self, other)
Returns ``True`` if this token is a direct child of *other*.
Returns ``True`` if this token is a direct child of *other*.
def is_child_of(self, other): """Returns ``True`` if this token is a direct child of *other*.""" return self.parent == other
[ "def", "is_child_of", "(", "self", ",", "other", ")", ":", "return", "self", ".", "parent", "==", "other" ]
[ 134, 4 ]
[ 136, 35 ]
python
en
['en', 'en', 'en']
True
Token.has_ancestor
(self, other)
Returns ``True`` if *other* is in this tokens ancestry.
Returns ``True`` if *other* is in this tokens ancestry.
def has_ancestor(self, other): """Returns ``True`` if *other* is in this tokens ancestry.""" parent = self.parent while parent: if parent == other: return True parent = parent.parent return False
[ "def", "has_ancestor", "(", "self", ",", "other", ")", ":", "parent", "=", "self", ".", "parent", "while", "parent", ":", "if", "parent", "==", "other", ":", "return", "True", "parent", "=", "parent", ".", "parent", "return", "False" ]
[ 138, 4 ]
[ 145, 20 ]
python
en
['en', 'en', 'en']
True
TokenList._pprint_tree
(self, max_depth=None, depth=0, f=None, _pre='')
Pretty-print the object tree.
Pretty-print the object tree.
def _pprint_tree(self, max_depth=None, depth=0, f=None, _pre=''): """Pretty-print the object tree.""" token_count = len(self.tokens) for idx, token in enumerate(self.tokens): cls = token._get_repr_name() value = token._get_repr_value() last = idx == (token_co...
[ "def", "_pprint_tree", "(", "self", ",", "max_depth", "=", "None", ",", "depth", "=", "0", ",", "f", "=", "None", ",", "_pre", "=", "''", ")", ":", "token_count", "=", "len", "(", "self", ".", "tokens", ")", "for", "idx", ",", "token", "in", "enu...
[ 179, 4 ]
[ 195, 78 ]
python
en
['en', 'mt', 'en']
True
TokenList.get_token_at_offset
(self, offset)
Returns the token that is on position offset.
Returns the token that is on position offset.
def get_token_at_offset(self, offset): """Returns the token that is on position offset.""" idx = 0 for token in self.flatten(): end = idx + len(token.value) if idx <= offset < end: return token idx = end
[ "def", "get_token_at_offset", "(", "self", ",", "offset", ")", ":", "idx", "=", "0", "for", "token", "in", "self", ".", "flatten", "(", ")", ":", "end", "=", "idx", "+", "len", "(", "token", ".", "value", ")", "if", "idx", "<=", "offset", "<", "e...
[ 197, 4 ]
[ 204, 21 ]
python
en
['en', 'en', 'en']
True
TokenList.flatten
(self)
Generator yielding ungrouped tokens. This method is recursively called for all child tokens.
Generator yielding ungrouped tokens.
def flatten(self): """Generator yielding ungrouped tokens. This method is recursively called for all child tokens. """ for token in self.tokens: if token.is_group: yield from token.flatten() else: yield token
[ "def", "flatten", "(", "self", ")", ":", "for", "token", "in", "self", ".", "tokens", ":", "if", "token", ".", "is_group", ":", "yield", "from", "token", ".", "flatten", "(", ")", "else", ":", "yield", "token" ]
[ 206, 4 ]
[ 215, 27 ]
python
en
['en', 'en', 'es']
True
TokenList._token_matching
(self, funcs, start=0, end=None, reverse=False)
next token that match functions
next token that match functions
def _token_matching(self, funcs, start=0, end=None, reverse=False): """next token that match functions""" if start is None: return None if not isinstance(funcs, (list, tuple)): funcs = (funcs,) if reverse: assert end is None for idx in ra...
[ "def", "_token_matching", "(", "self", ",", "funcs", ",", "start", "=", "0", ",", "end", "=", "None", ",", "reverse", "=", "False", ")", ":", "if", "start", "is", "None", ":", "return", "None", "if", "not", "isinstance", "(", "funcs", ",", "(", "li...
[ 226, 4 ]
[ 246, 25 ]
python
en
['en', 'en', 'en']
True
TokenList.token_first
(self, skip_ws=True, skip_cm=False)
Returns the first child token. If *skip_ws* is ``True`` (the default), whitespace tokens are ignored. if *skip_cm* is ``True`` (default: ``False``), comments are ignored too.
Returns the first child token.
def token_first(self, skip_ws=True, skip_cm=False): """Returns the first child token. If *skip_ws* is ``True`` (the default), whitespace tokens are ignored. if *skip_cm* is ``True`` (default: ``False``), comments are ignored too. """ # this on is inconsistent, u...
[ "def", "token_first", "(", "self", ",", "skip_ws", "=", "True", ",", "skip_cm", "=", "False", ")", ":", "# this on is inconsistent, using Comment instead of T.Comment...", "def", "matcher", "(", "tk", ")", ":", "return", "not", "(", "(", "skip_ws", "and", "tk", ...
[ 248, 4 ]
[ 261, 47 ]
python
en
['en', 'de', 'en']
True
TokenList.token_prev
(self, idx, skip_ws=True, skip_cm=False)
Returns the previous token relative to *idx*. If *skip_ws* is ``True`` (the default) whitespace tokens are ignored. If *skip_cm* is ``True`` comments are ignored. ``None`` is returned if there's no previous token.
Returns the previous token relative to *idx*.
def token_prev(self, idx, skip_ws=True, skip_cm=False): """Returns the previous token relative to *idx*. If *skip_ws* is ``True`` (the default) whitespace tokens are ignored. If *skip_cm* is ``True`` comments are ignored. ``None`` is returned if there's no previous token. """ ...
[ "def", "token_prev", "(", "self", ",", "idx", ",", "skip_ws", "=", "True", ",", "skip_cm", "=", "False", ")", ":", "return", "self", ".", "token_next", "(", "idx", ",", "skip_ws", ",", "skip_cm", ",", "_reverse", "=", "True", ")" ]
[ 275, 4 ]
[ 282, 68 ]
python
en
['en', 'gl', 'en']
True
TokenList.token_next
(self, idx, skip_ws=True, skip_cm=False, _reverse=False)
Returns the next token relative to *idx*. If *skip_ws* is ``True`` (the default) whitespace tokens are ignored. If *skip_cm* is ``True`` comments are ignored. ``None`` is returned if there's no next token.
Returns the next token relative to *idx*.
def token_next(self, idx, skip_ws=True, skip_cm=False, _reverse=False): """Returns the next token relative to *idx*. If *skip_ws* is ``True`` (the default) whitespace tokens are ignored. If *skip_cm* is ``True`` comments are ignored. ``None`` is returned if there's no next token. ...
[ "def", "token_next", "(", "self", ",", "idx", ",", "skip_ws", "=", "True", ",", "skip_cm", "=", "False", ",", "_reverse", "=", "False", ")", ":", "if", "idx", "is", "None", ":", "return", "None", ",", "None", "idx", "+=", "1", "# alot of code usage cur...
[ 285, 4 ]
[ 299, 67 ]
python
en
['en', 'nl', 'en']
True
TokenList.token_index
(self, token, start=0)
Return list index of token.
Return list index of token.
def token_index(self, token, start=0): """Return list index of token.""" start = start if isinstance(start, int) else self.token_index(start) return start + self.tokens[start:].index(token)
[ "def", "token_index", "(", "self", ",", "token", ",", "start", "=", "0", ")", ":", "start", "=", "start", "if", "isinstance", "(", "start", ",", "int", ")", "else", "self", ".", "token_index", "(", "start", ")", "return", "start", "+", "self", ".", ...
[ 301, 4 ]
[ 304, 55 ]
python
en
['en', 'de', 'en']
True
TokenList.group_tokens
(self, grp_cls, start, end, include_end=True, extend=False)
Replace tokens by an instance of *grp_cls*.
Replace tokens by an instance of *grp_cls*.
def group_tokens(self, grp_cls, start, end, include_end=True, extend=False): """Replace tokens by an instance of *grp_cls*.""" start_idx = start start = self.tokens[start_idx] end_idx = end + include_end # will be needed later for new group_clauses ...
[ "def", "group_tokens", "(", "self", ",", "grp_cls", ",", "start", ",", "end", ",", "include_end", "=", "True", ",", "extend", "=", "False", ")", ":", "start_idx", "=", "start", "start", "=", "self", ".", "tokens", "[", "start_idx", "]", "end_idx", "=",...
[ 306, 4 ]
[ 334, 18 ]
python
en
['en', 'en', 'en']
True
TokenList.insert_before
(self, where, token)
Inserts *token* before *where*.
Inserts *token* before *where*.
def insert_before(self, where, token): """Inserts *token* before *where*.""" if not isinstance(where, int): where = self.token_index(where) token.parent = self self.tokens.insert(where, token)
[ "def", "insert_before", "(", "self", ",", "where", ",", "token", ")", ":", "if", "not", "isinstance", "(", "where", ",", "int", ")", ":", "where", "=", "self", ".", "token_index", "(", "where", ")", "token", ".", "parent", "=", "self", "self", ".", ...
[ 336, 4 ]
[ 341, 40 ]
python
en
['en', 'en', 'en']
True
TokenList.insert_after
(self, where, token, skip_ws=True)
Inserts *token* after *where*.
Inserts *token* after *where*.
def insert_after(self, where, token, skip_ws=True): """Inserts *token* after *where*.""" if not isinstance(where, int): where = self.token_index(where) nidx, next_ = self.token_next(where, skip_ws=skip_ws) token.parent = self if next_ is None: self.tokens....
[ "def", "insert_after", "(", "self", ",", "where", ",", "token", ",", "skip_ws", "=", "True", ")", ":", "if", "not", "isinstance", "(", "where", ",", "int", ")", ":", "where", "=", "self", ".", "token_index", "(", "where", ")", "nidx", ",", "next_", ...
[ 343, 4 ]
[ 352, 43 ]
python
en
['en', 'en', 'en']
True
TokenList.has_alias
(self)
Returns ``True`` if an alias is present.
Returns ``True`` if an alias is present.
def has_alias(self): """Returns ``True`` if an alias is present.""" return self.get_alias() is not None
[ "def", "has_alias", "(", "self", ")", ":", "return", "self", ".", "get_alias", "(", ")", "is", "not", "None" ]
[ 354, 4 ]
[ 356, 43 ]
python
en
['en', 'lb', 'en']
True
TokenList.get_alias
(self)
Returns the alias for this identifier or ``None``.
Returns the alias for this identifier or ``None``.
def get_alias(self): """Returns the alias for this identifier or ``None``.""" return None
[ "def", "get_alias", "(", "self", ")", ":", "return", "None" ]
[ 358, 4 ]
[ 360, 19 ]
python
en
['en', 'en', 'en']
True
TokenList.get_name
(self)
Returns the name of this identifier. This is either it's alias or it's real name. The returned valued can be considered as the name under which the object corresponding to this identifier is known within the current statement.
Returns the name of this identifier.
def get_name(self): """Returns the name of this identifier. This is either it's alias or it's real name. The returned valued can be considered as the name under which the object corresponding to this identifier is known within the current statement. """ return self.get_a...
[ "def", "get_name", "(", "self", ")", ":", "return", "self", ".", "get_alias", "(", ")", "or", "self", ".", "get_real_name", "(", ")" ]
[ 362, 4 ]
[ 369, 55 ]
python
en
['en', 'en', 'en']
True
TokenList.get_real_name
(self)
Returns the real name (object name) of this identifier.
Returns the real name (object name) of this identifier.
def get_real_name(self): """Returns the real name (object name) of this identifier.""" return None
[ "def", "get_real_name", "(", "self", ")", ":", "return", "None" ]
[ 371, 4 ]
[ 373, 19 ]
python
en
['en', 'en', 'en']
True
TokenList.get_parent_name
(self)
Return name of the parent object if any. A parent object is identified by the first occurring dot.
Return name of the parent object if any.
def get_parent_name(self): """Return name of the parent object if any. A parent object is identified by the first occurring dot. """ dot_idx, _ = self.token_next_by(m=(T.Punctuation, '.')) _, prev_ = self.token_prev(dot_idx) return remove_quotes(prev_.value) if prev_ is ...
[ "def", "get_parent_name", "(", "self", ")", ":", "dot_idx", ",", "_", "=", "self", ".", "token_next_by", "(", "m", "=", "(", "T", ".", "Punctuation", ",", "'.'", ")", ")", "_", ",", "prev_", "=", "self", ".", "token_prev", "(", "dot_idx", ")", "ret...
[ 375, 4 ]
[ 382, 72 ]
python
en
['en', 'en', 'en']
True
TokenList._get_first_name
(self, idx=None, reverse=False, keywords=False, real_name=False)
Returns the name of the first token with a name
Returns the name of the first token with a name
def _get_first_name(self, idx=None, reverse=False, keywords=False, real_name=False): """Returns the name of the first token with a name""" tokens = self.tokens[idx:] if idx else self.tokens tokens = reversed(tokens) if reverse else tokens types = [T.Name, T.Wildc...
[ "def", "_get_first_name", "(", "self", ",", "idx", "=", "None", ",", "reverse", "=", "False", ",", "keywords", "=", "False", ",", "real_name", "=", "False", ")", ":", "tokens", "=", "self", ".", "tokens", "[", "idx", ":", "]", "if", "idx", "else", ...
[ 384, 4 ]
[ 399, 79 ]
python
en
['en', 'en', 'en']
True
Statement.get_type
(self)
Returns the type of a statement. The returned value is a string holding an upper-cased reprint of the first DML or DDL keyword. If the first token in this group isn't a DML or DDL keyword "UNKNOWN" is returned. Whitespaces and comments at the beginning of the statement are igno...
Returns the type of a statement.
def get_type(self): """Returns the type of a statement. The returned value is a string holding an upper-cased reprint of the first DML or DDL keyword. If the first token in this group isn't a DML or DDL keyword "UNKNOWN" is returned. Whitespaces and comments at the beginning of...
[ "def", "get_type", "(", "self", ")", ":", "first_token", "=", "self", ".", "token_first", "(", "skip_cm", "=", "True", ")", "if", "first_token", "is", "None", ":", "# An \"empty\" statement that either has not tokens at all", "# or only whitespace tokens.", "return", ...
[ 405, 4 ]
[ 438, 24 ]
python
en
['en', 'en', 'en']
True
Identifier.is_wildcard
(self)
Return ``True`` if this identifier contains a wildcard.
Return ``True`` if this identifier contains a wildcard.
def is_wildcard(self): """Return ``True`` if this identifier contains a wildcard.""" _, token = self.token_next_by(t=T.Wildcard) return token is not None
[ "def", "is_wildcard", "(", "self", ")", ":", "_", ",", "token", "=", "self", ".", "token_next_by", "(", "t", "=", "T", ".", "Wildcard", ")", "return", "token", "is", "not", "None" ]
[ 447, 4 ]
[ 450, 32 ]
python
en
['en', 'en', 'en']
True
Identifier.get_typecast
(self)
Returns the typecast or ``None`` of this object as a string.
Returns the typecast or ``None`` of this object as a string.
def get_typecast(self): """Returns the typecast or ``None`` of this object as a string.""" midx, marker = self.token_next_by(m=(T.Punctuation, '::')) nidx, next_ = self.token_next(midx, skip_ws=False) return next_.value if next_ else None
[ "def", "get_typecast", "(", "self", ")", ":", "midx", ",", "marker", "=", "self", ".", "token_next_by", "(", "m", "=", "(", "T", ".", "Punctuation", ",", "'::'", ")", ")", "nidx", ",", "next_", "=", "self", ".", "token_next", "(", "midx", ",", "ski...
[ 452, 4 ]
[ 456, 45 ]
python
en
['en', 'en', 'en']
True
Identifier.get_ordering
(self)
Returns the ordering or ``None`` as uppercase string.
Returns the ordering or ``None`` as uppercase string.
def get_ordering(self): """Returns the ordering or ``None`` as uppercase string.""" _, ordering = self.token_next_by(t=T.Keyword.Order) return ordering.normalized if ordering else None
[ "def", "get_ordering", "(", "self", ")", ":", "_", ",", "ordering", "=", "self", ".", "token_next_by", "(", "t", "=", "T", ".", "Keyword", ".", "Order", ")", "return", "ordering", ".", "normalized", "if", "ordering", "else", "None" ]
[ 458, 4 ]
[ 461, 56 ]
python
en
['en', 'en', 'en']
True
Identifier.get_array_indices
(self)
Returns an iterator of index token lists
Returns an iterator of index token lists
def get_array_indices(self): """Returns an iterator of index token lists""" for token in self.tokens: if isinstance(token, SquareBrackets): # Use [1:-1] index to discard the square brackets yield token.tokens[1:-1]
[ "def", "get_array_indices", "(", "self", ")", ":", "for", "token", "in", "self", ".", "tokens", ":", "if", "isinstance", "(", "token", ",", "SquareBrackets", ")", ":", "# Use [1:-1] index to discard the square brackets", "yield", "token", ".", "tokens", "[", "1"...
[ 463, 4 ]
[ 469, 40 ]
python
en
['en', 'en', 'en']
True
IdentifierList.get_identifiers
(self)
Returns the identifiers. Whitespaces and punctuations are not included in this generator.
Returns the identifiers.
def get_identifiers(self): """Returns the identifiers. Whitespaces and punctuations are not included in this generator. """ for token in self.tokens: if not (token.is_whitespace or token.match(T.Punctuation, ',')): yield token
[ "def", "get_identifiers", "(", "self", ")", ":", "for", "token", "in", "self", ".", "tokens", ":", "if", "not", "(", "token", ".", "is_whitespace", "or", "token", ".", "match", "(", "T", ".", "Punctuation", ",", "','", ")", ")", ":", "yield", "token"...
[ 475, 4 ]
[ 482, 27 ]
python
en
['en', 'nl', 'en']
True
Case.get_cases
(self, skip_ws=False)
Returns a list of 2-tuples (condition, value). If an ELSE exists condition is None.
Returns a list of 2-tuples (condition, value).
def get_cases(self, skip_ws=False): """Returns a list of 2-tuples (condition, value). If an ELSE exists condition is None. """ CONDITION = 1 VALUE = 2 ret = [] mode = CONDITION for token in self.tokens: # Set mode from the current statement ...
[ "def", "get_cases", "(", "self", ",", "skip_ws", "=", "False", ")", ":", "CONDITION", "=", "1", "VALUE", "=", "2", "ret", "=", "[", "]", "mode", "=", "CONDITION", "for", "token", "in", "self", ".", "tokens", ":", "# Set mode from the current statement", ...
[ 566, 4 ]
[ 611, 18 ]
python
en
['en', 'en', 'en']
True
Function.get_parameters
(self)
Return a list of parameters.
Return a list of parameters.
def get_parameters(self): """Return a list of parameters.""" parenthesis = self.tokens[-1] for token in parenthesis.tokens: if isinstance(token, IdentifierList): return token.get_identifiers() elif imt(token, i=(Function, Identifier), t=T.Literal): ...
[ "def", "get_parameters", "(", "self", ")", ":", "parenthesis", "=", "self", ".", "tokens", "[", "-", "1", "]", "for", "token", "in", "parenthesis", ".", "tokens", ":", "if", "isinstance", "(", "token", ",", "IdentifierList", ")", ":", "return", "token", ...
[ 617, 4 ]
[ 625, 17 ]
python
en
['en', 'en', 'en']
True
run
(argv=None)
The main function which creates the pipeline and runs it.
The main function which creates the pipeline and runs it.
def run(argv=None): """The main function which creates the pipeline and runs it.""" parser = argparse.ArgumentParser() # Here we add some specific command line arguments we expect. # This defaults the output table in your BigQuery you'll have # to create the example_data dataset yourself using bq mk...
[ "def", "run", "(", "argv", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "# Here we add some specific command line arguments we expect.", "# This defaults the output table in your BigQuery you'll have", "# to create the example_data dataset your...
[ 232, 0 ]
[ 324, 38 ]
python
en
['en', 'en', 'en']
True
DataLakeToDataMartCGBK.get_orders_query
(self)
This returns a query against a very large fact table. We are using a fake orders dataset to simulate a fact table in a typical data warehouse.
This returns a query against a very large fact table. We are using a fake orders dataset to simulate a fact table in a typical data warehouse.
def get_orders_query(self): """This returns a query against a very large fact table. We are using a fake orders dataset to simulate a fact table in a typical data warehouse.""" orders_query = """SELECT acct_number, col_number, col_number_1, ...
[ "def", "get_orders_query", "(", "self", ")", ":", "orders_query", "=", "\"\"\"SELECT\n acct_number,\n col_number,\n col_number_1,\n col_number_10,\n col_number_100,\n col_number_101,\n col_number_102,\n col_numbe...
[ 48, 4 ]
[ 206, 27 ]
python
en
['en', 'en', 'en']
True