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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
DatabaseOperations.format_for_duration_arithmetic | (self, sql) | Do nothing since formatting is handled in the custom function. | Do nothing since formatting is handled in the custom function. | def format_for_duration_arithmetic(self, sql):
"""Do nothing since formatting is handled in the custom function."""
return sql | [
"def",
"format_for_duration_arithmetic",
"(",
"self",
",",
"sql",
")",
":",
"return",
"sql"
] | [
75,
4
] | [
77,
18
] | python | en | ['en', 'en', 'en'] | True |
DatabaseOperations._quote_params_for_last_executed_query | (self, params) |
Only for last_executed_query! Don't use this to execute SQL queries!
|
Only for last_executed_query! Don't use this to execute SQL queries!
| def _quote_params_for_last_executed_query(self, params):
"""
Only for last_executed_query! Don't use this to execute SQL queries!
"""
# This function is limited both by SQLITE_LIMIT_VARIABLE_NUMBER (the
# number of parameters, default = 999) and SQLITE_MAX_COLUMN (the
# n... | [
"def",
"_quote_params_for_last_executed_query",
"(",
"self",
",",
"params",
")",
":",
"# This function is limited both by SQLITE_LIMIT_VARIABLE_NUMBER (the",
"# number of parameters, default = 999) and SQLITE_MAX_COLUMN (the",
"# number of return values, default = 2000). Since Python's sqlite3",... | [
124,
4
] | [
149,
26
] | python | en | ['en', 'error', 'th'] | False |
get_prediction | (image, server_host='127.0.0.1', server_port=9000,
server_name="server", timeout=10.0) |
Retrieve a prediction from a TensorFlow model server
:param image: a MNIST image represented as a 1x784 array
:param server_host: the address of the TensorFlow server
:param server_port: the port used by the server
:param server_name: the name of the server
:param timeout: the amount of time to ... |
Retrieve a prediction from a TensorFlow model server | def get_prediction(image, server_host='127.0.0.1', server_port=9000,
server_name="server", timeout=10.0):
"""
Retrieve a prediction from a TensorFlow model server
:param image: a MNIST image represented as a 1x784 array
:param server_host: the address of the TensorFlow server
:param ... | [
"def",
"get_prediction",
"(",
"image",
",",
"server_host",
"=",
"'127.0.0.1'",
",",
"server_port",
"=",
"9000",
",",
"server_name",
"=",
"\"server\"",
",",
"timeout",
"=",
"10.0",
")",
":",
"print",
"(",
"\"connecting to:%s:%i\"",
"%",
"(",
"server_host",
",",... | [
32,
0
] | [
64,
35
] | python | en | ['en', 'error', 'th'] | False |
random_mnist | (save_path=None) |
Pull a random image out of the MNIST test dataset
Optionally save the selected image as a file to disk
:param savePath: the path to save the file to. If None, file is not saved
:return 0: a 1x784 representation of the MNIST image
:return 1: the ground truth label associated with the image
:return 2: a boo... |
Pull a random image out of the MNIST test dataset
Optionally save the selected image as a file to disk | def random_mnist(save_path=None):
"""
Pull a random image out of the MNIST test dataset
Optionally save the selected image as a file to disk
:param savePath: the path to save the file to. If None, file is not saved
:return 0: a 1x784 representation of the MNIST image
:return 1: the ground truth label assoc... | [
"def",
"random_mnist",
"(",
"save_path",
"=",
"None",
")",
":",
"mnist",
"=",
"input_data",
".",
"read_data_sets",
"(",
"\"MNIST_data/\"",
",",
"one_hot",
"=",
"True",
")",
"batch_size",
"=",
"1",
"batch_x",
",",
"batch_y",
"=",
"mnist",
".",
"test",
".",
... | [
67,
0
] | [
91,
43
] | python | en | ['en', 'error', 'th'] | False |
MpoImageFile.adopt | (jpeg_instance, mpheader=None) |
Transform the instance of JpegImageFile into
an instance of MpoImageFile.
After the call, the JpegImageFile is extended
to be an MpoImageFile.
This is essentially useful when opening a JPEG
file that reveals itself as an MPO, to avoid
double call to _open.
... |
Transform the instance of JpegImageFile into
an instance of MpoImageFile.
After the call, the JpegImageFile is extended
to be an MpoImageFile. | def adopt(jpeg_instance, mpheader=None):
"""
Transform the instance of JpegImageFile into
an instance of MpoImageFile.
After the call, the JpegImageFile is extended
to be an MpoImageFile.
This is essentially useful when opening a JPEG
file that reveals itself as ... | [
"def",
"adopt",
"(",
"jpeg_instance",
",",
"mpheader",
"=",
"None",
")",
":",
"jpeg_instance",
".",
"__class__",
"=",
"MpoImageFile",
"jpeg_instance",
".",
"_after_jpeg_open",
"(",
"mpheader",
")",
"return",
"jpeg_instance"
] | [
108,
4
] | [
121,
28
] | python | en | ['en', 'error', 'th'] | False |
memorized_timedelta | (seconds) | Create only one instance of each distinct timedelta | Create only one instance of each distinct timedelta | def memorized_timedelta(seconds):
'''Create only one instance of each distinct timedelta'''
try:
return _timedelta_cache[seconds]
except KeyError:
delta = timedelta(seconds=seconds)
_timedelta_cache[seconds] = delta
return delta | [
"def",
"memorized_timedelta",
"(",
"seconds",
")",
":",
"try",
":",
"return",
"_timedelta_cache",
"[",
"seconds",
"]",
"except",
"KeyError",
":",
"delta",
"=",
"timedelta",
"(",
"seconds",
"=",
"seconds",
")",
"_timedelta_cache",
"[",
"seconds",
"]",
"=",
"d... | [
17,
0
] | [
24,
20
] | python | en | ['en', 'en', 'en'] | True |
memorized_datetime | (seconds) | Create only one instance of each distinct datetime | Create only one instance of each distinct datetime | def memorized_datetime(seconds):
'''Create only one instance of each distinct datetime'''
try:
return _datetime_cache[seconds]
except KeyError:
# NB. We can't just do datetime.utcfromtimestamp(seconds) as this
# fails with negative values under Windows (Bug #90096)
dt = _epoc... | [
"def",
"memorized_datetime",
"(",
"seconds",
")",
":",
"try",
":",
"return",
"_datetime_cache",
"[",
"seconds",
"]",
"except",
"KeyError",
":",
"# NB. We can't just do datetime.utcfromtimestamp(seconds) as this",
"# fails with negative values under Windows (Bug #90096)",
"dt",
... | [
30,
0
] | [
39,
17
] | python | en | ['en', 'en', 'en'] | True |
memorized_ttinfo | (*args) | Create only one instance of each distinct tuple | Create only one instance of each distinct tuple | def memorized_ttinfo(*args):
'''Create only one instance of each distinct tuple'''
try:
return _ttinfo_cache[args]
except KeyError:
ttinfo = (
memorized_timedelta(args[0]),
memorized_timedelta(args[1]),
args[2]
)
_ttinfo_cache[args] = ttinf... | [
"def",
"memorized_ttinfo",
"(",
"*",
"args",
")",
":",
"try",
":",
"return",
"_ttinfo_cache",
"[",
"args",
"]",
"except",
"KeyError",
":",
"ttinfo",
"=",
"(",
"memorized_timedelta",
"(",
"args",
"[",
"0",
"]",
")",
",",
"memorized_timedelta",
"(",
"args",
... | [
44,
0
] | [
55,
21
] | python | en | ['en', 'en', 'en'] | True |
_to_seconds | (td) | Convert a timedelta to seconds | Convert a timedelta to seconds | def _to_seconds(td):
'''Convert a timedelta to seconds'''
return td.seconds + td.days * 24 * 60 * 60 | [
"def",
"_to_seconds",
"(",
"td",
")",
":",
"return",
"td",
".",
"seconds",
"+",
"td",
".",
"days",
"*",
"24",
"*",
"60",
"*",
"60"
] | [
60,
0
] | [
62,
46
] | python | en | ['en', 'en', 'en'] | True |
unpickler | (zone, utcoffset=None, dstoffset=None, tzname=None) | Factory function for unpickling pytz tzinfo instances.
This is shared for both StaticTzInfo and DstTzInfo instances, because
database changes could cause a zones implementation to switch between
these two base classes and we can't break pickles on a pytz version
upgrade.
| Factory function for unpickling pytz tzinfo instances. | def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None):
"""Factory function for unpickling pytz tzinfo instances.
This is shared for both StaticTzInfo and DstTzInfo instances, because
database changes could cause a zones implementation to switch between
these two base classes and we can't bre... | [
"def",
"unpickler",
"(",
"zone",
",",
"utcoffset",
"=",
"None",
",",
"dstoffset",
"=",
"None",
",",
"tzname",
"=",
"None",
")",
":",
"# Raises a KeyError if zone no longer exists, which should never happen",
"# and would be a bug.",
"tz",
"=",
"pytz",
".",
"timezone",... | [
528,
0
] | [
576,
27
] | python | en | ['en', 'fr', 'en'] | True |
StaticTzInfo.fromutc | (self, dt) | See datetime.tzinfo.fromutc | See datetime.tzinfo.fromutc | def fromutc(self, dt):
'''See datetime.tzinfo.fromutc'''
if dt.tzinfo is not None and dt.tzinfo is not self:
raise ValueError('fromutc: dt.tzinfo is not self')
return (dt + self._utcoffset).replace(tzinfo=self) | [
"def",
"fromutc",
"(",
"self",
",",
"dt",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"not",
"None",
"and",
"dt",
".",
"tzinfo",
"is",
"not",
"self",
":",
"raise",
"ValueError",
"(",
"'fromutc: dt.tzinfo is not self'",
")",
"return",
"(",
"dt",
"+",
"se... | [
81,
4
] | [
85,
58
] | python | en | ['en', 'en', 'de'] | False |
StaticTzInfo.utcoffset | (self, dt, is_dst=None) | See datetime.tzinfo.utcoffset
is_dst is ignored for StaticTzInfo, and exists only to
retain compatibility with DstTzInfo.
| See datetime.tzinfo.utcoffset | def utcoffset(self, dt, is_dst=None):
'''See datetime.tzinfo.utcoffset
is_dst is ignored for StaticTzInfo, and exists only to
retain compatibility with DstTzInfo.
'''
return self._utcoffset | [
"def",
"utcoffset",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"None",
")",
":",
"return",
"self",
".",
"_utcoffset"
] | [
87,
4
] | [
93,
30
] | python | de | ['en', 'ny', 'de'] | False |
StaticTzInfo.dst | (self, dt, is_dst=None) | See datetime.tzinfo.dst
is_dst is ignored for StaticTzInfo, and exists only to
retain compatibility with DstTzInfo.
| See datetime.tzinfo.dst | def dst(self, dt, is_dst=None):
'''See datetime.tzinfo.dst
is_dst is ignored for StaticTzInfo, and exists only to
retain compatibility with DstTzInfo.
'''
return _notime | [
"def",
"dst",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"None",
")",
":",
"return",
"_notime"
] | [
95,
4
] | [
101,
22
] | python | en | ['en', 'en', 'de'] | False |
StaticTzInfo.tzname | (self, dt, is_dst=None) | See datetime.tzinfo.tzname
is_dst is ignored for StaticTzInfo, and exists only to
retain compatibility with DstTzInfo.
| See datetime.tzinfo.tzname | def tzname(self, dt, is_dst=None):
'''See datetime.tzinfo.tzname
is_dst is ignored for StaticTzInfo, and exists only to
retain compatibility with DstTzInfo.
'''
return self._tzname | [
"def",
"tzname",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"None",
")",
":",
"return",
"self",
".",
"_tzname"
] | [
103,
4
] | [
109,
27
] | python | de | ['de', 'en', 'de'] | False |
StaticTzInfo.localize | (self, dt, is_dst=False) | Convert naive time to local time | Convert naive time to local time | def localize(self, dt, is_dst=False):
'''Convert naive time to local time'''
if dt.tzinfo is not None:
raise ValueError('Not naive datetime (tzinfo is already set)')
return dt.replace(tzinfo=self) | [
"def",
"localize",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"False",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"'Not naive datetime (tzinfo is already set)'",
")",
"return",
"dt",
".",
"replace",
"(",
"tz... | [
111,
4
] | [
115,
38
] | python | en | ['en', 'en', 'en'] | True |
StaticTzInfo.normalize | (self, dt, is_dst=False) | Correct the timezone information on the given datetime.
This is normally a no-op, as StaticTzInfo timezones never have
ambiguous cases to correct:
>>> from pytz import timezone
>>> gmt = timezone('GMT')
>>> isinstance(gmt, StaticTzInfo)
True
>>> dt = datetime(20... | Correct the timezone information on the given datetime. | def normalize(self, dt, is_dst=False):
'''Correct the timezone information on the given datetime.
This is normally a no-op, as StaticTzInfo timezones never have
ambiguous cases to correct:
>>> from pytz import timezone
>>> gmt = timezone('GMT')
>>> isinstance(gmt, Stati... | [
"def",
"normalize",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"False",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"self",
":",
"return",
"dt",
"if",
"dt",
".",
"tzinfo",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Naive time - no tzinfo set'",
"... | [
117,
4
] | [
144,
34
] | python | en | ['en', 'en', 'en'] | True |
DstTzInfo.fromutc | (self, dt) | See datetime.tzinfo.fromutc | See datetime.tzinfo.fromutc | def fromutc(self, dt):
'''See datetime.tzinfo.fromutc'''
if (dt.tzinfo is not None and
getattr(dt.tzinfo, '_tzinfos', None) is not self._tzinfos):
raise ValueError('fromutc: dt.tzinfo is not self')
dt = dt.replace(tzinfo=None)
idx = max(0, bisect_right(self._u... | [
"def",
"fromutc",
"(",
"self",
",",
"dt",
")",
":",
"if",
"(",
"dt",
".",
"tzinfo",
"is",
"not",
"None",
"and",
"getattr",
"(",
"dt",
".",
"tzinfo",
",",
"'_tzinfos'",
",",
"None",
")",
"is",
"not",
"self",
".",
"_tzinfos",
")",
":",
"raise",
"Va... | [
192,
4
] | [
200,
63
] | python | en | ['en', 'en', 'de'] | False |
DstTzInfo.normalize | (self, dt) | Correct the timezone information on the given datetime
If date arithmetic crosses DST boundaries, the tzinfo
is not magically adjusted. This method normalizes the
tzinfo to the correct one.
To test, first we need to do some setup
>>> from pytz import timezone
>>> utc =... | Correct the timezone information on the given datetime | def normalize(self, dt):
'''Correct the timezone information on the given datetime
If date arithmetic crosses DST boundaries, the tzinfo
is not magically adjusted. This method normalizes the
tzinfo to the correct one.
To test, first we need to do some setup
>>> from py... | [
"def",
"normalize",
"(",
"self",
",",
"dt",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Naive time - no tzinfo set'",
")",
"# Convert dt in localtime to UTC",
"offset",
"=",
"dt",
".",
"tzinfo",
".",
"_utcoffset",
"dt"... | [
202,
4
] | [
255,
31
] | python | en | ['en', 'en', 'en'] | True |
DstTzInfo.localize | (self, dt, is_dst=False) | Convert naive time to local time.
This method should be used to construct localtimes, rather
than passing a tzinfo argument to a datetime constructor.
is_dst is used to determine the correct timezone in the ambigous
period at the end of daylight saving time.
>>> from pytz impo... | Convert naive time to local time. | def localize(self, dt, is_dst=False):
'''Convert naive time to local time.
This method should be used to construct localtimes, rather
than passing a tzinfo argument to a datetime constructor.
is_dst is used to determine the correct timezone in the ambigous
period at the end of ... | [
"def",
"localize",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"False",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"'Not naive datetime (tzinfo is already set)'",
")",
"# Find the two best possibilities.",
"possible_... | [
257,
4
] | [
393,
51
] | python | en | ['en', 'en', 'en'] | True |
DstTzInfo.utcoffset | (self, dt, is_dst=None) | See datetime.tzinfo.utcoffset
The is_dst parameter may be used to remove ambiguity during DST
transitions.
>>> from pytz import timezone
>>> tz = timezone('America/St_Johns')
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
>>> str(tz.utcoffset(ambiguous, is_dst=False))
... | See datetime.tzinfo.utcoffset | def utcoffset(self, dt, is_dst=None):
'''See datetime.tzinfo.utcoffset
The is_dst parameter may be used to remove ambiguity during DST
transitions.
>>> from pytz import timezone
>>> tz = timezone('America/St_Johns')
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
... | [
"def",
"utcoffset",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"None",
")",
":",
"if",
"dt",
"is",
"None",
":",
"return",
"None",
"elif",
"dt",
".",
"tzinfo",
"is",
"not",
"self",
":",
"dt",
"=",
"self",
".",
"localize",
"(",
"dt",
",",
"is_dst"... | [
395,
4
] | [
424,
34
] | python | de | ['en', 'ny', 'de'] | False |
DstTzInfo.dst | (self, dt, is_dst=None) | See datetime.tzinfo.dst
The is_dst parameter may be used to remove ambiguity during DST
transitions.
>>> from pytz import timezone
>>> tz = timezone('America/St_Johns')
>>> normal = datetime(2009, 9, 1)
>>> str(tz.dst(normal))
'1:00:00'
>>> str(tz.dst(... | See datetime.tzinfo.dst | def dst(self, dt, is_dst=None):
'''See datetime.tzinfo.dst
The is_dst parameter may be used to remove ambiguity during DST
transitions.
>>> from pytz import timezone
>>> tz = timezone('America/St_Johns')
>>> normal = datetime(2009, 9, 1)
>>> str(tz.dst(normal)... | [
"def",
"dst",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"None",
")",
":",
"if",
"dt",
"is",
"None",
":",
"return",
"None",
"elif",
"dt",
".",
"tzinfo",
"is",
"not",
"self",
":",
"dt",
"=",
"self",
".",
"localize",
"(",
"dt",
",",
"is_dst",
")... | [
426,
4
] | [
463,
28
] | python | en | ['en', 'en', 'de'] | False |
DstTzInfo.tzname | (self, dt, is_dst=None) | See datetime.tzinfo.tzname
The is_dst parameter may be used to remove ambiguity during DST
transitions.
>>> from pytz import timezone
>>> tz = timezone('America/St_Johns')
>>> normal = datetime(2009, 9, 1)
>>> tz.tzname(normal)
'NDT'
>>> tz.tzname(norm... | See datetime.tzinfo.tzname | def tzname(self, dt, is_dst=None):
'''See datetime.tzinfo.tzname
The is_dst parameter may be used to remove ambiguity during DST
transitions.
>>> from pytz import timezone
>>> tz = timezone('America/St_Johns')
>>> normal = datetime(2009, 9, 1)
>>> tz.tzname(no... | [
"def",
"tzname",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"None",
")",
":",
"if",
"dt",
"is",
"None",
":",
"return",
"self",
".",
"zone",
"elif",
"dt",
".",
"tzinfo",
"is",
"not",
"self",
":",
"dt",
"=",
"self",
".",
"localize",
"(",
"dt",
"... | [
465,
4
] | [
501,
31
] | python | de | ['de', 'en', 'de'] | False |
reset_urlconf | (sender, **kwargs) | Reset the URLconf after each request is finished. | Reset the URLconf after each request is finished. | def reset_urlconf(sender, **kwargs):
"""Reset the URLconf after each request is finished."""
set_urlconf(None) | [
"def",
"reset_urlconf",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"set_urlconf",
"(",
"None",
")"
] | [
344,
0
] | [
346,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseHandler.load_middleware | (self, is_async=False) |
Populate middleware lists from settings.MIDDLEWARE.
Must be called after the environment is fixed (see __call__ in subclasses).
|
Populate middleware lists from settings.MIDDLEWARE. | def load_middleware(self, is_async=False):
"""
Populate middleware lists from settings.MIDDLEWARE.
Must be called after the environment is fixed (see __call__ in subclasses).
"""
self._view_middleware = []
self._template_response_middleware = []
self._exception_m... | [
"def",
"load_middleware",
"(",
"self",
",",
"is_async",
"=",
"False",
")",
":",
"self",
".",
"_view_middleware",
"=",
"[",
"]",
"self",
".",
"_template_response_middleware",
"=",
"[",
"]",
"self",
".",
"_exception_middleware",
"=",
"[",
"]",
"get_response",
... | [
25,
4
] | [
96,
40
] | python | en | ['en', 'error', 'th'] | False |
BaseHandler.adapt_method_mode | (
self, is_async, method, method_is_async=None, debug=False, name=None,
) |
Adapt a method to be in the correct "mode":
- If is_async is False:
- Synchronous methods are left alone
- Asynchronous methods are wrapped with async_to_sync
- If is_async is True:
- Synchronous methods are wrapped with sync_to_async()
- Asynchronous met... |
Adapt a method to be in the correct "mode":
- If is_async is False:
- Synchronous methods are left alone
- Asynchronous methods are wrapped with async_to_sync
- If is_async is True:
- Synchronous methods are wrapped with sync_to_async()
- Asynchronous met... | def adapt_method_mode(
self, is_async, method, method_is_async=None, debug=False, name=None,
):
"""
Adapt a method to be in the correct "mode":
- If is_async is False:
- Synchronous methods are left alone
- Asynchronous methods are wrapped with async_to_sync
... | [
"def",
"adapt_method_mode",
"(",
"self",
",",
"is_async",
",",
"method",
",",
"method_is_async",
"=",
"None",
",",
"debug",
"=",
"False",
",",
"name",
"=",
"None",
",",
")",
":",
"if",
"method_is_async",
"is",
"None",
":",
"method_is_async",
"=",
"asyncio"... | [
98,
4
] | [
123,
21
] | python | en | ['en', 'error', 'th'] | False |
BaseHandler.get_response | (self, request) | Return an HttpResponse object for the given HttpRequest. | Return an HttpResponse object for the given HttpRequest. | def get_response(self, request):
"""Return an HttpResponse object for the given HttpRequest."""
# Setup default url resolver for this thread
set_urlconf(settings.ROOT_URLCONF)
response = self._middleware_chain(request)
response._resource_closers.append(request.close)
if r... | [
"def",
"get_response",
"(",
"self",
",",
"request",
")",
":",
"# Setup default url resolver for this thread",
"set_urlconf",
"(",
"settings",
".",
"ROOT_URLCONF",
")",
"response",
"=",
"self",
".",
"_middleware_chain",
"(",
"request",
")",
"response",
".",
"_resourc... | [
125,
4
] | [
137,
23
] | python | en | ['en', 'en', 'en'] | True |
BaseHandler.get_response_async | (self, request) |
Asynchronous version of get_response.
Funneling everything, including WSGI, into a single async
get_response() is too slow. Avoid the context switch by using
a separate async response path.
|
Asynchronous version of get_response. | async def get_response_async(self, request):
"""
Asynchronous version of get_response.
Funneling everything, including WSGI, into a single async
get_response() is too slow. Avoid the context switch by using
a separate async response path.
"""
# Setup default url ... | [
"async",
"def",
"get_response_async",
"(",
"self",
",",
"request",
")",
":",
"# Setup default url resolver for this thread.",
"set_urlconf",
"(",
"settings",
".",
"ROOT_URLCONF",
")",
"response",
"=",
"await",
"self",
".",
"_middleware_chain",
"(",
"request",
")",
"... | [
139,
4
] | [
157,
23
] | python | en | ['en', 'error', 'th'] | False |
BaseHandler._get_response | (self, request) |
Resolve and call the view, then apply view, exception, and
template_response middleware. This method is everything that happens
inside the request/response middleware.
|
Resolve and call the view, then apply view, exception, and
template_response middleware. This method is everything that happens
inside the request/response middleware.
| def _get_response(self, request):
"""
Resolve and call the view, then apply view, exception, and
template_response middleware. This method is everything that happens
inside the request/response middleware.
"""
response = None
callback, callback_args, callback_kwar... | [
"def",
"_get_response",
"(",
"self",
",",
"request",
")",
":",
"response",
"=",
"None",
"callback",
",",
"callback_args",
",",
"callback_kwargs",
"=",
"self",
".",
"resolve_request",
"(",
"request",
")",
"# Apply view middleware",
"for",
"middleware_method",
"in",... | [
159,
4
] | [
209,
23
] | python | en | ['en', 'error', 'th'] | False |
BaseHandler._get_response_async | (self, request) |
Resolve and call the view, then apply view, exception, and
template_response middleware. This method is everything that happens
inside the request/response middleware.
|
Resolve and call the view, then apply view, exception, and
template_response middleware. This method is everything that happens
inside the request/response middleware.
| async def _get_response_async(self, request):
"""
Resolve and call the view, then apply view, exception, and
template_response middleware. This method is everything that happens
inside the request/response middleware.
"""
response = None
callback, callback_args, c... | [
"async",
"def",
"_get_response_async",
"(",
"self",
",",
"request",
")",
":",
"response",
"=",
"None",
"callback",
",",
"callback_args",
",",
"callback_kwargs",
"=",
"self",
".",
"resolve_request",
"(",
"request",
")",
"# Apply view middleware.",
"for",
"middlewar... | [
211,
4
] | [
274,
23
] | python | en | ['en', 'error', 'th'] | False |
BaseHandler.resolve_request | (self, request) |
Retrieve/set the urlconf for the request. Return the view resolved,
with its args and kwargs.
|
Retrieve/set the urlconf for the request. Return the view resolved,
with its args and kwargs.
| def resolve_request(self, request):
"""
Retrieve/set the urlconf for the request. Return the view resolved,
with its args and kwargs.
"""
# Work out the resolver.
if hasattr(request, 'urlconf'):
urlconf = request.urlconf
set_urlconf(urlconf)
... | [
"def",
"resolve_request",
"(",
"self",
",",
"request",
")",
":",
"# Work out the resolver.",
"if",
"hasattr",
"(",
"request",
",",
"'urlconf'",
")",
":",
"urlconf",
"=",
"request",
".",
"urlconf",
"set_urlconf",
"(",
"urlconf",
")",
"resolver",
"=",
"get_resol... | [
276,
4
] | [
291,
29
] | python | en | ['en', 'error', 'th'] | False |
BaseHandler.check_response | (self, response, callback, name=None) |
Raise an error if the view returned None or an uncalled coroutine.
|
Raise an error if the view returned None or an uncalled coroutine.
| def check_response(self, response, callback, name=None):
"""
Raise an error if the view returned None or an uncalled coroutine.
"""
if not(response is None or asyncio.iscoroutine(response)):
return
if not name:
if isinstance(callback, types.FunctionType): ... | [
"def",
"check_response",
"(",
"self",
",",
"response",
",",
"callback",
",",
"name",
"=",
"None",
")",
":",
"if",
"not",
"(",
"response",
"is",
"None",
"or",
"asyncio",
".",
"iscoroutine",
"(",
"response",
")",
")",
":",
"return",
"if",
"not",
"name",
... | [
293,
4
] | [
317,
13
] | python | en | ['en', 'error', 'th'] | False |
BaseHandler.process_exception_by_middleware | (self, exception, request) |
Pass the exception to the exception middleware. If no middleware
return a response for this exception, return None.
|
Pass the exception to the exception middleware. If no middleware
return a response for this exception, return None.
| def process_exception_by_middleware(self, exception, request):
"""
Pass the exception to the exception middleware. If no middleware
return a response for this exception, return None.
"""
for middleware_method in self._exception_middleware:
response = middleware_method... | [
"def",
"process_exception_by_middleware",
"(",
"self",
",",
"exception",
",",
"request",
")",
":",
"for",
"middleware_method",
"in",
"self",
".",
"_exception_middleware",
":",
"response",
"=",
"middleware_method",
"(",
"request",
",",
"exception",
")",
"if",
"resp... | [
332,
4
] | [
341,
19
] | python | en | ['en', 'error', 'th'] | False |
sleep | (seconds: float) |
Sleep strategy that delays execution for a given number of seconds.
This is the default strategy, and may be mocked out for unit testing.
|
Sleep strategy that delays execution for a given number of seconds. | def sleep(seconds: float) -> None:
"""
Sleep strategy that delays execution for a given number of seconds.
This is the default strategy, and may be mocked out for unit testing.
"""
time.sleep(seconds) | [
"def",
"sleep",
"(",
"seconds",
":",
"float",
")",
"->",
"None",
":",
"time",
".",
"sleep",
"(",
"seconds",
")"
] | [
24,
0
] | [
30,
23
] | python | en | ['en', 'error', 'th'] | False |
csrf_failure | (request, reason="", template_name=CSRF_FAILURE_TEMPLATE_NAME) |
Default view used when request fails CSRF protection
|
Default view used when request fails CSRF protection
| def csrf_failure(request, reason="", template_name=CSRF_FAILURE_TEMPLATE_NAME):
"""
Default view used when request fails CSRF protection
"""
from django.middleware.csrf import REASON_NO_CSRF_COOKIE, REASON_NO_REFERER
c = {
'title': _("Forbidden"),
'main': _("CSRF verification failed.... | [
"def",
"csrf_failure",
"(",
"request",
",",
"reason",
"=",
"\"\"",
",",
"template_name",
"=",
"CSRF_FAILURE_TEMPLATE_NAME",
")",
":",
"from",
"django",
".",
"middleware",
".",
"csrf",
"import",
"REASON_NO_CSRF_COOKIE",
",",
"REASON_NO_REFERER",
"c",
"=",
"{",
"'... | [
103,
0
] | [
153,
71
] | python | en | ['en', 'error', 'th'] | False |
Photo.validate_image_size | (f: File) | validate uploaded image size is within range | validate uploaded image size is within range | def validate_image_size(f: File): # noqa
""" validate uploaded image size is within range """
filesize = f.size
size_limit = int(settings.MAX_IMAGE_SIZE) * 1024 * 1024
if filesize > size_limit:
raise ValidationError(f"Max file size is {settings.MAX_IMAGE_SIZE}MB") | [
"def",
"validate_image_size",
"(",
"f",
":",
"File",
")",
":",
"# noqa",
"filesize",
"=",
"f",
".",
"size",
"size_limit",
"=",
"int",
"(",
"settings",
".",
"MAX_IMAGE_SIZE",
")",
"*",
"1024",
"*",
"1024",
"if",
"filesize",
">",
"size_limit",
":",
"raise"... | [
18,
4
] | [
23,
82
] | python | en | ['en', 'zu', 'en'] | True |
load | (fp: TextIO, *, parse_float: ParseFloat = float) | Parse TOML from a file object. | Parse TOML from a file object. | def load(fp: TextIO, *, parse_float: ParseFloat = float) -> Dict[str, Any]:
"""Parse TOML from a file object."""
s = fp.read()
return loads(s, parse_float=parse_float) | [
"def",
"load",
"(",
"fp",
":",
"TextIO",
",",
"*",
",",
"parse_float",
":",
"ParseFloat",
"=",
"float",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"s",
"=",
"fp",
".",
"read",
"(",
")",
"return",
"loads",
"(",
"s",
",",
"parse_float",
... | [
69,
0
] | [
72,
44
] | python | en | ['en', 'en', 'en'] | True |
loads | (s: str, *, parse_float: ParseFloat = float) | Parse TOML from a string. | Parse TOML from a string. | def loads(s: str, *, parse_float: ParseFloat = float) -> Dict[str, Any]: # noqa: C901
"""Parse TOML from a string."""
# The spec allows converting "\r\n" to "\n", even in string
# literals. Let's do so to simplify parsing.
src = s.replace("\r\n", "\n")
pos = 0
state = State()
# Parse one ... | [
"def",
"loads",
"(",
"s",
":",
"str",
",",
"*",
",",
"parse_float",
":",
"ParseFloat",
"=",
"float",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# noqa: C901",
"# The spec allows converting \"\\r\\n\" to \"\\n\", even in string",
"# literals. Let's do so t... | [
75,
0
] | [
135,
25
] | python | en | ['en', 'en', 'en'] | True |
suffixed_err | (src: str, pos: Pos, msg: str) | Return a `TOMLDecodeError` where error message is suffixed with
coordinates in source. | Return a `TOMLDecodeError` where error message is suffixed with
coordinates in source. | def suffixed_err(src: str, pos: Pos, msg: str) -> TOMLDecodeError:
"""Return a `TOMLDecodeError` where error message is suffixed with
coordinates in source."""
def coord_repr(src: str, pos: Pos) -> str:
if pos >= len(src):
return "end of document"
line = src.count("\n", 0, pos) ... | [
"def",
"suffixed_err",
"(",
"src",
":",
"str",
",",
"pos",
":",
"Pos",
",",
"msg",
":",
"str",
")",
"->",
"TOMLDecodeError",
":",
"def",
"coord_repr",
"(",
"src",
":",
"str",
",",
"pos",
":",
"Pos",
")",
"->",
"str",
":",
"if",
"pos",
">=",
"len"... | [
684,
0
] | [
698,
64
] | python | en | ['en', 'en', 'en'] | True |
ip_address_validators | (protocol, unpack_ipv4) |
Depending on the given parameters, return the appropriate validators for
the GenericIPAddressField.
|
Depending on the given parameters, return the appropriate validators for
the GenericIPAddressField.
| def ip_address_validators(protocol, unpack_ipv4):
"""
Depending on the given parameters, return the appropriate validators for
the GenericIPAddressField.
"""
if protocol != 'both' and unpack_ipv4:
raise ValueError(
"You can only use `unpack_ipv4` if `protocol` is set to 'both'")
... | [
"def",
"ip_address_validators",
"(",
"protocol",
",",
"unpack_ipv4",
")",
":",
"if",
"protocol",
"!=",
"'both'",
"and",
"unpack_ipv4",
":",
"raise",
"ValueError",
"(",
"\"You can only use `unpack_ipv4` if `protocol` is set to 'both'\"",
")",
"try",
":",
"return",
"ip_ad... | [
315,
0
] | [
327,
70
] | python | en | ['en', 'error', 'th'] | False |
publish_messages | (project, topic_name) | Publishes multiple messages to a Pub/Sub topic. | Publishes multiple messages to a Pub/Sub topic. | def publish_messages(project, topic_name):
"""Publishes multiple messages to a Pub/Sub topic."""
# [START pubsub_quickstart_publisher]
# [START pubsub_publish]
publisher = pubsub_v1.PublisherClient()
topic_path = publisher.topic_path(project, topic_name)
f = open("sensorData.txt","r")
#for ... | [
"def",
"publish_messages",
"(",
"project",
",",
"topic_name",
")",
":",
"# [START pubsub_quickstart_publisher]",
"# [START pubsub_publish]",
"publisher",
"=",
"pubsub_v1",
".",
"PublisherClient",
"(",
")",
"topic_path",
"=",
"publisher",
".",
"topic_path",
"(",
"project... | [
6,
0
] | [
26,
32
] | python | en | ['en', 'en', 'en'] | True |
_is_relevant_relation | (relation, altered_field) |
When altering the given field, must constraints on its model from the given
relation be temporarily dropped?
|
When altering the given field, must constraints on its model from the given
relation be temporarily dropped?
| def _is_relevant_relation(relation, altered_field):
"""
When altering the given field, must constraints on its model from the given
relation be temporarily dropped?
"""
field = relation.field
if field.many_to_many:
# M2M reverse field
return False
if altered_field.primary_key... | [
"def",
"_is_relevant_relation",
"(",
"relation",
",",
"altered_field",
")",
":",
"field",
"=",
"relation",
".",
"field",
"if",
"field",
".",
"many_to_many",
":",
"# M2M reverse field",
"return",
"False",
"if",
"altered_field",
".",
"primary_key",
"and",
"field",
... | [
15,
0
] | [
28,
48
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.execute | (self, sql, params=()) | Execute the given SQL statement, with optional parameters. | Execute the given SQL statement, with optional parameters. | def execute(self, sql, params=()):
"""Execute the given SQL statement, with optional parameters."""
# Don't perform the transactional DDL check if SQL is being collected
# as it's not going to be executed anyway.
if not self.collect_sql and self.connection.in_atomic_block and not self.co... | [
"def",
"execute",
"(",
"self",
",",
"sql",
",",
"params",
"=",
"(",
")",
")",
":",
"# Don't perform the transactional DDL check if SQL is being collected",
"# as it's not going to be executed anyway.",
"if",
"not",
"self",
".",
"collect_sql",
"and",
"self",
".",
"connec... | [
123,
4
] | [
144,
43
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.table_sql | (self, model) | Take a model and return its table definition. | Take a model and return its table definition. | def table_sql(self, model):
"""Take a model and return its table definition."""
# Add any unique_togethers (always deferred, as some fields might be
# created afterwards, like geometry fields with some backends).
for fields in model._meta.unique_together:
columns = [model._me... | [
"def",
"table_sql",
"(",
"self",
",",
"model",
")",
":",
"# Add any unique_togethers (always deferred, as some fields might be",
"# created afterwards, like geometry fields with some backends).",
"for",
"fields",
"in",
"model",
".",
"_meta",
".",
"unique_together",
":",
"column... | [
149,
4
] | [
204,
26
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.column_sql | (self, model, field, include_default=False) |
Take a field and return its column definition.
The field must already have had set_attributes_from_name() called.
|
Take a field and return its column definition.
The field must already have had set_attributes_from_name() called.
| def column_sql(self, model, field, include_default=False):
"""
Take a field and return its column definition.
The field must already have had set_attributes_from_name() called.
"""
# Get the column's type and use that as the basis of the SQL
db_params = field.db_parameter... | [
"def",
"column_sql",
"(",
"self",
",",
"model",
",",
"field",
",",
"include_default",
"=",
"False",
")",
":",
"# Get the column's type and use that as the basis of the SQL",
"db_params",
"=",
"field",
".",
"db_parameters",
"(",
"connection",
"=",
"self",
".",
"conne... | [
208,
4
] | [
266,
26
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.skip_default | (self, field) |
Some backends don't accept default values for certain columns types
(i.e. MySQL longtext and longblob).
|
Some backends don't accept default values for certain columns types
(i.e. MySQL longtext and longblob).
| def skip_default(self, field):
"""
Some backends don't accept default values for certain columns types
(i.e. MySQL longtext and longblob).
"""
return False | [
"def",
"skip_default",
"(",
"self",
",",
"field",
")",
":",
"return",
"False"
] | [
268,
4
] | [
273,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.skip_default_on_alter | (self, field) |
Some backends don't accept default values for certain columns types
(i.e. MySQL longtext and longblob) in the ALTER COLUMN statement.
|
Some backends don't accept default values for certain columns types
(i.e. MySQL longtext and longblob) in the ALTER COLUMN statement.
| def skip_default_on_alter(self, field):
"""
Some backends don't accept default values for certain columns types
(i.e. MySQL longtext and longblob) in the ALTER COLUMN statement.
"""
return False | [
"def",
"skip_default_on_alter",
"(",
"self",
",",
"field",
")",
":",
"return",
"False"
] | [
275,
4
] | [
280,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.prepare_default | (self, value) |
Only used for backends which have requires_literal_defaults feature
|
Only used for backends which have requires_literal_defaults feature
| def prepare_default(self, value):
"""
Only used for backends which have requires_literal_defaults feature
"""
raise NotImplementedError(
'subclasses of BaseDatabaseSchemaEditor for backends which have '
'requires_literal_defaults must provide a prepare_default() m... | [
"def",
"prepare_default",
"(",
"self",
",",
"value",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseSchemaEditor for backends which have '",
"'requires_literal_defaults must provide a prepare_default() method'",
")"
] | [
282,
4
] | [
289,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._column_default_sql | (self, field) |
Return the SQL to use in a DEFAULT clause. The resulting string should
contain a '%s' placeholder for a default value.
|
Return the SQL to use in a DEFAULT clause. The resulting string should
contain a '%s' placeholder for a default value.
| def _column_default_sql(self, field):
"""
Return the SQL to use in a DEFAULT clause. The resulting string should
contain a '%s' placeholder for a default value.
"""
return '%s' | [
"def",
"_column_default_sql",
"(",
"self",
",",
"field",
")",
":",
"return",
"'%s'"
] | [
291,
4
] | [
296,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.effective_default | (self, field) | Return a field's effective database default value. | Return a field's effective database default value. | def effective_default(self, field):
"""Return a field's effective database default value."""
return field.get_db_prep_save(self._effective_default(field), self.connection) | [
"def",
"effective_default",
"(",
"self",
",",
"field",
")",
":",
"return",
"field",
".",
"get_db_prep_save",
"(",
"self",
".",
"_effective_default",
"(",
"field",
")",
",",
"self",
".",
"connection",
")"
] | [
321,
4
] | [
323,
86
] | python | da | ['ro', 'da', 'en'] | False |
BaseDatabaseSchemaEditor.quote_value | (self, value) |
Return a quoted version of the value so it's safe to use in an SQL
string. This is not safe against injection from user code; it is
intended only for use in making SQL scripts or preparing default values
for particularly tricky backends (defaults are not user-defined, though,
so... |
Return a quoted version of the value so it's safe to use in an SQL
string. This is not safe against injection from user code; it is
intended only for use in making SQL scripts or preparing default values
for particularly tricky backends (defaults are not user-defined, though,
so... | def quote_value(self, value):
"""
Return a quoted version of the value so it's safe to use in an SQL
string. This is not safe against injection from user code; it is
intended only for use in making SQL scripts or preparing default values
for particularly tricky backends (defaults... | [
"def",
"quote_value",
"(",
"self",
",",
"value",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
325,
4
] | [
333,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.create_model | (self, model) |
Create a table and any accompanying indexes or unique constraints for
the given `model`.
|
Create a table and any accompanying indexes or unique constraints for
the given `model`.
| def create_model(self, model):
"""
Create a table and any accompanying indexes or unique constraints for
the given `model`.
"""
sql, params = self.table_sql(model)
# Prevent using [] as params, in the case a literal '%' is used in the definition
self.execute(sql, ... | [
"def",
"create_model",
"(",
"self",
",",
"model",
")",
":",
"sql",
",",
"params",
"=",
"self",
".",
"table_sql",
"(",
"model",
")",
"# Prevent using [] as params, in the case a literal '%' is used in the definition",
"self",
".",
"execute",
"(",
"sql",
",",
"params"... | [
337,
4
] | [
352,
61
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.delete_model | (self, model) | Delete a model from the database. | Delete a model from the database. | def delete_model(self, model):
"""Delete a model from the database."""
# Handle auto-created intermediary models
for field in model._meta.local_many_to_many:
if field.remote_field.through._meta.auto_created:
self.delete_model(field.remote_field.through)
# Del... | [
"def",
"delete_model",
"(",
"self",
",",
"model",
")",
":",
"# Handle auto-created intermediary models",
"for",
"field",
"in",
"model",
".",
"_meta",
".",
"local_many_to_many",
":",
"if",
"field",
".",
"remote_field",
".",
"through",
".",
"_meta",
".",
"auto_cre... | [
354,
4
] | [
368,
45
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.add_index | (self, model, index) | Add an index on a model. | Add an index on a model. | def add_index(self, model, index):
"""Add an index on a model."""
if (
index.contains_expressions and
not self.connection.features.supports_expression_indexes
):
return None
# Index.create_sql returns interpolated SQL which makes params=None a
... | [
"def",
"add_index",
"(",
"self",
",",
"model",
",",
"index",
")",
":",
"if",
"(",
"index",
".",
"contains_expressions",
"and",
"not",
"self",
".",
"connection",
".",
"features",
".",
"supports_expression_indexes",
")",
":",
"return",
"None",
"# Index.create_sq... | [
370,
4
] | [
379,
64
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.remove_index | (self, model, index) | Remove an index from a model. | Remove an index from a model. | def remove_index(self, model, index):
"""Remove an index from a model."""
if (
index.contains_expressions and
not self.connection.features.supports_expression_indexes
):
return None
self.execute(index.remove_sql(model, self)) | [
"def",
"remove_index",
"(",
"self",
",",
"model",
",",
"index",
")",
":",
"if",
"(",
"index",
".",
"contains_expressions",
"and",
"not",
"self",
".",
"connection",
".",
"features",
".",
"supports_expression_indexes",
")",
":",
"return",
"None",
"self",
".",
... | [
381,
4
] | [
388,
51
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.add_constraint | (self, model, constraint) | Add a constraint to a model. | Add a constraint to a model. | def add_constraint(self, model, constraint):
"""Add a constraint to a model."""
sql = constraint.create_sql(model, self)
if sql:
# Constraint.create_sql returns interpolated SQL which makes
# params=None a necessity to avoid escaping attempts on execution.
sel... | [
"def",
"add_constraint",
"(",
"self",
",",
"model",
",",
"constraint",
")",
":",
"sql",
"=",
"constraint",
".",
"create_sql",
"(",
"model",
",",
"self",
")",
"if",
"sql",
":",
"# Constraint.create_sql returns interpolated SQL which makes",
"# params=None a necessity t... | [
390,
4
] | [
396,
42
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.remove_constraint | (self, model, constraint) | Remove a constraint from a model. | Remove a constraint from a model. | def remove_constraint(self, model, constraint):
"""Remove a constraint from a model."""
sql = constraint.remove_sql(model, self)
if sql:
self.execute(sql) | [
"def",
"remove_constraint",
"(",
"self",
",",
"model",
",",
"constraint",
")",
":",
"sql",
"=",
"constraint",
".",
"remove_sql",
"(",
"model",
",",
"self",
")",
"if",
"sql",
":",
"self",
".",
"execute",
"(",
"sql",
")"
] | [
398,
4
] | [
402,
29
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.alter_unique_together | (self, model, old_unique_together, new_unique_together) |
Deal with a model changing its unique_together. The input
unique_togethers must be doubly-nested, not the single-nested
["foo", "bar"] format.
|
Deal with a model changing its unique_together. The input
unique_togethers must be doubly-nested, not the single-nested
["foo", "bar"] format.
| def alter_unique_together(self, model, old_unique_together, new_unique_together):
"""
Deal with a model changing its unique_together. The input
unique_togethers must be doubly-nested, not the single-nested
["foo", "bar"] format.
"""
olds = {tuple(fields) for fields in old... | [
"def",
"alter_unique_together",
"(",
"self",
",",
"model",
",",
"old_unique_together",
",",
"new_unique_together",
")",
":",
"olds",
"=",
"{",
"tuple",
"(",
"fields",
")",
"for",
"fields",
"in",
"old_unique_together",
"}",
"news",
"=",
"{",
"tuple",
"(",
"fi... | [
404,
4
] | [
418,
65
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.alter_index_together | (self, model, old_index_together, new_index_together) |
Deal with a model changing its index_together. The input
index_togethers must be doubly-nested, not the single-nested
["foo", "bar"] format.
|
Deal with a model changing its index_together. The input
index_togethers must be doubly-nested, not the single-nested
["foo", "bar"] format.
| def alter_index_together(self, model, old_index_together, new_index_together):
"""
Deal with a model changing its index_together. The input
index_togethers must be doubly-nested, not the single-nested
["foo", "bar"] format.
"""
olds = {tuple(fields) for fields in old_inde... | [
"def",
"alter_index_together",
"(",
"self",
",",
"model",
",",
"old_index_together",
",",
"new_index_together",
")",
":",
"olds",
"=",
"{",
"tuple",
"(",
"fields",
")",
"for",
"fields",
"in",
"old_index_together",
"}",
"news",
"=",
"{",
"tuple",
"(",
"fields... | [
420,
4
] | [
439,
85
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.alter_db_table | (self, model, old_db_table, new_db_table) | Rename the table a model points to. | Rename the table a model points to. | def alter_db_table(self, model, old_db_table, new_db_table):
"""Rename the table a model points to."""
if (old_db_table == new_db_table or
(self.connection.features.ignores_table_name_case and
old_db_table.lower() == new_db_table.lower())):
return
self.exe... | [
"def",
"alter_db_table",
"(",
"self",
",",
"model",
",",
"old_db_table",
",",
"new_db_table",
")",
":",
"if",
"(",
"old_db_table",
"==",
"new_db_table",
"or",
"(",
"self",
".",
"connection",
".",
"features",
".",
"ignores_table_name_case",
"and",
"old_db_table",... | [
457,
4
] | [
470,
71
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.alter_db_tablespace | (self, model, old_db_tablespace, new_db_tablespace) | Move a model's table between tablespaces. | Move a model's table between tablespaces. | def alter_db_tablespace(self, model, old_db_tablespace, new_db_tablespace):
"""Move a model's table between tablespaces."""
self.execute(self.sql_retablespace_table % {
"table": self.quote_name(model._meta.db_table),
"old_tablespace": self.quote_name(old_db_tablespace),
... | [
"def",
"alter_db_tablespace",
"(",
"self",
",",
"model",
",",
"old_db_tablespace",
",",
"new_db_tablespace",
")",
":",
"self",
".",
"execute",
"(",
"self",
".",
"sql_retablespace_table",
"%",
"{",
"\"table\"",
":",
"self",
".",
"quote_name",
"(",
"model",
".",... | [
472,
4
] | [
478,
10
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor.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",
".",... | [
480,
4
] | [
535,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.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.
"""
# Special-case implicit M2M tables
if field.many_to_many and field.remote_field.through._meta.auto_created:
... | [
"def",
"remove_field",
"(",
"self",
",",
"model",
",",
"field",
")",
":",
"# Special-case implicit M2M tables",
"if",
"field",
".",
"many_to_many",
"and",
"field",
".",
"remote_field",
".",
"through",
".",
"_meta",
".",
"auto_created",
":",
"return",
"self",
"... | [
537,
4
] | [
565,
45
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor.alter_field | (self, model, old_field, new_field, strict=False) |
Allow a field's type, uniqueness, nullability, default, column,
constraints, etc. to be modified.
`old_field` is required to compute the necessary changes.
If `strict` is True, raise errors if the old column does not match
`old_field` precisely.
|
Allow a field's type, uniqueness, nullability, default, column,
constraints, etc. to be modified.
`old_field` is required to compute the necessary changes.
If `strict` is True, raise errors if the old column does not match
`old_field` precisely.
| def alter_field(self, model, old_field, new_field, strict=False):
"""
Allow a field's type, uniqueness, nullability, default, column,
constraints, etc. to be modified.
`old_field` is required to compute the necessary changes.
If `strict` is True, raise errors if the old column do... | [
"def",
"alter_field",
"(",
"self",
",",
"model",
",",
"old_field",
",",
"new_field",
",",
"strict",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"_field_should_be_altered",
"(",
"old_field",
",",
"new_field",
")",
":",
"return",
"# Ensure this field is ev... | [
567,
4
] | [
608,
63
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._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."""
# Drop any FK constraints, we'll remake them later
fks_dropped = set()
if (
self... | [
"def",
"_alter_field",
"(",
"self",
",",
"model",
",",
"old_field",
",",
"new_field",
",",
"old_type",
",",
"new_type",
",",
"old_db_params",
",",
"new_db_params",
",",
"strict",
"=",
"False",
")",
":",
"# Drop any FK constraints, we'll remake them later",
"fks_drop... | [
610,
4
] | [
863,
35
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor._alter_column_null_sql | (self, model, old_field, new_field) |
Hook to specialize column null alteration.
Return a (sql, params) fragment to set a column to null or non-null
as required by new_field, or None if no changes are required.
|
Hook to specialize column null alteration. | def _alter_column_null_sql(self, model, old_field, new_field):
"""
Hook to specialize column null alteration.
Return a (sql, params) fragment to set a column to null or non-null
as required by new_field, or None if no changes are required.
"""
if (self.connection.feature... | [
"def",
"_alter_column_null_sql",
"(",
"self",
",",
"model",
",",
"old_field",
",",
"new_field",
")",
":",
"if",
"(",
"self",
".",
"connection",
".",
"features",
".",
"interprets_empty_strings_as_nulls",
"and",
"new_field",
".",
"get_internal_type",
"(",
")",
"in... | [
865,
4
] | [
885,
13
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._alter_column_default_sql | (self, model, old_field, new_field, drop=False) |
Hook to specialize column default alteration.
Return a (sql, params) fragment to add or drop (depending on the drop
argument) a default to new_field's column.
|
Hook to specialize column default alteration. | def _alter_column_default_sql(self, model, old_field, new_field, drop=False):
"""
Hook to specialize column default alteration.
Return a (sql, params) fragment to add or drop (depending on the drop
argument) a default to new_field's column.
"""
new_default = self.effecti... | [
"def",
"_alter_column_default_sql",
"(",
"self",
",",
"model",
",",
"old_field",
",",
"new_field",
",",
"drop",
"=",
"False",
")",
":",
"new_default",
"=",
"self",
".",
"effective_default",
"(",
"new_field",
")",
"default",
"=",
"self",
".",
"_column_default_s... | [
887,
4
] | [
922,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._alter_column_type_sql | (self, model, old_field, new_field, new_type) |
Hook to specialize column type alteration for different backends,
for cases when a creation type is different to an alteration type
(e.g. SERIAL in PostgreSQL, PostGIS fields).
Return a two-tuple of: an SQL fragment of (sql, params) to insert into
an ALTER TABLE statement and a... |
Hook to specialize column type alteration for different backends,
for cases when a creation type is different to an alteration type
(e.g. SERIAL in PostgreSQL, PostGIS fields). | def _alter_column_type_sql(self, model, old_field, new_field, new_type):
"""
Hook to specialize column type alteration for different backends,
for cases when a creation type is different to an alteration type
(e.g. SERIAL in PostgreSQL, PostGIS fields).
Return a two-tuple of: an... | [
"def",
"_alter_column_type_sql",
"(",
"self",
",",
"model",
",",
"old_field",
",",
"new_field",
",",
"new_type",
")",
":",
"return",
"(",
"(",
"self",
".",
"sql_alter_column_type",
"%",
"{",
"\"column\"",
":",
"self",
".",
"quote_name",
"(",
"new_field",
"."... | [
924,
4
] | [
943,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._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."""
# Rename the through table
if old_field.remote_field.through._meta.db_table != new_field.remote_field.through._meta.db_table:
self.alter_db_table(old_field.remote_fiel... | [
"def",
"_alter_many_to_many",
"(",
"self",
",",
"model",
",",
"old_field",
",",
"new_field",
",",
"strict",
")",
":",
"# Rename the through table",
"if",
"old_field",
".",
"remote_field",
".",
"through",
".",
"_meta",
".",
"db_table",
"!=",
"new_field",
".",
"... | [
955,
4
] | [
974,
9
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseSchemaEditor._create_index_name | (self, table_name, column_names, suffix="") |
Generate a unique name for an index/unique constraint.
The name is divided into 3 parts: the table name, the column names,
and a unique digest and suffix.
|
Generate a unique name for an index/unique constraint. | def _create_index_name(self, table_name, column_names, suffix=""):
"""
Generate a unique name for an index/unique constraint.
The name is divided into 3 parts: the table name, the column names,
and a unique digest and suffix.
"""
_, table_name = split_identifier(table_na... | [
"def",
"_create_index_name",
"(",
"self",
",",
"table_name",
",",
"column_names",
",",
"suffix",
"=",
"\"\"",
")",
":",
"_",
",",
"table_name",
"=",
"split_identifier",
"(",
"table_name",
")",
"hash_suffix_part",
"=",
"'%s%s'",
"%",
"(",
"names_digest",
"(",
... | [
976,
4
] | [
1003,
25
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._create_index_sql | (self, model, *, fields=None, name=None, suffix='', using='',
db_tablespace=None, col_suffixes=(), sql=None, opclasses=(),
condition=None, include=None, expressions=None) |
Return the SQL statement to create the index for one or several fields
or expressions. `sql` can be specified if the syntax differs from the
standard (GIS indexes, ...).
|
Return the SQL statement to create the index for one or several fields
or expressions. `sql` can be specified if the syntax differs from the
standard (GIS indexes, ...).
| def _create_index_sql(self, model, *, fields=None, name=None, suffix='', using='',
db_tablespace=None, col_suffixes=(), sql=None, opclasses=(),
condition=None, include=None, expressions=None):
"""
Return the SQL statement to create the index for one or... | [
"def",
"_create_index_sql",
"(",
"self",
",",
"model",
",",
"*",
",",
"fields",
"=",
"None",
",",
"name",
"=",
"None",
",",
"suffix",
"=",
"''",
",",
"using",
"=",
"''",
",",
"db_tablespace",
"=",
"None",
",",
"col_suffixes",
"=",
"(",
")",
",",
"s... | [
1028,
4
] | [
1065,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._model_indexes_sql | (self, model) |
Return a list of all index SQL statements (field indexes,
index_together, Meta.indexes) for the specified model.
|
Return a list of all index SQL statements (field indexes,
index_together, Meta.indexes) for the specified model.
| def _model_indexes_sql(self, model):
"""
Return a list of all index SQL statements (field indexes,
index_together, Meta.indexes) for the specified model.
"""
if not model._meta.managed or model._meta.proxy or model._meta.swapped:
return []
output = []
... | [
"def",
"_model_indexes_sql",
"(",
"self",
",",
"model",
")",
":",
"if",
"not",
"model",
".",
"_meta",
".",
"managed",
"or",
"model",
".",
"_meta",
".",
"proxy",
"or",
"model",
".",
"_meta",
".",
"swapped",
":",
"return",
"[",
"]",
"output",
"=",
"[",... | [
1077,
4
] | [
1098,
21
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._field_indexes_sql | (self, model, field) |
Return a list of all index SQL statements for the specified field.
|
Return a list of all index SQL statements for the specified field.
| def _field_indexes_sql(self, model, field):
"""
Return a list of all index SQL statements for the specified field.
"""
output = []
if self._field_should_be_indexed(model, field):
output.append(self._create_index_sql(model, fields=[field]))
return output | [
"def",
"_field_indexes_sql",
"(",
"self",
",",
"model",
",",
"field",
")",
":",
"output",
"=",
"[",
"]",
"if",
"self",
".",
"_field_should_be_indexed",
"(",
"model",
",",
"field",
")",
":",
"output",
".",
"append",
"(",
"self",
".",
"_create_index_sql",
... | [
1100,
4
] | [
1107,
21
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseSchemaEditor._constraint_names | (self, model, column_names=None, unique=None,
primary_key=None, index=None, foreign_key=None,
check=None, type_=None, exclude=None) | Return all constraint names matching the columns and conditions. | Return all constraint names matching the columns and conditions. | def _constraint_names(self, model, column_names=None, unique=None,
primary_key=None, index=None, foreign_key=None,
check=None, type_=None, exclude=None):
"""Return all constraint names matching the columns and conditions."""
if column_names is not None... | [
"def",
"_constraint_names",
"(",
"self",
",",
"model",
",",
"column_names",
"=",
"None",
",",
"unique",
"=",
"None",
",",
"primary_key",
"=",
"None",
",",
"index",
"=",
"None",
",",
"foreign_key",
"=",
"None",
",",
"check",
"=",
"None",
",",
"type_",
"... | [
1310,
4
] | [
1338,
21
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClientMeta.get_transport_class | (
cls, label: str = None,
) | Returns an appropriate transport class.
Args:
label: The name of the desired transport. If none is
provided, then the first transport in the registry is used.
Returns:
The transport class to use.
| Returns an appropriate transport class. | def get_transport_class(
cls, label: str = None,
) -> Type[DashboardsServiceTransport]:
"""Returns an appropriate transport class.
Args:
label: The name of the desired transport. If none is
provided, then the first transport in the registry is used.
Retu... | [
"def",
"get_transport_class",
"(",
"cls",
",",
"label",
":",
"str",
"=",
"None",
",",
")",
"->",
"Type",
"[",
"DashboardsServiceTransport",
"]",
":",
"# If a specific transport is requested, return that one.",
"if",
"label",
":",
"return",
"cls",
".",
"_transport_re... | [
59,
4
] | [
77,
59
] | python | en | ['en', 'lb', 'en'] | True |
DashboardsServiceClient._get_default_mtls_endpoint | (api_endpoint) | Converts api endpoint to mTLS endpoint.
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
api_endpoint (Optional[str]): the api endpoint to convert.
Returns:
str: converted... | Converts api endpoint to mTLS endpoint. | def _get_default_mtls_endpoint(api_endpoint):
"""Converts api endpoint to mTLS endpoint.
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
api_endpoint (Optional[str]): the api endpoin... | [
"def",
"_get_default_mtls_endpoint",
"(",
"api_endpoint",
")",
":",
"if",
"not",
"api_endpoint",
":",
"return",
"api_endpoint",
"mtls_endpoint_re",
"=",
"re",
".",
"compile",
"(",
"r\"(?P<name>[^.]+)(?P<mtls>\\.mtls)?(?P<sandbox>\\.sandbox)?(?P<googledomain>\\.googleapis\\.com)?\... | [
86,
4
] | [
113,
78
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.from_service_account_info | (cls, info: dict, *args, **kwargs) | Creates an instance of this client using the provided credentials
info.
Args:
info (dict): The service account private key info.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.
Returns:
... | Creates an instance of this client using the provided credentials
info. | def from_service_account_info(cls, info: dict, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
info.
Args:
info (dict): The service account private key info.
args: Additional arguments to pass to the constructor.
kwa... | [
"def",
"from_service_account_info",
"(",
"cls",
",",
"info",
":",
"dict",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"credentials",
"=",
"service_account",
".",
"Credentials",
".",
"from_service_account_info",
"(",
"info",
")",
"kwargs",
"[",
"\"cr... | [
121,
4
] | [
135,
35
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.from_service_account_file | (cls, filename: str, *args, **kwargs) | Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the... | Creates an instance of this client using the provided credentials
file. | def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to p... | [
"def",
"from_service_account_file",
"(",
"cls",
",",
"filename",
":",
"str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"credentials",
"=",
"service_account",
".",
"Credentials",
".",
"from_service_account_file",
"(",
"filename",
")",
"kwargs",
"[",
... | [
138,
4
] | [
153,
35
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.transport | (self) | Returns the transport used by the client instance.
Returns:
DashboardsServiceTransport: The transport used by the client
instance.
| Returns the transport used by the client instance. | def transport(self) -> DashboardsServiceTransport:
"""Returns the transport used by the client instance.
Returns:
DashboardsServiceTransport: The transport used by the client
instance.
"""
return self._transport | [
"def",
"transport",
"(",
"self",
")",
"->",
"DashboardsServiceTransport",
":",
"return",
"self",
".",
"_transport"
] | [
158,
4
] | [
165,
30
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.alert_policy_path | (project: str, alert_policy: str,) | Returns a fully-qualified alert_policy string. | Returns a fully-qualified alert_policy string. | def alert_policy_path(project: str, alert_policy: str,) -> str:
"""Returns a fully-qualified alert_policy string."""
return "projects/{project}/alertPolicies/{alert_policy}".format(
project=project, alert_policy=alert_policy,
) | [
"def",
"alert_policy_path",
"(",
"project",
":",
"str",
",",
"alert_policy",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"projects/{project}/alertPolicies/{alert_policy}\"",
".",
"format",
"(",
"project",
"=",
"project",
",",
"alert_policy",
"=",
"alert_po... | [
168,
4
] | [
172,
9
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.parse_alert_policy_path | (path: str) | Parses a alert_policy path into its component segments. | Parses a alert_policy path into its component segments. | def parse_alert_policy_path(path: str) -> Dict[str, str]:
"""Parses a alert_policy path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/alertPolicies/(?P<alert_policy>.+?)$", path
)
return m.groupdict() if m else {} | [
"def",
"parse_alert_policy_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^projects/(?P<project>.+?)/alertPolicies/(?P<alert_policy>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"gr... | [
175,
4
] | [
180,
41
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.dashboard_path | (project: str, dashboard: str,) | Returns a fully-qualified dashboard string. | Returns a fully-qualified dashboard string. | def dashboard_path(project: str, dashboard: str,) -> str:
"""Returns a fully-qualified dashboard string."""
return "projects/{project}/dashboards/{dashboard}".format(
project=project, dashboard=dashboard,
) | [
"def",
"dashboard_path",
"(",
"project",
":",
"str",
",",
"dashboard",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"projects/{project}/dashboards/{dashboard}\"",
".",
"format",
"(",
"project",
"=",
"project",
",",
"dashboard",
"=",
"dashboard",
",",
")... | [
183,
4
] | [
187,
9
] | python | en | ['pt', 'en', 'en'] | True |
DashboardsServiceClient.parse_dashboard_path | (path: str) | Parses a dashboard path into its component segments. | Parses a dashboard path into its component segments. | def parse_dashboard_path(path: str) -> Dict[str, str]:
"""Parses a dashboard path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/dashboards/(?P<dashboard>.+?)$", path)
return m.groupdict() if m else {} | [
"def",
"parse_dashboard_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^projects/(?P<project>.+?)/dashboards/(?P<dashboard>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"groupdict",... | [
190,
4
] | [
193,
41
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.common_billing_account_path | (billing_account: str,) | Returns a fully-qualified billing_account string. | Returns a fully-qualified billing_account string. | def common_billing_account_path(billing_account: str,) -> str:
"""Returns a fully-qualified billing_account string."""
return "billingAccounts/{billing_account}".format(
billing_account=billing_account,
) | [
"def",
"common_billing_account_path",
"(",
"billing_account",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"billingAccounts/{billing_account}\"",
".",
"format",
"(",
"billing_account",
"=",
"billing_account",
",",
")"
] | [
196,
4
] | [
200,
9
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.parse_common_billing_account_path | (path: str) | Parse a billing_account path into its component segments. | Parse a billing_account path into its component segments. | def parse_common_billing_account_path(path: str) -> Dict[str, str]:
"""Parse a billing_account path into its component segments."""
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
return m.groupdict() if m else {} | [
"def",
"parse_common_billing_account_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^billingAccounts/(?P<billing_account>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"groupdict",
... | [
203,
4
] | [
206,
41
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.common_folder_path | (folder: str,) | Returns a fully-qualified folder string. | Returns a fully-qualified folder string. | def common_folder_path(folder: str,) -> str:
"""Returns a fully-qualified folder string."""
return "folders/{folder}".format(folder=folder,) | [
"def",
"common_folder_path",
"(",
"folder",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"folders/{folder}\"",
".",
"format",
"(",
"folder",
"=",
"folder",
",",
")"
] | [
209,
4
] | [
211,
56
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.parse_common_folder_path | (path: str) | Parse a folder path into its component segments. | Parse a folder path into its component segments. | def parse_common_folder_path(path: str) -> Dict[str, str]:
"""Parse a folder path into its component segments."""
m = re.match(r"^folders/(?P<folder>.+?)$", path)
return m.groupdict() if m else {} | [
"def",
"parse_common_folder_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^folders/(?P<folder>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"groupdict",
"(",
")",
"if",
"m"... | [
214,
4
] | [
217,
41
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.common_organization_path | (organization: str,) | Returns a fully-qualified organization string. | Returns a fully-qualified organization string. | def common_organization_path(organization: str,) -> str:
"""Returns a fully-qualified organization string."""
return "organizations/{organization}".format(organization=organization,) | [
"def",
"common_organization_path",
"(",
"organization",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"organizations/{organization}\"",
".",
"format",
"(",
"organization",
"=",
"organization",
",",
")"
] | [
220,
4
] | [
222,
80
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.parse_common_organization_path | (path: str) | Parse a organization path into its component segments. | Parse a organization path into its component segments. | def parse_common_organization_path(path: str) -> Dict[str, str]:
"""Parse a organization path into its component segments."""
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
return m.groupdict() if m else {} | [
"def",
"parse_common_organization_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^organizations/(?P<organization>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"groupdict",
"(",
... | [
225,
4
] | [
228,
41
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.common_project_path | (project: str,) | Returns a fully-qualified project string. | Returns a fully-qualified project string. | def common_project_path(project: str,) -> str:
"""Returns a fully-qualified project string."""
return "projects/{project}".format(project=project,) | [
"def",
"common_project_path",
"(",
"project",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"projects/{project}\"",
".",
"format",
"(",
"project",
"=",
"project",
",",
")"
] | [
231,
4
] | [
233,
60
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.parse_common_project_path | (path: str) | Parse a project path into its component segments. | Parse a project path into its component segments. | def parse_common_project_path(path: str) -> Dict[str, str]:
"""Parse a project path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)$", path)
return m.groupdict() if m else {} | [
"def",
"parse_common_project_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^projects/(?P<project>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"groupdict",
"(",
")",
"if",
... | [
236,
4
] | [
239,
41
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.common_location_path | (project: str, location: str,) | Returns a fully-qualified location string. | Returns a fully-qualified location string. | def common_location_path(project: str, location: str,) -> str:
"""Returns a fully-qualified location string."""
return "projects/{project}/locations/{location}".format(
project=project, location=location,
) | [
"def",
"common_location_path",
"(",
"project",
":",
"str",
",",
"location",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"projects/{project}/locations/{location}\"",
".",
"format",
"(",
"project",
"=",
"project",
",",
"location",
"=",
"location",
",",
"... | [
242,
4
] | [
246,
9
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.parse_common_location_path | (path: str) | Parse a location path into its component segments. | Parse a location path into its component segments. | def parse_common_location_path(path: str) -> Dict[str, str]:
"""Parse a location path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
return m.groupdict() if m else {} | [
"def",
"parse_common_location_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"groupdi... | [
249,
4
] | [
252,
41
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.__init__ | (
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, DashboardsServiceTransport, None] = None,
client_options: Optional[client_options_lib.ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
... | Instantiates the dashboards service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the c... | Instantiates the dashboards service client. | def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, DashboardsServiceTransport, None] = None,
client_options: Optional[client_options_lib.ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIEN... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"credentials",
":",
"Optional",
"[",
"ga_credentials",
".",
"Credentials",
"]",
"=",
"None",
",",
"transport",
":",
"Union",
"[",
"str",
",",
"DashboardsServiceTransport",
",",
"None",
"]",
"=",
"None",
",",
... | [
254,
4
] | [
376,
13
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.create_dashboard | (
self,
request: Union[dashboards_service.CreateDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Creates a new custom dashboard. For examples on how you can use
this API to create dashboards, see `Managing dashboards by
API <https://cloud.google.com/monitoring/dashboards/api-dashboard>`__.
This method requires the ``monitoring.dashboards.create``
permission on the specified proj... | r"""Creates a new custom dashboard. For examples on how you can use
this API to create dashboards, see `Managing dashboards by
API <https://cloud.google.com/monitoring/dashboards/api-dashboard>`__.
This method requires the ``monitoring.dashboards.create``
permission on the specified proj... | def create_dashboard(
self,
request: Union[dashboards_service.CreateDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Creates a new ... | [
"def",
"create_dashboard",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"CreateDashboardRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
... | [
378,
4
] | [
433,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.list_dashboards | (
self,
request: Union[dashboards_service.ListDashboardsRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Lists the existing dashboards.
This method requires the ``monitoring.dashboards.list``
permission on the specified project. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/iam>`__.
Args:
request (Union[google.cloud.monit... | r"""Lists the existing dashboards. | def list_dashboards(
self,
request: Union[dashboards_service.ListDashboardsRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDashboardsPager:
r"""Lists the... | [
"def",
"list_dashboards",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"ListDashboardsRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
... | [
435,
4
] | [
495,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.get_dashboard | (
self,
request: Union[dashboards_service.GetDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Fetches a specific dashboard.
This method requires the ``monitoring.dashboards.get``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/iam>`__.
Args:
request (Union[google.cloud.monit... | r"""Fetches a specific dashboard. | def get_dashboard(
self,
request: Union[dashboards_service.GetDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Fetches a specific d... | [
"def",
"get_dashboard",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"GetDashboardRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"tim... | [
497,
4
] | [
551,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.delete_dashboard | (
self,
request: Union[dashboards_service.DeleteDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Deletes an existing custom dashboard.
This method requires the ``monitoring.dashboards.delete``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/iam>`__.
Args:
request (Union[google.... | r"""Deletes an existing custom dashboard. | def delete_dashboard(
self,
request: Union[dashboards_service.DeleteDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes an existing custom da... | [
"def",
"delete_dashboard",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"DeleteDashboardRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
... | [
553,
4
] | [
598,
9
] | python | en | ['en', 'cy', 'en'] | True |
DashboardsServiceClient.update_dashboard | (
self,
request: Union[dashboards_service.UpdateDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Replaces an existing custom dashboard with a new definition.
This method requires the ``monitoring.dashboards.update``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/iam>`__.
Args:
... | r"""Replaces an existing custom dashboard with a new definition. | def update_dashboard(
self,
request: Union[dashboards_service.UpdateDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Replaces an ex... | [
"def",
"update_dashboard",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"UpdateDashboardRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
... | [
600,
4
] | [
656,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.__exit__ | (self, type, value, traceback) | Releases underlying transport's resources.
.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clients!
| Releases underlying transport's resources. | def __exit__(self, type, value, traceback):
"""Releases underlying transport's resources.
.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clien... | [
"def",
"__exit__",
"(",
"self",
",",
"type",
",",
"value",
",",
"traceback",
")",
":",
"self",
".",
"transport",
".",
"close",
"(",
")"
] | [
661,
4
] | [
669,
30
] | python | en | ['en', 'en', 'en'] | True |
responder | (f) | Marks a function as responder. Decorate a function with it and it
will automatically call the return value as WSGI application.
Example::
@responder
def application(environ, start_response):
return Response('Hello World!')
| Marks a function as responder. Decorate a function with it and it
will automatically call the return value as WSGI application. | def responder(f):
"""Marks a function as responder. Decorate a function with it and it
will automatically call the return value as WSGI application.
Example::
@responder
def application(environ, start_response):
return Response('Hello World!')
"""
return update_wrapper... | [
"def",
"responder",
"(",
"f",
")",
":",
"return",
"update_wrapper",
"(",
"lambda",
"*",
"a",
":",
"f",
"(",
"*",
"a",
")",
"(",
"*",
"a",
"[",
"-",
"2",
":",
"]",
")",
",",
"f",
")"
] | [
32,
0
] | [
42,
55
] | 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.