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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
DataLakeToDataMartCGBK.add_account_details | (self, account_info) | This function performs the join of the two datasets. | This function performs the join of the two datasets. | def add_account_details(self, account_info):
"""This function performs the join of the two datasets."""
(acct_number, data) = account_info
result = list(data['orders'])
if not data['account_details']:
logging.info('account details are empty')
return
if not... | [
"def",
"add_account_details",
"(",
"self",
",",
"account_info",
")",
":",
"(",
"acct_number",
",",
"data",
")",
"=",
"account_info",
"result",
"=",
"list",
"(",
"data",
"[",
"'orders'",
"]",
")",
"if",
"not",
"data",
"[",
"'account_details'",
"]",
":",
"... | [
208,
4
] | [
229,
21
] | python | en | ['en', 'en', 'en'] | True |
HttpError._get_reason | (self) | Calculate the reason for the error from the response content. | Calculate the reason for the error from the response content. | def _get_reason(self):
"""Calculate the reason for the error from the response content."""
reason = self.resp.reason
try:
data = json.loads(self.content.decode('utf-8'))
if isinstance(data, dict):
reason = data['error']['message']
elif isinstance(data, list) and len(data) > 0:
... | [
"def",
"_get_reason",
"(",
"self",
")",
":",
"reason",
"=",
"self",
".",
"resp",
".",
"reason",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"content",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"if",
"isinstance",
"(",
"data",
",... | [
49,
2
] | [
63,
17
] | python | en | ['en', 'en', 'en'] | True |
UnexpectedMethodError.__init__ | (self, methodId=None) | Constructor for an UnexpectedMethodError. | Constructor for an UnexpectedMethodError. | def __init__(self, methodId=None):
"""Constructor for an UnexpectedMethodError."""
super(UnexpectedMethodError, self).__init__(
'Received unexpected call %s' % methodId) | [
"def",
"__init__",
"(",
"self",
",",
"methodId",
"=",
"None",
")",
":",
"super",
"(",
"UnexpectedMethodError",
",",
"self",
")",
".",
"__init__",
"(",
"'Received unexpected call %s'",
"%",
"methodId",
")"
] | [
140,
2
] | [
143,
49
] | python | en | ['en', 'gl', 'en'] | True |
UnexpectedBodyError.__init__ | (self, expected, provided) | Constructor for an UnexpectedMethodError. | Constructor for an UnexpectedMethodError. | def __init__(self, expected, provided):
"""Constructor for an UnexpectedMethodError."""
super(UnexpectedBodyError, self).__init__(
'Expected: [%s] - Provided: [%s]' % (expected, provided)) | [
"def",
"__init__",
"(",
"self",
",",
"expected",
",",
"provided",
")",
":",
"super",
"(",
"UnexpectedBodyError",
",",
"self",
")",
".",
"__init__",
"(",
"'Expected: [%s] - Provided: [%s]'",
"%",
"(",
"expected",
",",
"provided",
")",
")"
] | [
149,
2
] | [
152,
65
] | python | en | ['en', 'gl', 'en'] | True |
main | (args: (Optional[List[str]]) = None) | This is preserved for old console scripts that may still be referencing
it.
For additional details, see https://github.com/pypa/pip/issues/7498.
| This is preserved for old console scripts that may still be referencing
it. | def main(args: (Optional[List[str]]) = None) -> int:
"""This is preserved for old console scripts that may still be referencing
it.
For additional details, see https://github.com/pypa/pip/issues/7498.
"""
from pip._internal.utils.entrypoints import _wrapper
return _wrapper(args) | [
"def",
"main",
"(",
"args",
":",
"(",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
")",
"=",
"None",
")",
"->",
"int",
":",
"from",
"pip",
".",
"_internal",
".",
"utils",
".",
"entrypoints",
"import",
"_wrapper",
"return",
"_wrapper",
"(",
"args",
... | [
10,
0
] | [
18,
25
] | python | en | ['en', 'en', 'en'] | True |
was_installed_by_pip | (pkg) | Checks whether pkg was installed by pip
This is used not to display the upgrade message when pip is in fact
installed by system package manager, such as dnf on Fedora.
| Checks whether pkg was installed by pip | def was_installed_by_pip(pkg):
# type: (str) -> bool
"""Checks whether pkg was installed by pip
This is used not to display the upgrade message when pip is in fact
installed by system package manager, such as dnf on Fedora.
"""
dist = get_default_environment().get_distribution(pkg)
return d... | [
"def",
"was_installed_by_pip",
"(",
"pkg",
")",
":",
"# type: (str) -> bool",
"dist",
"=",
"get_default_environment",
"(",
")",
".",
"get_distribution",
"(",
"pkg",
")",
"return",
"dist",
"is",
"not",
"None",
"and",
"\"pip\"",
"==",
"dist",
".",
"installer"
] | [
92,
0
] | [
100,
55
] | python | en | ['en', 'en', 'en'] | True |
pip_self_version_check | (session, options) | Check for an update for pip.
Limit the frequency of checks to once per week. State is stored either in
the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
of the pip script path.
| Check for an update for pip. | def pip_self_version_check(session, options):
# type: (PipSession, optparse.Values) -> None
"""Check for an update for pip.
Limit the frequency of checks to once per week. State is stored either in
the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
of the pip script path.
... | [
"def",
"pip_self_version_check",
"(",
"session",
",",
"options",
")",
":",
"# type: (PipSession, optparse.Values) -> None",
"installed_dist",
"=",
"get_default_environment",
"(",
")",
".",
"get_distribution",
"(",
"\"pip\"",
")",
"if",
"not",
"installed_dist",
":",
"ret... | [
103,
0
] | [
186,
9
] | python | en | ['en', 'en', 'en'] | True |
main | () | Main entry point for demimove-ui. | Main entry point for demimove-ui. | def main():
"Main entry point for demimove-ui."
startdir = os.getcwd()
try:
args = docopt(__doc__, version="0.2")
# args["-v"] = 3 # Force debug logging
fileop = fileops.FileOps(verbosity=args["-v"],
quiet=args["--quiet"])
if args["<path>"]:
... | [
"def",
"main",
"(",
")",
":",
"startdir",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"args",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"\"0.2\"",
")",
"# args[\"-v\"] = 3 # Force debug logging",
"fileop",
"=",
"fileops",
".",
"FileOps... | [
829,
0
] | [
847,
25
] | python | en | ['es', 'en', 'en'] | True |
DemiMoveGUI.set_cwd | (self, index=None, force=False) | Set the current working directory for renaming actions. | Set the current working directory for renaming actions. | def set_cwd(self, index=None, force=False):
"Set the current working directory for renaming actions."
if not index:
index = self.get_index()
path = self.get_path(index)
if force or path != self.cwd and os.path.isdir(path):
self.cwd = path
self.cwdidx =... | [
"def",
"set_cwd",
"(",
"self",
",",
"index",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"index",
":",
"index",
"=",
"self",
".",
"get_index",
"(",
")",
"path",
"=",
"self",
".",
"get_path",
"(",
"index",
")",
"if",
"force",
"... | [
250,
4
] | [
263,
22
] | python | en | ['en', 'en', 'en'] | True |
DemiMoveGUI.keyPressEvent | (self, e) | Overloaded to connect return key to self.set_cwd(). | Overloaded to connect return key to self.set_cwd(). | def keyPressEvent(self, e):
"Overloaded to connect return key to self.set_cwd()."
# TODO: Move this to TreeView only.
if e.key() == QtCore.Qt.Key_Return:
self.set_cwd()
if e.key() == QtCore.Qt.Key_Delete:
self.delete_index() | [
"def",
"keyPressEvent",
"(",
"self",
",",
"e",
")",
":",
"# TODO: Move this to TreeView only.",
"if",
"e",
".",
"key",
"(",
")",
"==",
"QtCore",
".",
"Qt",
".",
"Key_Return",
":",
"self",
".",
"set_cwd",
"(",
")",
"if",
"e",
".",
"key",
"(",
")",
"==... | [
350,
4
] | [
356,
31
] | python | en | ['en', 'en', 'en'] | True |
DemiMoveGUI.update | (self, mode=1) | Main update routine using threading to get targets and/or previews | Main update routine using threading to get targets and/or previews | def update(self, mode=1):
"""Main update routine using threading to get targets and/or previews"""
# Modes: 0 = targets, 1 = previews, 2 = both.
self.fileops.stopupdate = False
if not self.autopreview or not self.cwd:
self.update_view()
return
self.updatet... | [
"def",
"update",
"(",
"self",
",",
"mode",
"=",
"1",
")",
":",
"# Modes: 0 = targets, 1 = previews, 2 = both.",
"self",
".",
"fileops",
".",
"stopupdate",
"=",
"False",
"if",
"not",
"self",
".",
"autopreview",
"or",
"not",
"self",
".",
"cwd",
":",
"self",
... | [
358,
4
] | [
366,
33
] | python | en | ['en', 'en', 'en'] | True |
DemiMoveGUI.on_saveoptionsbutton | (self) | Save current options to configfile. | Save current options to configfile. | def on_saveoptionsbutton(self):
"""Save current options to configfile."""
log.info("Saving options.")
helpers.save_configfile(self.fileops.configdir, self.get_options())
self.statusbar.showMessage("Configuration file saved.") | [
"def",
"on_saveoptionsbutton",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Saving options.\"",
")",
"helpers",
".",
"save_configfile",
"(",
"self",
".",
"fileops",
".",
"configdir",
",",
"self",
".",
"get_options",
"(",
")",
")",
"self",
".",
"statu... | [
491,
4
] | [
495,
63
] | python | en | ['en', 'en', 'en'] | True |
DemiMoveGUI.on_restoreoptionsbutton | (self) | Restore options to start point. | Restore options to start point. | def on_restoreoptionsbutton(self):
"""Restore options to start point."""
log.info("Restoring options.")
self.set_options(self.startoptions) | [
"def",
"on_restoreoptionsbutton",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Restoring options.\"",
")",
"self",
".",
"set_options",
"(",
"self",
".",
"startoptions",
")"
] | [
497,
4
] | [
500,
43
] | python | en | ['en', 'en', 'en'] | True |
DemiMoveGUI.on_clearoptionsbutton | (self) | Reset/Clear all options. | Reset/Clear all options. | def on_clearoptionsbutton(self):
"""Reset/Clear all options."""
log.info("Clearing options.")
self.set_options(sanitize=True) | [
"def",
"on_clearoptionsbutton",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Clearing options.\"",
")",
"self",
".",
"set_options",
"(",
"sanitize",
"=",
"True",
")"
] | [
502,
4
] | [
505,
39
] | python | en | ['en', 'en', 'en'] | True |
DemiMoveGUI.on_commitbutton | (self) | Perform the currently previewed rename actions. | Perform the currently previewed rename actions. | def on_commitbutton(self):
"""Perform the currently previewed rename actions."""
log.info("Committing previewed changes.")
if self.committhread.isRunning():
self.fileops.stopcommit = True
else:
self.fileops.stopcommit = False
self.committhread.start() | [
"def",
"on_commitbutton",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Committing previewed changes.\"",
")",
"if",
"self",
".",
"committhread",
".",
"isRunning",
"(",
")",
":",
"self",
".",
"fileops",
".",
"stopcommit",
"=",
"True",
"else",
":",
"se... | [
507,
4
] | [
514,
37
] | python | en | ['en', 'en', 'en'] | True |
DemiMoveGUI.on_undobutton | (self) | Pops the history stack of commits, reverting the one on top. | Pops the history stack of commits, reverting the one on top. | def on_undobutton(self):
"""Pops the history stack of commits, reverting the one on top."""
log.info("Reverting last commit.")
self.fileops.undo()
self.update(2) | [
"def",
"on_undobutton",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Reverting last commit.\"",
")",
"self",
".",
"fileops",
".",
"undo",
"(",
")",
"self",
".",
"update",
"(",
"2",
")"
] | [
516,
4
] | [
520,
22
] | python | en | ['en', 'en', 'en'] | True |
DemiMoveGUI.on_refreshbutton | (self) | Force a refresh of browser view and model. | Force a refresh of browser view and model. | def on_refreshbutton(self):
"""Force a refresh of browser view and model."""
if self.updatethread.isRunning():
self.fileops.stopupdate = True
else:
self.update(2) | [
"def",
"on_refreshbutton",
"(",
"self",
")",
":",
"if",
"self",
".",
"updatethread",
".",
"isRunning",
"(",
")",
":",
"self",
".",
"fileops",
".",
"stopupdate",
"=",
"True",
"else",
":",
"self",
".",
"update",
"(",
"2",
")"
] | [
522,
4
] | [
527,
26
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.__init__ | (self, path=None, cache=0, country=None, city=None) |
Initialize the GeoIP object. No parameters are required to use default
settings. Keyword arguments may be passed in to customize the locations
of the GeoIP datasets.
* path: Base directory to where GeoIP data is located or the full path
to where the city or country data fil... |
Initialize the GeoIP object. No parameters are required to use default
settings. Keyword arguments may be passed in to customize the locations
of the GeoIP datasets. | def __init__(self, path=None, cache=0, country=None, city=None):
"""
Initialize the GeoIP object. No parameters are required to use default
settings. Keyword arguments may be passed in to customize the locations
of the GeoIP datasets.
* path: Base directory to where GeoIP data i... | [
"def",
"__init__",
"(",
"self",
",",
"path",
"=",
"None",
",",
"cache",
"=",
"0",
",",
"country",
"=",
"None",
",",
"city",
"=",
"None",
")",
":",
"# Checking the given cache option.",
"if",
"cache",
"in",
"self",
".",
"cache_options",
":",
"self",
".",
... | [
45,
4
] | [
113,
82
] | python | en | ['en', 'error', 'th'] | False |
GeoIP2._check_query | (self, query, country=False, city=False, city_or_country=False) | Check the query and database availability. | Check the query and database availability. | def _check_query(self, query, country=False, city=False, city_or_country=False):
"Check the query and database availability."
# Making sure a string was passed in for the query.
if not isinstance(query, str):
raise TypeError('GeoIP query must be a string, not type %s' % type(query)._... | [
"def",
"_check_query",
"(",
"self",
",",
"query",
",",
"country",
"=",
"False",
",",
"city",
"=",
"False",
",",
"city_or_country",
"=",
"False",
")",
":",
"# Making sure a string was passed in for the query.",
"if",
"not",
"isinstance",
"(",
"query",
",",
"str",... | [
141,
4
] | [
161,
20
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.city | (self, query) |
Return a dictionary of city information for the given IP address or
Fully Qualified Domain Name (FQDN). Some information in the dictionary
may be undefined (None).
|
Return a dictionary of city information for the given IP address or
Fully Qualified Domain Name (FQDN). Some information in the dictionary
may be undefined (None).
| def city(self, query):
"""
Return a dictionary of city information for the given IP address or
Fully Qualified Domain Name (FQDN). Some information in the dictionary
may be undefined (None).
"""
enc_query = self._check_query(query, city=True)
return City(self._cit... | [
"def",
"city",
"(",
"self",
",",
"query",
")",
":",
"enc_query",
"=",
"self",
".",
"_check_query",
"(",
"query",
",",
"city",
"=",
"True",
")",
"return",
"City",
"(",
"self",
".",
"_city",
".",
"city",
"(",
"enc_query",
")",
")"
] | [
163,
4
] | [
170,
47
] | python | en | ['en', 'error', 'th'] | False |
GeoIP2.country_code | (self, query) | Return the country code for the given IP Address or FQDN. | Return the country code for the given IP Address or FQDN. | def country_code(self, query):
"Return the country code for the given IP Address or FQDN."
enc_query = self._check_query(query, city_or_country=True)
return self.country(enc_query)['country_code'] | [
"def",
"country_code",
"(",
"self",
",",
"query",
")",
":",
"enc_query",
"=",
"self",
".",
"_check_query",
"(",
"query",
",",
"city_or_country",
"=",
"True",
")",
"return",
"self",
".",
"country",
"(",
"enc_query",
")",
"[",
"'country_code'",
"]"
] | [
172,
4
] | [
175,
54
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.country_name | (self, query) | Return the country name for the given IP Address or FQDN. | Return the country name for the given IP Address or FQDN. | def country_name(self, query):
"Return the country name for the given IP Address or FQDN."
enc_query = self._check_query(query, city_or_country=True)
return self.country(enc_query)['country_name'] | [
"def",
"country_name",
"(",
"self",
",",
"query",
")",
":",
"enc_query",
"=",
"self",
".",
"_check_query",
"(",
"query",
",",
"city_or_country",
"=",
"True",
")",
"return",
"self",
".",
"country",
"(",
"enc_query",
")",
"[",
"'country_name'",
"]"
] | [
177,
4
] | [
180,
54
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.country | (self, query) |
Return a dictionary with the country code and name when given an
IP address or a Fully Qualified Domain Name (FQDN). For example, both
'24.124.1.80' and 'djangoproject.com' are valid parameters.
|
Return a dictionary with the country code and name when given an
IP address or a Fully Qualified Domain Name (FQDN). For example, both
'24.124.1.80' and 'djangoproject.com' are valid parameters.
| def country(self, query):
"""
Return a dictionary with the country code and name when given an
IP address or a Fully Qualified Domain Name (FQDN). For example, both
'24.124.1.80' and 'djangoproject.com' are valid parameters.
"""
# Returning the country code and name
... | [
"def",
"country",
"(",
"self",
",",
"query",
")",
":",
"# Returning the country code and name",
"enc_query",
"=",
"self",
".",
"_check_query",
"(",
"query",
",",
"city_or_country",
"=",
"True",
")",
"return",
"Country",
"(",
"self",
".",
"_country_or_city",
"(",... | [
182,
4
] | [
190,
56
] | python | en | ['en', 'error', 'th'] | False |
GeoIP2.lon_lat | (self, query) | Return a tuple of the (longitude, latitude) for the given query. | Return a tuple of the (longitude, latitude) for the given query. | def lon_lat(self, query):
"Return a tuple of the (longitude, latitude) for the given query."
return self.coords(query) | [
"def",
"lon_lat",
"(",
"self",
",",
"query",
")",
":",
"return",
"self",
".",
"coords",
"(",
"query",
")"
] | [
200,
4
] | [
202,
33
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.lat_lon | (self, query) | Return a tuple of the (latitude, longitude) for the given query. | Return a tuple of the (latitude, longitude) for the given query. | def lat_lon(self, query):
"Return a tuple of the (latitude, longitude) for the given query."
return self.coords(query, ('latitude', 'longitude')) | [
"def",
"lat_lon",
"(",
"self",
",",
"query",
")",
":",
"return",
"self",
".",
"coords",
"(",
"query",
",",
"(",
"'latitude'",
",",
"'longitude'",
")",
")"
] | [
204,
4
] | [
206,
60
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.geos | (self, query) | Return a GEOS Point object for the given query. | Return a GEOS Point object for the given query. | def geos(self, query):
"Return a GEOS Point object for the given query."
ll = self.lon_lat(query)
if ll:
from django.contrib.gis.geos import Point
return Point(ll, srid=4326)
else:
return None | [
"def",
"geos",
"(",
"self",
",",
"query",
")",
":",
"ll",
"=",
"self",
".",
"lon_lat",
"(",
"query",
")",
"if",
"ll",
":",
"from",
"django",
".",
"contrib",
".",
"gis",
".",
"geos",
"import",
"Point",
"return",
"Point",
"(",
"ll",
",",
"srid",
"=... | [
208,
4
] | [
215,
23
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.info | (self) | Return information about the GeoIP library and databases in use. | Return information about the GeoIP library and databases in use. | def info(self):
"Return information about the GeoIP library and databases in use."
meta = self._reader.metadata()
return 'GeoIP Library:\n\t%s.%s\n' % (meta.binary_format_major_version, meta.binary_format_minor_version) | [
"def",
"info",
"(",
"self",
")",
":",
"meta",
"=",
"self",
".",
"_reader",
".",
"metadata",
"(",
")",
"return",
"'GeoIP Library:\\n\\t%s.%s\\n'",
"%",
"(",
"meta",
".",
"binary_format_major_version",
",",
"meta",
".",
"binary_format_minor_version",
")"
] | [
219,
4
] | [
222,
113
] | python | en | ['en', 'en', 'en'] | True |
run_tests | (session, dir=None) | Run all tests for all directories (slow!) | Run all tests for all directories (slow!) | def run_tests(session, dir=None):
"""Run all tests for all directories (slow!)"""
run_test(session, dir) | [
"def",
"run_tests",
"(",
"session",
",",
"dir",
"=",
"None",
")",
":",
"run_test",
"(",
"session",
",",
"dir",
")"
] | [
59,
0
] | [
61,
26
] | python | en | ['en', 'en', 'en'] | True |
SigningAlgorithm.get_signature | (self, key, value) | Returns the signature for the given key and value. | Returns the signature for the given key and value. | def get_signature(self, key, value):
"""Returns the signature for the given key and value."""
raise NotImplementedError() | [
"def",
"get_signature",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
16,
4
] | [
18,
35
] | python | en | ['en', 'en', 'en'] | True |
SigningAlgorithm.verify_signature | (self, key, value, sig) | Verifies the given signature matches the expected
signature.
| Verifies the given signature matches the expected
signature.
| def verify_signature(self, key, value, sig):
"""Verifies the given signature matches the expected
signature.
"""
return constant_time_compare(sig, self.get_signature(key, value)) | [
"def",
"verify_signature",
"(",
"self",
",",
"key",
",",
"value",
",",
"sig",
")",
":",
"return",
"constant_time_compare",
"(",
"sig",
",",
"self",
".",
"get_signature",
"(",
"key",
",",
"value",
")",
")"
] | [
20,
4
] | [
24,
73
] | python | en | ['en', 'en', 'en'] | True |
Signer.derive_key | (self) | This method is called to derive the key. The default key
derivation choices can be overridden here. Key derivation is not
intended to be used as a security method to make a complex key
out of a short password. Instead you should use large random
secret keys.
| This method is called to derive the key. The default key
derivation choices can be overridden here. Key derivation is not
intended to be used as a security method to make a complex key
out of a short password. Instead you should use large random
secret keys.
| def derive_key(self):
"""This method is called to derive the key. The default key
derivation choices can be overridden here. Key derivation is not
intended to be used as a security method to make a complex key
out of a short password. Instead you should use large random
secret ke... | [
"def",
"derive_key",
"(",
"self",
")",
":",
"salt",
"=",
"want_bytes",
"(",
"self",
".",
"salt",
")",
"if",
"self",
".",
"key_derivation",
"==",
"\"concat\"",
":",
"return",
"self",
".",
"digest_method",
"(",
"salt",
"+",
"self",
".",
"secret_key",
")",
... | [
118,
4
] | [
137,
60
] | python | en | ['en', 'en', 'en'] | True |
Signer.get_signature | (self, value) | Returns the signature for the given value. | Returns the signature for the given value. | def get_signature(self, value):
"""Returns the signature for the given value."""
value = want_bytes(value)
key = self.derive_key()
sig = self.algorithm.get_signature(key, value)
return base64_encode(sig) | [
"def",
"get_signature",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"want_bytes",
"(",
"value",
")",
"key",
"=",
"self",
".",
"derive_key",
"(",
")",
"sig",
"=",
"self",
".",
"algorithm",
".",
"get_signature",
"(",
"key",
",",
"value",
")",
"r... | [
139,
4
] | [
144,
33
] | python | en | ['en', 'en', 'en'] | True |
Signer.sign | (self, value) | Signs the given string. | Signs the given string. | def sign(self, value):
"""Signs the given string."""
return want_bytes(value) + want_bytes(self.sep) + self.get_signature(value) | [
"def",
"sign",
"(",
"self",
",",
"value",
")",
":",
"return",
"want_bytes",
"(",
"value",
")",
"+",
"want_bytes",
"(",
"self",
".",
"sep",
")",
"+",
"self",
".",
"get_signature",
"(",
"value",
")"
] | [
146,
4
] | [
148,
83
] | python | en | ['en', 'en', 'en'] | True |
Signer.verify_signature | (self, value, sig) | Verifies the signature for the given value. | Verifies the signature for the given value. | def verify_signature(self, value, sig):
"""Verifies the signature for the given value."""
key = self.derive_key()
try:
sig = base64_decode(sig)
except Exception:
return False
return self.algorithm.verify_signature(key, value, sig) | [
"def",
"verify_signature",
"(",
"self",
",",
"value",
",",
"sig",
")",
":",
"key",
"=",
"self",
".",
"derive_key",
"(",
")",
"try",
":",
"sig",
"=",
"base64_decode",
"(",
"sig",
")",
"except",
"Exception",
":",
"return",
"False",
"return",
"self",
".",... | [
150,
4
] | [
157,
63
] | python | en | ['en', 'en', 'en'] | True |
Signer.unsign | (self, signed_value) | Unsigns the given string. | Unsigns the given string. | def unsign(self, signed_value):
"""Unsigns the given string."""
signed_value = want_bytes(signed_value)
sep = want_bytes(self.sep)
if sep not in signed_value:
raise BadSignature("No %r found in value" % self.sep)
value, sig = signed_value.rsplit(sep, 1)
if sel... | [
"def",
"unsign",
"(",
"self",
",",
"signed_value",
")",
":",
"signed_value",
"=",
"want_bytes",
"(",
"signed_value",
")",
"sep",
"=",
"want_bytes",
"(",
"self",
".",
"sep",
")",
"if",
"sep",
"not",
"in",
"signed_value",
":",
"raise",
"BadSignature",
"(",
... | [
159,
4
] | [
168,
78
] | python | en | ['en', 'en', 'en'] | True |
Signer.validate | (self, signed_value) | Only validates the given signed value. Returns ``True`` if
the signature exists and is valid.
| Only validates the given signed value. Returns ``True`` if
the signature exists and is valid.
| def validate(self, signed_value):
"""Only validates the given signed value. Returns ``True`` if
the signature exists and is valid.
"""
try:
self.unsign(signed_value)
return True
except BadSignature:
return False | [
"def",
"validate",
"(",
"self",
",",
"signed_value",
")",
":",
"try",
":",
"self",
".",
"unsign",
"(",
"signed_value",
")",
"return",
"True",
"except",
"BadSignature",
":",
"return",
"False"
] | [
170,
4
] | [
178,
24
] | python | en | ['en', 'en', 'en'] | True |
BaseHeuristic.warning | (self, response) |
Return a valid 1xx warning header value describing the cache
adjustments.
The response is provided too allow warnings like 113
http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need
to explicitly say response is over 24 hours old.
|
Return a valid 1xx warning header value describing the cache
adjustments. | def warning(self, response):
"""
Return a valid 1xx warning header value describing the cache
adjustments.
The response is provided too allow warnings like 113
http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need
to explicitly say response is over 24 hours old.... | [
"def",
"warning",
"(",
"self",
",",
"response",
")",
":",
"return",
"'110 - \"Response is Stale\"'"
] | [
21,
4
] | [
30,
42
] | python | en | ['en', 'error', 'th'] | False |
BaseHeuristic.update_headers | (self, response) | Update the response headers with any new headers.
NOTE: This SHOULD always include some Warning header to
signify that the response was cached by the client, not
by way of the provided headers.
| Update the response headers with any new headers. | def update_headers(self, response):
"""Update the response headers with any new headers.
NOTE: This SHOULD always include some Warning header to
signify that the response was cached by the client, not
by way of the provided headers.
"""
return {} | [
"def",
"update_headers",
"(",
"self",
",",
"response",
")",
":",
"return",
"{",
"}"
] | [
32,
4
] | [
39,
17
] | python | en | ['en', 'en', 'en'] | True |
CloudinaryJsFileField.to_python | (self, value) | Convert to CloudinaryResource | Convert to CloudinaryResource | def to_python(self, value):
"""Convert to CloudinaryResource"""
if not value:
return None
m = re.search(r'^([^/]+)/([^/]+)/v(\d+)/([^#]+)#([^/]+)$', value)
if not m:
raise forms.ValidationError("Invalid format")
resource_type = m.group(1)
upload_ty... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"m",
"=",
"re",
".",
"search",
"(",
"r'^([^/]+)/([^/]+)/v(\\d+)/([^#]+)#([^/]+)$'",
",",
"value",
")",
"if",
"not",
"m",
":",
"raise",
"forms",
".",
"Va... | [
75,
4
] | [
97,
62
] | python | en | ['en', 'su', 'en'] | True |
CloudinaryJsFileField.validate | (self, value) | Validate the signature | Validate the signature | def validate(self, value):
"""Validate the signature"""
# Use the parent's handling of required fields, etc.
super(CloudinaryJsFileField, self).validate(value)
if not value:
return
if not value.validate():
raise forms.ValidationError("Signature mismatch") | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"# Use the parent's handling of required fields, etc.",
"super",
"(",
"CloudinaryJsFileField",
",",
"self",
")",
".",
"validate",
"(",
"value",
")",
"if",
"not",
"value",
":",
"return",
"if",
"not",
"value"... | [
99,
4
] | [
106,
61
] | python | en | ['en', 'la', 'en'] | True |
CloudinaryFileField.to_python | (self, value) | Upload and convert to CloudinaryResource | Upload and convert to CloudinaryResource | def to_python(self, value):
"""Upload and convert to CloudinaryResource"""
value = super(CloudinaryFileField, self).to_python(value)
if not value:
return None
if self.autosave:
return cloudinary.uploader.upload_image(value, **self.options)
else:
... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"super",
"(",
"CloudinaryFileField",
",",
"self",
")",
".",
"to_python",
"(",
"value",
")",
"if",
"not",
"value",
":",
"return",
"None",
"if",
"self",
".",
"autosave",
":",
"return"... | [
133,
4
] | [
141,
24
] | python | en | ['en', 'en', 'en'] | True |
serve | (request, path, insecure=False, **kwargs) |
Serve static files below a given point in the directory structure or
from locations inferred from the staticfiles finders.
To use, put a URL pattern such as::
from django.contrib.staticfiles import views
path('<path:path>', views.serve)
in your URLconf.
It uses the django.views... |
Serve static files below a given point in the directory structure or
from locations inferred from the staticfiles finders. | def serve(request, path, insecure=False, **kwargs):
"""
Serve static files below a given point in the directory structure or
from locations inferred from the staticfiles finders.
To use, put a URL pattern such as::
from django.contrib.staticfiles import views
path('<path:path>', views... | [
"def",
"serve",
"(",
"request",
",",
"path",
",",
"insecure",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"settings",
".",
"DEBUG",
"and",
"not",
"insecure",
":",
"raise",
"Http404",
"normalized_path",
"=",
"posixpath",
".",
"normpath",... | [
14,
0
] | [
38,
77
] | python | en | ['en', 'error', 'th'] | False |
glob | (pathname, recursive=False) | Return a list of paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la
fnmatch. However, unlike fnmatch, filenames starting with a
dot are special cases that are not matched by '*' and '?'
patterns.
If recursive is true, the pattern '**' will match any files ... | Return a list of paths matching a pathname pattern. | def glob(pathname, recursive=False):
"""Return a list of paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la
fnmatch. However, unlike fnmatch, filenames starting with a
dot are special cases that are not matched by '*' and '?'
patterns.
If recursive is ... | [
"def",
"glob",
"(",
"pathname",
",",
"recursive",
"=",
"False",
")",
":",
"return",
"list",
"(",
"iglob",
"(",
"pathname",
",",
"recursive",
"=",
"recursive",
")",
")"
] | [
17,
0
] | [
28,
53
] | python | en | ['en', 'en', 'en'] | True |
iglob | (pathname, recursive=False) | Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la
fnmatch. However, unlike fnmatch, filenames starting with a
dot are special cases that are not matched by '*' and '?'
patterns.
If recursive is true, the pattern '**' wi... | Return an iterator which yields the paths matching a pathname pattern. | def iglob(pathname, recursive=False):
"""Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la
fnmatch. However, unlike fnmatch, filenames starting with a
dot are special cases that are not matched by '*' and '?'
patterns.
... | [
"def",
"iglob",
"(",
"pathname",
",",
"recursive",
"=",
"False",
")",
":",
"it",
"=",
"_iglob",
"(",
"pathname",
",",
"recursive",
")",
"if",
"recursive",
"and",
"_isrecursive",
"(",
"pathname",
")",
":",
"s",
"=",
"next",
"(",
"it",
")",
"# skip empty... | [
31,
0
] | [
46,
13
] | python | en | ['en', 'en', 'en'] | True |
escape | (pathname) | Escape all special characters.
| Escape all special characters.
| def escape(pathname):
"""Escape all special characters.
"""
# Escaping is done by wrapping any of "*?[" between square brackets.
# Metacharacters do not work in the drive part and shouldn't be escaped.
drive, pathname = os.path.splitdrive(pathname)
if isinstance(pathname, binary_type):
p... | [
"def",
"escape",
"(",
"pathname",
")",
":",
"# Escaping is done by wrapping any of \"*?[\" between square brackets.",
"# Metacharacters do not work in the drive part and shouldn't be escaped.",
"drive",
",",
"pathname",
"=",
"os",
".",
"path",
".",
"splitdrive",
"(",
"pathname",
... | [
165,
0
] | [
175,
27
] | python | en | ['en', 'en', 'en'] | True |
cria_cardapios | (cardapios_por_data) |
Recebe objetos de Refeicao agrupados por data em um dicionario e retorna uma lista de objetos Cardapios a partir desse dicionario.
:param cardapios_por_data: dicionario do tipo {String: [Refeicao]}, onde a string eh uma data.
:return: lista com os objetos Cardapio instanciados.
|
Recebe objetos de Refeicao agrupados por data em um dicionario e retorna uma lista de objetos Cardapios a partir desse dicionario. | def cria_cardapios(cardapios_por_data):
"""
Recebe objetos de Refeicao agrupados por data em um dicionario e retorna uma lista de objetos Cardapios a partir desse dicionario.
:param cardapios_por_data: dicionario do tipo {String: [Refeicao]}, onde a string eh uma data.
:return: lista com os objetos Car... | [
"def",
"cria_cardapios",
"(",
"cardapios_por_data",
")",
":",
"cardapios",
"=",
"[",
"]",
"chaves_para_tipos",
"=",
"{",
"'Almoço':",
"'",
"almoco',",
"",
"'Almoço vegetariano':",
" ",
"almoco_vegetariano',",
"",
"'Jantar'",
":",
"'jantar'",
",",
"'Jantar vegetarian... | [
19,
0
] | [
41,
20
] | python | en | ['en', 'error', 'th'] | False |
cria_refeicoes | (refeicoes_list) |
Cria um dicionario que agrupas objetos da classe Refeicao por data a partir de uma lista de dicionarios contendo informacoes das refeicoes.
:param refeicoes_list: Lista com refeicoes em dicionarios.
:return: Dicionario que mapeia datas a uma lista com objetos Refeicao contendo o cardapios daquela data.
... |
Cria um dicionario que agrupas objetos da classe Refeicao por data a partir de uma lista de dicionarios contendo informacoes das refeicoes. | def cria_refeicoes(refeicoes_list):
"""
Cria um dicionario que agrupas objetos da classe Refeicao por data a partir de uma lista de dicionarios contendo informacoes das refeicoes.
:param refeicoes_list: Lista com refeicoes em dicionarios.
:return: Dicionario que mapeia datas a uma lista com objetos Re... | [
"def",
"cria_refeicoes",
"(",
"refeicoes_list",
")",
":",
"cardapios_por_data",
"=",
"{",
"}",
"for",
"ref",
"in",
"refeicoes_list",
":",
"try",
":",
"d",
"=",
"ref",
"[",
"'data'",
"]",
"except",
"KeyError",
"as",
"e",
":",
"print",
"(",
"\"KeyError nas d... | [
47,
0
] | [
81,
29
] | python | en | ['en', 'error', 'th'] | False |
request_data_from_unicamp | () |
Responsavel por fazer o request ao webservices da UNICAMP e armazenar a resposta no firebase.
Esse metodo configura o add-on do Heroku que garante que todos os outbounds requests utilizando esse proxy sao feitos a partir de um IP fixo.
|
Responsavel por fazer o request ao webservices da UNICAMP e armazenar a resposta no firebase. | def request_data_from_unicamp():
""""
Responsavel por fazer o request ao webservices da UNICAMP e armazenar a resposta no firebase.
Esse metodo configura o add-on do Heroku que garante que todos os outbounds requests utilizando esse proxy sao feitos a partir de um IP fixo.
"""
proxyDict... | [
"def",
"request_data_from_unicamp",
"(",
")",
":",
"proxyDict",
"=",
"{",
"\"http\"",
":",
"environment_vars",
".",
"FIXIE_URL",
",",
"\"https\"",
":",
"environment_vars",
".",
"FIXIE_URL",
"}",
"try",
":",
"print",
"(",
"\"Opcao 1: Executando request para o API da UN... | [
84,
0
] | [
145,
23
] | python | en | ['en', 'error', 'th'] | False |
request_cardapio | (raw_json) |
Obtem o JSON original contendo todas as informacoes dos proximos cardapios e retorna uma lista com as refeicoes em dicionarios, para comecar o processo de criacao dos objetos de tipo Refeicao e Cardapio.
:param raw_json: parametro opcional que contem as informacoes obtidas com o API da Unicamp em formato de ... |
Obtem o JSON original contendo todas as informacoes dos proximos cardapios e retorna uma lista com as refeicoes em dicionarios, para comecar o processo de criacao dos objetos de tipo Refeicao e Cardapio. | def request_cardapio(raw_json):
"""
Obtem o JSON original contendo todas as informacoes dos proximos cardapios e retorna uma lista com as refeicoes em dicionarios, para comecar o processo de criacao dos objetos de tipo Refeicao e Cardapio.
:param raw_json: parametro opcional que contem as informacoes obti... | [
"def",
"request_cardapio",
"(",
"raw_json",
")",
":",
"# so faz request pro firebase se nao tiver o json.",
"if",
"raw_json",
"==",
"None",
":",
"db",
"=",
"setup_firebase",
"(",
")",
"raw_json",
"=",
"db",
".",
"child",
"(",
"\"cardapio_raw_json\"",
")",
".",
"ge... | [
151,
0
] | [
179,
25
] | python | en | ['en', 'error', 'th'] | False |
get_all_cardapios | (raw_json=None) |
Fornece uma lista de objetos Cardapio (contendo todos os cardapios disponiveis). O JSON com as informacoes e obtido pelo firebase e passa por um processo de "limpeza". Esse JSON e obtido pelo API da Unicamp e salvo no firebase utilizando a funcao `request_data_from_unicamp` (mais informacoes la).
Como o modulo... |
Fornece uma lista de objetos Cardapio (contendo todos os cardapios disponiveis). O JSON com as informacoes e obtido pelo firebase e passa por um processo de "limpeza". Esse JSON e obtido pelo API da Unicamp e salvo no firebase utilizando a funcao `request_data_from_unicamp` (mais informacoes la).
Como o modulo... | def get_all_cardapios(raw_json=None):
"""
Fornece uma lista de objetos Cardapio (contendo todos os cardapios disponiveis). O JSON com as informacoes e obtido pelo firebase e passa por um processo de "limpeza". Esse JSON e obtido pelo API da Unicamp e salvo no firebase utilizando a funcao `request_data_from_unic... | [
"def",
"get_all_cardapios",
"(",
"raw_json",
"=",
"None",
")",
":",
"refeicoes_list",
"=",
"request_cardapio",
"(",
"raw_json",
")",
"# faz o request e recebe uma lista contendo as refeicoes em dicionarios.",
"limpa_chaves",
"(",
"refeicoes_list",
")",
"# faz a limpeza das info... | [
203,
0
] | [
225,
27
] | python | en | ['en', 'error', 'th'] | False |
features_and_labels | (row_data) | Splits features and labels from feature dictionary.
Args:
row_data: Dictionary of CSV column names and tensor values.
Returns:
Dictionary of feature tensors and label tensor.
| Splits features and labels from feature dictionary. | def features_and_labels(row_data):
"""Splits features and labels from feature dictionary.
Args:
row_data: Dictionary of CSV column names and tensor values.
Returns:
Dictionary of feature tensors and label tensor.
"""
label = row_data.pop(LABEL_COLUMN)
return row_data, label | [
"def",
"features_and_labels",
"(",
"row_data",
")",
":",
"label",
"=",
"row_data",
".",
"pop",
"(",
"LABEL_COLUMN",
")",
"return",
"row_data",
",",
"label"
] | [
19,
0
] | [
29,
26
] | python | en | ['en', 'en', 'en'] | True |
load_dataset | (pattern, batch_size=1, mode='eval') | Loads dataset using the tf.data API from CSV files.
Args:
pattern: str, file pattern to glob into list of files.
batch_size: int, the number of examples per batch.
mode: 'eval' | 'train' to determine if training or evaluating.
Returns:
`Dataset` object.
| Loads dataset using the tf.data API from CSV files. | def load_dataset(pattern, batch_size=1, mode='eval'):
"""Loads dataset using the tf.data API from CSV files.
Args:
pattern: str, file pattern to glob into list of files.
batch_size: int, the number of examples per batch.
mode: 'eval' | 'train' to determine if training or evaluating.
... | [
"def",
"load_dataset",
"(",
"pattern",
",",
"batch_size",
"=",
"1",
",",
"mode",
"=",
"'eval'",
")",
":",
"print",
"(",
"\"mode = {}\"",
".",
"format",
"(",
"mode",
")",
")",
"# Make a CSV dataset",
"dataset",
"=",
"tf",
".",
"data",
".",
"experimental",
... | [
32,
0
] | [
60,
18
] | python | en | ['en', 'en', 'en'] | True |
create_input_layers | () | Creates dictionary of input layers for each feature.
Returns:
Dictionary of `tf.Keras.layers.Input` layers for each feature.
| Creates dictionary of input layers for each feature. | def create_input_layers():
"""Creates dictionary of input layers for each feature.
Returns:
Dictionary of `tf.Keras.layers.Input` layers for each feature.
"""
deep_inputs = {
colname: tf.keras.layers.Input(
name=colname, shape=(), dtype="float32")
for colname in ["mo... | [
"def",
"create_input_layers",
"(",
")",
":",
"deep_inputs",
"=",
"{",
"colname",
":",
"tf",
".",
"keras",
".",
"layers",
".",
"Input",
"(",
"name",
"=",
"colname",
",",
"shape",
"=",
"(",
")",
",",
"dtype",
"=",
"\"float32\"",
")",
"for",
"colname",
... | [
63,
0
] | [
83,
17
] | python | en | ['en', 'en', 'en'] | True |
categorical_fc | (name, values) | Helper function to wrap categorical feature by indicator column.
Args:
name: str, name of feature.
values: list, list of strings of categorical values.
Returns:
Categorical and indicator column of categorical feature.
| Helper function to wrap categorical feature by indicator column. | def categorical_fc(name, values):
"""Helper function to wrap categorical feature by indicator column.
Args:
name: str, name of feature.
values: list, list of strings of categorical values.
Returns:
Categorical and indicator column of categorical feature.
"""
cat_column = tf.... | [
"def",
"categorical_fc",
"(",
"name",
",",
"values",
")",
":",
"cat_column",
"=",
"tf",
".",
"feature_column",
".",
"categorical_column_with_vocabulary_list",
"(",
"key",
"=",
"name",
",",
"vocabulary_list",
"=",
"values",
")",
"ind_column",
"=",
"tf",
".",
"f... | [
86,
0
] | [
100,
33
] | python | en | ['en', 'en', 'en'] | True |
create_feature_columns | (nembeds) | Creates wide and deep dictionaries of feature columns from inputs.
Args:
nembeds: int, number of dimensions to embed categorical column down to.
Returns:
Wide and deep dictionaries of feature columns.
| Creates wide and deep dictionaries of feature columns from inputs. | def create_feature_columns(nembeds):
"""Creates wide and deep dictionaries of feature columns from inputs.
Args:
nembeds: int, number of dimensions to embed categorical column down to.
Returns:
Wide and deep dictionaries of feature columns.
"""
deep_fc = {
colname: tf.featur... | [
"def",
"create_feature_columns",
"(",
"nembeds",
")",
":",
"deep_fc",
"=",
"{",
"colname",
":",
"tf",
".",
"feature_column",
".",
"numeric_column",
"(",
"key",
"=",
"colname",
")",
"for",
"colname",
"in",
"[",
"\"mother_age\"",
",",
"\"gestation_weeks\"",
"]",... | [
103,
0
] | [
142,
27
] | python | en | ['en', 'en', 'en'] | True |
get_model_outputs | (wide_inputs, deep_inputs, dnn_hidden_units) | Creates model architecture and returns outputs.
Args:
wide_inputs: Dense tensor used as inputs to wide side of model.
deep_inputs: Dense tensor used as inputs to deep side of model.
dnn_hidden_units: List of integers where length is number of hidden
layers and ith element is the... | Creates model architecture and returns outputs. | def get_model_outputs(wide_inputs, deep_inputs, dnn_hidden_units):
"""Creates model architecture and returns outputs.
Args:
wide_inputs: Dense tensor used as inputs to wide side of model.
deep_inputs: Dense tensor used as inputs to deep side of model.
dnn_hidden_units: List of integers ... | [
"def",
"get_model_outputs",
"(",
"wide_inputs",
",",
"deep_inputs",
",",
"dnn_hidden_units",
")",
":",
"# Hidden layers for the deep side",
"layers",
"=",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"dnn_hidden_units",
"]",
"deep",
"=",
"deep_inputs",
"for",
"l... | [
145,
0
] | [
178,
17
] | python | en | ['en', 'en', 'en'] | True |
rmse | (y_true, y_pred) | Calculates RMSE evaluation metric.
Args:
y_true: tensor, true labels.
y_pred: tensor, predicted labels.
Returns:
Tensor with value of RMSE between true and predicted labels.
| Calculates RMSE evaluation metric. | def rmse(y_true, y_pred):
"""Calculates RMSE evaluation metric.
Args:
y_true: tensor, true labels.
y_pred: tensor, predicted labels.
Returns:
Tensor with value of RMSE between true and predicted labels.
"""
return tf.sqrt(tf.reduce_mean(tf.square(y_pred - y_true))) | [
"def",
"rmse",
"(",
"y_true",
",",
"y_pred",
")",
":",
"return",
"tf",
".",
"sqrt",
"(",
"tf",
".",
"reduce_mean",
"(",
"tf",
".",
"square",
"(",
"y_pred",
"-",
"y_true",
")",
")",
")"
] | [
181,
0
] | [
190,
62
] | python | en | ['en', 'en', 'en'] | True |
build_wide_deep_model | (dnn_hidden_units=[64, 32], nembeds=3) | Builds wide and deep model using Keras Functional API.
Returns:
`tf.keras.models.Model` object.
| Builds wide and deep model using Keras Functional API. | def build_wide_deep_model(dnn_hidden_units=[64, 32], nembeds=3):
"""Builds wide and deep model using Keras Functional API.
Returns:
`tf.keras.models.Model` object.
"""
# Create input layers
inputs = create_input_layers()
# Create feature columns for both wide and deep
wide_fc, deep... | [
"def",
"build_wide_deep_model",
"(",
"dnn_hidden_units",
"=",
"[",
"64",
",",
"32",
"]",
",",
"nembeds",
"=",
"3",
")",
":",
"# Create input layers",
"inputs",
"=",
"create_input_layers",
"(",
")",
"# Create feature columns for both wide and deep",
"wide_fc",
",",
"... | [
193,
0
] | [
219,
16
] | python | en | ['en', 'en', 'en'] | True |
get_connection | (using=None) |
Get a database connection by name, or the default database connection
if no name is provided. This is a private API.
|
Get a database connection by name, or the default database connection
if no name is provided. This is a private API.
| def get_connection(using=None):
"""
Get a database connection by name, or the default database connection
if no name is provided. This is a private API.
"""
if using is None:
using = DEFAULT_DB_ALIAS
return connections[using] | [
"def",
"get_connection",
"(",
"using",
"=",
"None",
")",
":",
"if",
"using",
"is",
"None",
":",
"using",
"=",
"DEFAULT_DB_ALIAS",
"return",
"connections",
"[",
"using",
"]"
] | [
12,
0
] | [
19,
29
] | python | en | ['en', 'error', 'th'] | False |
get_autocommit | (using=None) | Get the autocommit status of the connection. | Get the autocommit status of the connection. | def get_autocommit(using=None):
"""Get the autocommit status of the connection."""
return get_connection(using).get_autocommit() | [
"def",
"get_autocommit",
"(",
"using",
"=",
"None",
")",
":",
"return",
"get_connection",
"(",
"using",
")",
".",
"get_autocommit",
"(",
")"
] | [
22,
0
] | [
24,
49
] | python | en | ['en', 'en', 'en'] | True |
set_autocommit | (autocommit, using=None) | Set the autocommit status of the connection. | Set the autocommit status of the connection. | def set_autocommit(autocommit, using=None):
"""Set the autocommit status of the connection."""
return get_connection(using).set_autocommit(autocommit) | [
"def",
"set_autocommit",
"(",
"autocommit",
",",
"using",
"=",
"None",
")",
":",
"return",
"get_connection",
"(",
"using",
")",
".",
"set_autocommit",
"(",
"autocommit",
")"
] | [
27,
0
] | [
29,
59
] | python | en | ['en', 'en', 'en'] | True |
commit | (using=None) | Commit a transaction. | Commit a transaction. | def commit(using=None):
"""Commit a transaction."""
get_connection(using).commit() | [
"def",
"commit",
"(",
"using",
"=",
"None",
")",
":",
"get_connection",
"(",
"using",
")",
".",
"commit",
"(",
")"
] | [
32,
0
] | [
34,
34
] | python | en | ['en', 'en', 'en'] | True |
rollback | (using=None) | Roll back a transaction. | Roll back a transaction. | def rollback(using=None):
"""Roll back a transaction."""
get_connection(using).rollback() | [
"def",
"rollback",
"(",
"using",
"=",
"None",
")",
":",
"get_connection",
"(",
"using",
")",
".",
"rollback",
"(",
")"
] | [
37,
0
] | [
39,
36
] | python | en | ['en', 'en', 'en'] | True |
savepoint | (using=None) |
Create a savepoint (if supported and required by the backend) inside the
current transaction. Return an identifier for the savepoint that will be
used for the subsequent rollback or commit.
|
Create a savepoint (if supported and required by the backend) inside the
current transaction. Return an identifier for the savepoint that will be
used for the subsequent rollback or commit.
| def savepoint(using=None):
"""
Create a savepoint (if supported and required by the backend) inside the
current transaction. Return an identifier for the savepoint that will be
used for the subsequent rollback or commit.
"""
return get_connection(using).savepoint() | [
"def",
"savepoint",
"(",
"using",
"=",
"None",
")",
":",
"return",
"get_connection",
"(",
"using",
")",
".",
"savepoint",
"(",
")"
] | [
42,
0
] | [
48,
44
] | python | en | ['en', 'error', 'th'] | False |
savepoint_rollback | (sid, using=None) |
Roll back the most recent savepoint (if one exists). Do nothing if
savepoints are not supported.
|
Roll back the most recent savepoint (if one exists). Do nothing if
savepoints are not supported.
| def savepoint_rollback(sid, using=None):
"""
Roll back the most recent savepoint (if one exists). Do nothing if
savepoints are not supported.
"""
get_connection(using).savepoint_rollback(sid) | [
"def",
"savepoint_rollback",
"(",
"sid",
",",
"using",
"=",
"None",
")",
":",
"get_connection",
"(",
"using",
")",
".",
"savepoint_rollback",
"(",
"sid",
")"
] | [
51,
0
] | [
56,
49
] | python | en | ['en', 'error', 'th'] | False |
savepoint_commit | (sid, using=None) |
Commit the most recent savepoint (if one exists). Do nothing if
savepoints are not supported.
|
Commit the most recent savepoint (if one exists). Do nothing if
savepoints are not supported.
| def savepoint_commit(sid, using=None):
"""
Commit the most recent savepoint (if one exists). Do nothing if
savepoints are not supported.
"""
get_connection(using).savepoint_commit(sid) | [
"def",
"savepoint_commit",
"(",
"sid",
",",
"using",
"=",
"None",
")",
":",
"get_connection",
"(",
"using",
")",
".",
"savepoint_commit",
"(",
"sid",
")"
] | [
59,
0
] | [
64,
47
] | python | en | ['en', 'error', 'th'] | False |
clean_savepoints | (using=None) |
Reset the counter used to generate unique savepoint ids in this thread.
|
Reset the counter used to generate unique savepoint ids in this thread.
| def clean_savepoints(using=None):
"""
Reset the counter used to generate unique savepoint ids in this thread.
"""
get_connection(using).clean_savepoints() | [
"def",
"clean_savepoints",
"(",
"using",
"=",
"None",
")",
":",
"get_connection",
"(",
"using",
")",
".",
"clean_savepoints",
"(",
")"
] | [
67,
0
] | [
71,
44
] | python | en | ['en', 'error', 'th'] | False |
get_rollback | (using=None) | Get the "needs rollback" flag -- for *advanced use* only. | Get the "needs rollback" flag -- for *advanced use* only. | def get_rollback(using=None):
"""Get the "needs rollback" flag -- for *advanced use* only."""
return get_connection(using).get_rollback() | [
"def",
"get_rollback",
"(",
"using",
"=",
"None",
")",
":",
"return",
"get_connection",
"(",
"using",
")",
".",
"get_rollback",
"(",
")"
] | [
74,
0
] | [
76,
47
] | python | en | ['en', 'en', 'en'] | True |
set_rollback | (rollback, using=None) |
Set or unset the "needs rollback" flag -- for *advanced use* only.
When `rollback` is `True`, trigger a rollback when exiting the innermost
enclosing atomic block that has `savepoint=True` (that's the default). Use
this to force a rollback without raising an exception.
When `rollback` is `False`,... |
Set or unset the "needs rollback" flag -- for *advanced use* only. | def set_rollback(rollback, using=None):
"""
Set or unset the "needs rollback" flag -- for *advanced use* only.
When `rollback` is `True`, trigger a rollback when exiting the innermost
enclosing atomic block that has `savepoint=True` (that's the default). Use
this to force a rollback without raising... | [
"def",
"set_rollback",
"(",
"rollback",
",",
"using",
"=",
"None",
")",
":",
"return",
"get_connection",
"(",
"using",
")",
".",
"set_rollback",
"(",
"rollback",
")"
] | [
79,
0
] | [
91,
55
] | python | en | ['en', 'error', 'th'] | False |
mark_for_rollback_on_error | (using=None) |
Internal low-level utility to mark a transaction as "needs rollback" when
an exception is raised while not enforcing the enclosed block to be in a
transaction. This is needed by Model.save() and friends to avoid starting a
transaction when in autocommit mode and a single query is executed.
It's eq... |
Internal low-level utility to mark a transaction as "needs rollback" when
an exception is raised while not enforcing the enclosed block to be in a
transaction. This is needed by Model.save() and friends to avoid starting a
transaction when in autocommit mode and a single query is executed. | def mark_for_rollback_on_error(using=None):
"""
Internal low-level utility to mark a transaction as "needs rollback" when
an exception is raised while not enforcing the enclosed block to be in a
transaction. This is needed by Model.save() and friends to avoid starting a
transaction when in autocommi... | [
"def",
"mark_for_rollback_on_error",
"(",
"using",
"=",
"None",
")",
":",
"try",
":",
"yield",
"except",
"Exception",
":",
"connection",
"=",
"get_connection",
"(",
"using",
")",
"if",
"connection",
".",
"in_atomic_block",
":",
"connection",
".",
"needs_rollback... | [
95,
0
] | [
119,
13
] | python | en | ['en', 'error', 'th'] | False |
on_commit | (func, using=None) |
Register `func` to be called when the current transaction is committed.
If the current transaction is rolled back, `func` will not be called.
|
Register `func` to be called when the current transaction is committed.
If the current transaction is rolled back, `func` will not be called.
| def on_commit(func, using=None):
"""
Register `func` to be called when the current transaction is committed.
If the current transaction is rolled back, `func` will not be called.
"""
get_connection(using).on_commit(func) | [
"def",
"on_commit",
"(",
"func",
",",
"using",
"=",
"None",
")",
":",
"get_connection",
"(",
"using",
")",
".",
"on_commit",
"(",
"func",
")"
] | [
122,
0
] | [
127,
41
] | python | en | ['en', 'error', 'th'] | False |
Feed.feed_extra_kwargs | (self, obj) |
Return an extra keyword arguments dictionary that is used when
initializing the feed generator.
|
Return an extra keyword arguments dictionary that is used when
initializing the feed generator.
| def feed_extra_kwargs(self, obj):
"""
Return an extra keyword arguments dictionary that is used when
initializing the feed generator.
"""
return {} | [
"def",
"feed_extra_kwargs",
"(",
"self",
",",
"obj",
")",
":",
"return",
"{",
"}"
] | [
95,
4
] | [
100,
17
] | python | en | ['en', 'error', 'th'] | False |
Feed.item_extra_kwargs | (self, item) |
Return an extra keyword arguments dictionary that is used with
the `add_item` call of the feed generator.
|
Return an extra keyword arguments dictionary that is used with
the `add_item` call of the feed generator.
| def item_extra_kwargs(self, item):
"""
Return an extra keyword arguments dictionary that is used with
the `add_item` call of the feed generator.
"""
return {} | [
"def",
"item_extra_kwargs",
"(",
"self",
",",
"item",
")",
":",
"return",
"{",
"}"
] | [
102,
4
] | [
107,
17
] | python | en | ['en', 'error', 'th'] | False |
Feed.get_context_data | (self, **kwargs) |
Return a dictionary to use as extra context if either
``self.description_template`` or ``self.item_template`` are used.
Default implementation preserves the old behavior
of using {'obj': item, 'site': current_site} as the context.
|
Return a dictionary to use as extra context if either
``self.description_template`` or ``self.item_template`` are used. | def get_context_data(self, **kwargs):
"""
Return a dictionary to use as extra context if either
``self.description_template`` or ``self.item_template`` are used.
Default implementation preserves the old behavior
of using {'obj': item, 'site': current_site} as the context.
... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"{",
"'obj'",
":",
"kwargs",
".",
"get",
"(",
"'item'",
")",
",",
"'site'",
":",
"kwargs",
".",
"get",
"(",
"'site'",
")",
"}"
] | [
112,
4
] | [
120,
70
] | python | en | ['en', 'error', 'th'] | False |
Feed.get_feed | (self, obj, request) |
Return a feedgenerator.DefaultFeed object, fully populated, for
this feed. Raise FeedDoesNotExist for invalid parameters.
|
Return a feedgenerator.DefaultFeed object, fully populated, for
this feed. Raise FeedDoesNotExist for invalid parameters.
| def get_feed(self, obj, request):
"""
Return a feedgenerator.DefaultFeed object, fully populated, for
this feed. Raise FeedDoesNotExist for invalid parameters.
"""
current_site = get_current_site(request)
link = self._get_dynamic_attr('link', obj)
link = add_doma... | [
"def",
"get_feed",
"(",
"self",
",",
"obj",
",",
"request",
")",
":",
"current_site",
"=",
"get_current_site",
"(",
"request",
")",
"link",
"=",
"self",
".",
"_get_dynamic_attr",
"(",
"'link'",
",",
"obj",
")",
"link",
"=",
"add_domain",
"(",
"current_site... | [
122,
4
] | [
219,
19
] | python | en | ['en', 'error', 'th'] | False |
JSONMixin.json | (self) | The parsed JSON data if :attr:`mimetype` indicates JSON
(:mimetype:`application/json`, see :meth:`is_json`).
Calls :meth:`get_json` with default arguments.
| The parsed JSON data if :attr:`mimetype` indicates JSON
(:mimetype:`application/json`, see :meth:`is_json`). | def json(self):
"""The parsed JSON data if :attr:`mimetype` indicates JSON
(:mimetype:`application/json`, see :meth:`is_json`).
Calls :meth:`get_json` with default arguments.
"""
return self.get_json() | [
"def",
"json",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_json",
"(",
")"
] | [
62,
4
] | [
68,
30
] | python | en | ['en', 'en', 'en'] | True |
JSONMixin.is_json | (self) | Check if the mimetype indicates JSON data, either
:mimetype:`application/json` or :mimetype:`application/*+json`.
| Check if the mimetype indicates JSON data, either
:mimetype:`application/json` or :mimetype:`application/*+json`.
| def is_json(self):
"""Check if the mimetype indicates JSON data, either
:mimetype:`application/json` or :mimetype:`application/*+json`.
"""
mt = self.mimetype
return (
mt == "application/json"
or mt.startswith("application/")
and mt.endswith("+... | [
"def",
"is_json",
"(",
"self",
")",
":",
"mt",
"=",
"self",
".",
"mimetype",
"return",
"(",
"mt",
"==",
"\"application/json\"",
"or",
"mt",
".",
"startswith",
"(",
"\"application/\"",
")",
"and",
"mt",
".",
"endswith",
"(",
"\"+json\"",
")",
")"
] | [
71,
4
] | [
80,
9
] | python | en | ['en', 'en', 'en'] | True |
JSONMixin.get_json | (self, force=False, silent=False, cache=True) | Parse :attr:`data` as JSON.
If the mimetype does not indicate JSON
(:mimetype:`application/json`, see :meth:`is_json`), this
returns ``None``.
If parsing fails, :meth:`on_json_loading_failed` is called and
its return value is used as the return value.
:param force: Ign... | Parse :attr:`data` as JSON. | def get_json(self, force=False, silent=False, cache=True):
"""Parse :attr:`data` as JSON.
If the mimetype does not indicate JSON
(:mimetype:`application/json`, see :meth:`is_json`), this
returns ``None``.
If parsing fails, :meth:`on_json_loading_failed` is called and
it... | [
"def",
"get_json",
"(",
"self",
",",
"force",
"=",
"False",
",",
"silent",
"=",
"False",
",",
"cache",
"=",
"True",
")",
":",
"if",
"cache",
"and",
"self",
".",
"_cached_json",
"[",
"silent",
"]",
"is",
"not",
"Ellipsis",
":",
"return",
"self",
".",
... | [
93,
4
] | [
136,
17
] | python | de | ['en', 'de', 'ur'] | False |
JSONMixin.on_json_loading_failed | (self, e) | Called if :meth:`get_json` parsing fails and isn't silenced.
If this method returns a value, it is used as the return value
for :meth:`get_json`. The default implementation raises
:exc:`~werkzeug.exceptions.BadRequest`.
| Called if :meth:`get_json` parsing fails and isn't silenced.
If this method returns a value, it is used as the return value
for :meth:`get_json`. The default implementation raises
:exc:`~werkzeug.exceptions.BadRequest`.
| def on_json_loading_failed(self, e):
"""Called if :meth:`get_json` parsing fails and isn't silenced.
If this method returns a value, it is used as the return value
for :meth:`get_json`. The default implementation raises
:exc:`~werkzeug.exceptions.BadRequest`.
"""
raise Ba... | [
"def",
"on_json_loading_failed",
"(",
"self",
",",
"e",
")",
":",
"raise",
"BadRequest",
"(",
"\"Failed to decode JSON object: {0}\"",
".",
"format",
"(",
"e",
")",
")"
] | [
138,
4
] | [
144,
71
] | python | en | ['en', 'en', 'en'] | True |
description_of | (lines, name='stdin') |
Return a string describing the probable encoding of a file or
list of strings.
:param lines: The lines to get the encoding of.
:type lines: Iterable of bytes
:param name: Name of file or collection of lines
:type name: str
|
Return a string describing the probable encoding of a file or
list of strings. | def description_of(lines, name='stdin'):
"""
Return a string describing the probable encoding of a file or
list of strings.
:param lines: The lines to get the encoding of.
:type lines: Iterable of bytes
:param name: Name of file or collection of lines
:type name: str
"""
u = Univers... | [
"def",
"description_of",
"(",
"lines",
",",
"name",
"=",
"'stdin'",
")",
":",
"u",
"=",
"UniversalDetector",
"(",
")",
"for",
"line",
"in",
"lines",
":",
"line",
"=",
"bytearray",
"(",
"line",
")",
"u",
".",
"feed",
"(",
"line",
")",
"# shortcut out of... | [
24,
0
] | [
49,
43
] | python | en | ['en', 'error', 'th'] | False |
main | (argv=None) |
Handles command line arguments and gets things started.
:param argv: List of arguments, as if specified on the command-line.
If None, ``sys.argv[1:]`` is used instead.
:type argv: list of str
|
Handles command line arguments and gets things started. | def main(argv=None):
"""
Handles command line arguments and gets things started.
:param argv: List of arguments, as if specified on the command-line.
If None, ``sys.argv[1:]`` is used instead.
:type argv: list of str
"""
# Get command line arguments
parser = argparse.Argume... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"# Get command line arguments",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Takes one or more file paths and reports their detected \\\n encodings\"",
")",
"parser",
".",
... | [
52,
0
] | [
79,
40
] | python | en | ['en', 'error', 'th'] | False |
get_session_data | (transaction, session_id) | Looks up (or creates) the session with the given session_id.
Creates a random session_id if none is provided. Increments
the number of views in this session. Updates are done in a
transaction to make sure no saved increments are overwritten.
| Looks up (or creates) the session with the given session_id.
Creates a random session_id if none is provided. Increments
the number of views in this session. Updates are done in a
transaction to make sure no saved increments are overwritten.
| def get_session_data(transaction, session_id):
""" Looks up (or creates) the session with the given session_id.
Creates a random session_id if none is provided. Increments
the number of views in this session. Updates are done in a
transaction to make sure no saved increments are overwritten.... | [
"def",
"get_session_data",
"(",
"transaction",
",",
"session_id",
")",
":",
"if",
"session_id",
"is",
"None",
":",
"session_id",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"# Random, unique identifier",
"doc_ref",
"=",
"sessions",
".",
"document",
"(",
"document... | [
34,
0
] | [
57,
18
] | python | en | ['en', 'en', 'en'] | True |
generate_a_pyrex_source | (self, base, ext_name, source, extension) | Monkey patch for numpy build_src.build_src method
Uses Cython instead of Pyrex.
Assumes Cython is present
| Monkey patch for numpy build_src.build_src method
Uses Cython instead of Pyrex.
Assumes Cython is present
| def generate_a_pyrex_source(self, base, ext_name, source, extension):
''' Monkey patch for numpy build_src.build_src method
Uses Cython instead of Pyrex.
Assumes Cython is present
'''
if self.inplace:
target_dir = dirname(base)
else:
target_dir = appendpath(self.build_src, dirnam... | [
"def",
"generate_a_pyrex_source",
"(",
"self",
",",
"base",
",",
"ext_name",
",",
"source",
",",
"extension",
")",
":",
"if",
"self",
".",
"inplace",
":",
"target_dir",
"=",
"dirname",
"(",
"base",
")",
"else",
":",
"target_dir",
"=",
"appendpath",
"(",
... | [
40,
0
] | [
62,
22
] | python | en | ['en', 'fr', 'en'] | True |
ConfigurationCommand.list_config_values | (self, options: Values, args: List[str]) | List config key-value pairs across different config files | List config key-value pairs across different config files | def list_config_values(self, options: Values, args: List[str]) -> None:
"""List config key-value pairs across different config files"""
self._get_n_args(args, "debug", n=0)
self.print_env_var_values()
# Iterate over config files and print if they exist, and the
# key-value pairs... | [
"def",
"list_config_values",
"(",
"self",
",",
"options",
":",
"Values",
",",
"args",
":",
"List",
"[",
"str",
"]",
")",
"->",
"None",
":",
"self",
".",
"_get_n_args",
"(",
"args",
",",
"\"debug\"",
",",
"n",
"=",
"0",
")",
"self",
".",
"print_env_va... | [
184,
4
] | [
199,
62
] | python | en | ['fr', 'en', 'en'] | True |
ConfigurationCommand.print_config_file_values | (self, variant: Kind) | Get key-value pairs from the file of a variant | Get key-value pairs from the file of a variant | def print_config_file_values(self, variant: Kind) -> None:
"""Get key-value pairs from the file of a variant"""
for name, value in self.configuration.\
get_values_in_config(variant).items():
with indent_log():
write_output("%s: %s", name, value) | [
"def",
"print_config_file_values",
"(",
"self",
",",
"variant",
":",
"Kind",
")",
"->",
"None",
":",
"for",
"name",
",",
"value",
"in",
"self",
".",
"configuration",
".",
"get_values_in_config",
"(",
"variant",
")",
".",
"items",
"(",
")",
":",
"with",
"... | [
201,
4
] | [
206,
51
] | python | en | ['en', 'en', 'en'] | True |
ConfigurationCommand.print_env_var_values | (self) | Get key-values pairs present as environment variables | Get key-values pairs present as environment variables | def print_env_var_values(self) -> None:
"""Get key-values pairs present as environment variables"""
write_output("%s:", 'env_var')
with indent_log():
for key, value in sorted(self.configuration.get_environ_vars()):
env_var = f'PIP_{key.upper()}'
write_... | [
"def",
"print_env_var_values",
"(",
"self",
")",
"->",
"None",
":",
"write_output",
"(",
"\"%s:\"",
",",
"'env_var'",
")",
"with",
"indent_log",
"(",
")",
":",
"for",
"key",
",",
"value",
"in",
"sorted",
"(",
"self",
".",
"configuration",
".",
"get_environ... | [
208,
4
] | [
214,
53
] | python | en | ['fr', 'en', 'en'] | True |
ConfigurationCommand._get_n_args | (self, args: List[str], example: str, n: int) | Helper to make sure the command got the right number of arguments
| Helper to make sure the command got the right number of arguments
| def _get_n_args(self, args: List[str], example: str, n: int) -> Any:
"""Helper to make sure the command got the right number of arguments
"""
if len(args) != n:
msg = (
'Got unexpected number of arguments, expected {}. '
'(example: "{} config {}")'
... | [
"def",
"_get_n_args",
"(",
"self",
",",
"args",
":",
"List",
"[",
"str",
"]",
",",
"example",
":",
"str",
",",
"n",
":",
"int",
")",
"->",
"Any",
":",
"if",
"len",
"(",
"args",
")",
"!=",
"n",
":",
"msg",
"=",
"(",
"'Got unexpected number of argume... | [
231,
4
] | [
244,
23
] | python | en | ['en', 'en', 'en'] | True |
incoming_call | (request) | Twilio Voice URL - receives incoming calls from Twilio | Twilio Voice URL - receives incoming calls from Twilio | def incoming_call(request):
"""Twilio Voice URL - receives incoming calls from Twilio"""
# Create a new TwiML response
resp = VoiceResponse()
# <Say> a message to the caller
from_number = request.POST['From']
body = """
Thanks for calling!
Your phone number is {0}. I got your call beca... | [
"def",
"incoming_call",
"(",
"request",
")",
":",
"# Create a new TwiML response",
"resp",
"=",
"VoiceResponse",
"(",
")",
"# <Say> a message to the caller",
"from_number",
"=",
"request",
".",
"POST",
"[",
"'From'",
"]",
"body",
"=",
"\"\"\"\n Thanks for calling!\n\... | [
9,
0
] | [
25,
29
] | python | en | ['en', 'la', 'en'] | True |
incoming_message | (request) | Twilio Messaging URL - receives incoming messages from Twilio | Twilio Messaging URL - receives incoming messages from Twilio | def incoming_message(request):
"""Twilio Messaging URL - receives incoming messages from Twilio"""
# Create a new TwiML response
resp = MessagingResponse()
# <Message> a text back to the person who texted us
body = "Your text to me was {0} characters long. Webhooks are neat :)" \
.format(le... | [
"def",
"incoming_message",
"(",
"request",
")",
":",
"# Create a new TwiML response",
"resp",
"=",
"MessagingResponse",
"(",
")",
"# <Message> a text back to the person who texted us",
"body",
"=",
"\"Your text to me was {0} characters long. Webhooks are neat :)\"",
".",
"format",
... | [
31,
0
] | [
42,
29
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdmin.formfield_for_dbfield | (self, db_field, request, **kwargs) |
Hook for specifying the form Field instance for a given database Field
instance.
If kwargs are given, they're passed to the form Field's constructor.
|
Hook for specifying the form Field instance for a given database Field
instance. | def formfield_for_dbfield(self, db_field, request, **kwargs):
"""
Hook for specifying the form Field instance for a given database Field
instance.
If kwargs are given, they're passed to the form Field's constructor.
"""
# If the field specifies choices, we don't need to ... | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# If the field specifies choices, we don't need to look for special",
"# admin widgets - we just need to use a select widget of some kind.",
"if",
"db_field",
".",
... | [
131,
4
] | [
186,
43
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.formfield_for_choice_field | (self, db_field, request, **kwargs) |
Get a form Field for a database Field that has declared choices.
|
Get a form Field for a database Field that has declared choices.
| def formfield_for_choice_field(self, db_field, request, **kwargs):
"""
Get a form Field for a database Field that has declared choices.
"""
# If the field is named as a radio_field, use a RadioSelect
if db_field.name in self.radio_fields:
# Avoid stomping on custom wi... | [
"def",
"formfield_for_choice_field",
"(",
"self",
",",
"db_field",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# If the field is named as a radio_field, use a RadioSelect",
"if",
"db_field",
".",
"name",
"in",
"self",
".",
"radio_fields",
":",
"# Avoid stompin... | [
188,
4
] | [
204,
43
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_field_queryset | (self, db, db_field, request) |
If the ModelAdmin specifies ordering, the queryset should respect that
ordering. Otherwise don't specify the queryset, let the field decide
(return None in that case).
|
If the ModelAdmin specifies ordering, the queryset should respect that
ordering. Otherwise don't specify the queryset, let the field decide
(return None in that case).
| def get_field_queryset(self, db, db_field, request):
"""
If the ModelAdmin specifies ordering, the queryset should respect that
ordering. Otherwise don't specify the queryset, let the field decide
(return None in that case).
"""
related_admin = self.admin_site._registry.... | [
"def",
"get_field_queryset",
"(",
"self",
",",
"db",
",",
"db_field",
",",
"request",
")",
":",
"related_admin",
"=",
"self",
".",
"admin_site",
".",
"_registry",
".",
"get",
"(",
"db_field",
".",
"remote_field",
".",
"model",
")",
"if",
"related_admin",
"... | [
206,
4
] | [
217,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.formfield_for_foreignkey | (self, db_field, request, **kwargs) |
Get a form Field for a ForeignKey.
|
Get a form Field for a ForeignKey.
| def formfield_for_foreignkey(self, db_field, request, **kwargs):
"""
Get a form Field for a ForeignKey.
"""
db = kwargs.get('using')
if 'widget' not in kwargs:
if db_field.name in self.get_autocomplete_fields(request):
kwargs['widget'] = AutocompleteS... | [
"def",
"formfield_for_foreignkey",
"(",
"self",
",",
"db_field",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"db",
"=",
"kwargs",
".",
"get",
"(",
"'using'",
")",
"if",
"'widget'",
"not",
"in",
"kwargs",
":",
"if",
"db_field",
".",
"name",
"in",... | [
219,
4
] | [
241,
43
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.formfield_for_manytomany | (self, db_field, request, **kwargs) |
Get a form Field for a ManyToManyField.
|
Get a form Field for a ManyToManyField.
| def formfield_for_manytomany(self, db_field, request, **kwargs):
"""
Get a form Field for a ManyToManyField.
"""
# If it uses an intermediary model that isn't auto created, don't show
# a field in admin.
if not db_field.remote_field.through._meta.auto_created:
... | [
"def",
"formfield_for_manytomany",
"(",
"self",
",",
"db_field",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# If it uses an intermediary model that isn't auto created, don't show",
"# a field in admin.",
"if",
"not",
"db_field",
".",
"remote_field",
".",
"through... | [
243,
4
] | [
283,
25
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_autocomplete_fields | (self, request) |
Return a list of ForeignKey and/or ManyToMany fields which should use
an autocomplete widget.
|
Return a list of ForeignKey and/or ManyToMany fields which should use
an autocomplete widget.
| def get_autocomplete_fields(self, request):
"""
Return a list of ForeignKey and/or ManyToMany fields which should use
an autocomplete widget.
"""
return self.autocomplete_fields | [
"def",
"get_autocomplete_fields",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"autocomplete_fields"
] | [
285,
4
] | [
290,
39
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_empty_value_display | (self) |
Return the empty_value_display set on ModelAdmin or AdminSite.
|
Return the empty_value_display set on ModelAdmin or AdminSite.
| def get_empty_value_display(self):
"""
Return the empty_value_display set on ModelAdmin or AdminSite.
"""
try:
return mark_safe(self.empty_value_display)
except AttributeError:
return mark_safe(self.admin_site.empty_value_display) | [
"def",
"get_empty_value_display",
"(",
"self",
")",
":",
"try",
":",
"return",
"mark_safe",
"(",
"self",
".",
"empty_value_display",
")",
"except",
"AttributeError",
":",
"return",
"mark_safe",
"(",
"self",
".",
"admin_site",
".",
"empty_value_display",
")"
] | [
305,
4
] | [
312,
65
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_exclude | (self, request, obj=None) |
Hook for specifying exclude.
|
Hook for specifying exclude.
| def get_exclude(self, request, obj=None):
"""
Hook for specifying exclude.
"""
return self.exclude | [
"def",
"get_exclude",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"exclude"
] | [
314,
4
] | [
318,
27
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_fields | (self, request, obj=None) |
Hook for specifying fields.
|
Hook for specifying fields.
| def get_fields(self, request, obj=None):
"""
Hook for specifying fields.
"""
if self.fields:
return self.fields
# _get_form_for_get_fields() is implemented in subclasses.
form = self._get_form_for_get_fields(request, obj)
return [*form.base_fields, *se... | [
"def",
"get_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"if",
"self",
".",
"fields",
":",
"return",
"self",
".",
"fields",
"# _get_form_for_get_fields() is implemented in subclasses.",
"form",
"=",
"self",
".",
"_get_form_for_get_field... | [
320,
4
] | [
328,
75
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_fieldsets | (self, request, obj=None) |
Hook for specifying fieldsets.
|
Hook for specifying fieldsets.
| def get_fieldsets(self, request, obj=None):
"""
Hook for specifying fieldsets.
"""
if self.fieldsets:
return self.fieldsets
return [(None, {'fields': self.get_fields(request, obj)})] | [
"def",
"get_fieldsets",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"if",
"self",
".",
"fieldsets",
":",
"return",
"self",
".",
"fieldsets",
"return",
"[",
"(",
"None",
",",
"{",
"'fields'",
":",
"self",
".",
"get_fields",
"(",
"r... | [
330,
4
] | [
336,
66
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_inlines | (self, request, obj) | Hook for specifying custom inlines. | Hook for specifying custom inlines. | def get_inlines(self, request, obj):
"""Hook for specifying custom inlines."""
return self.inlines | [
"def",
"get_inlines",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"return",
"self",
".",
"inlines"
] | [
338,
4
] | [
340,
27
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.