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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
get_current_timezone_tag | (parser, token) |
Stores the name of the current time zone in the context.
Usage::
{% get_current_timezone as TIME_ZONE %}
This will fetch the currently active time zone and put its name
into the ``TIME_ZONE`` context variable.
|
Stores the name of the current time zone in the context. | def get_current_timezone_tag(parser, token):
"""
Stores the name of the current time zone in the context.
Usage::
{% get_current_timezone as TIME_ZONE %}
This will fetch the currently active time zone and put its name
into the ``TIME_ZONE`` context variable.
"""
# token.split_cont... | [
"def",
"get_current_timezone_tag",
"(",
"parser",
",",
"token",
")",
":",
"# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments",
"args",
"=",
"token",
".",
"contents",
".",
"split",
"(",
")",
"if",
"len",
"(",
"args",
")",
"!... | [
181,
0
] | [
197,
42
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.__repr__ | (self) |
Short-hand representation because WKB may be very large.
|
Short-hand representation because WKB may be very large.
| def __repr__(self):
"""
Short-hand representation because WKB may be very large.
"""
return '<Raster object at %s>' % hex(addressof(self._ptr)) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"'<Raster object at %s>'",
"%",
"hex",
"(",
"addressof",
"(",
"self",
".",
"_ptr",
")",
")"
] | [
192,
4
] | [
196,
66
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster._flush | (self) |
Flush all data from memory into the source file if it exists.
The data that needs flushing are geotransforms, coordinate systems,
nodata_values and pixel values. This function will be called
automatically wherever it is needed.
|
Flush all data from memory into the source file if it exists.
The data that needs flushing are geotransforms, coordinate systems,
nodata_values and pixel values. This function will be called
automatically wherever it is needed.
| def _flush(self):
"""
Flush all data from memory into the source file if it exists.
The data that needs flushing are geotransforms, coordinate systems,
nodata_values and pixel values. This function will be called
automatically wherever it is needed.
"""
# Raise an... | [
"def",
"_flush",
"(",
"self",
")",
":",
"# Raise an Exception if the value is being changed in read mode.",
"if",
"not",
"self",
".",
"_write",
":",
"raise",
"GDALException",
"(",
"'Raster needs to be opened in write mode to change values.'",
")",
"capi",
".",
"flush_ds",
"... | [
198,
4
] | [
208,
32
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.name | (self) |
Return the name of this raster. Corresponds to filename
for file-based rasters.
|
Return the name of this raster. Corresponds to filename
for file-based rasters.
| def name(self):
"""
Return the name of this raster. Corresponds to filename
for file-based rasters.
"""
return force_str(capi.get_ds_description(self._ptr)) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"force_str",
"(",
"capi",
".",
"get_ds_description",
"(",
"self",
".",
"_ptr",
")",
")"
] | [
230,
4
] | [
235,
60
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.driver | (self) |
Return the GDAL Driver used for this raster.
|
Return the GDAL Driver used for this raster.
| def driver(self):
"""
Return the GDAL Driver used for this raster.
"""
ds_driver = capi.get_ds_driver(self._ptr)
return Driver(ds_driver) | [
"def",
"driver",
"(",
"self",
")",
":",
"ds_driver",
"=",
"capi",
".",
"get_ds_driver",
"(",
"self",
".",
"_ptr",
")",
"return",
"Driver",
"(",
"ds_driver",
")"
] | [
238,
4
] | [
243,
32
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.width | (self) |
Width (X axis) in pixels.
|
Width (X axis) in pixels.
| def width(self):
"""
Width (X axis) in pixels.
"""
return capi.get_ds_xsize(self._ptr) | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_ds_xsize",
"(",
"self",
".",
"_ptr",
")"
] | [
246,
4
] | [
250,
43
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.height | (self) |
Height (Y axis) in pixels.
|
Height (Y axis) in pixels.
| def height(self):
"""
Height (Y axis) in pixels.
"""
return capi.get_ds_ysize(self._ptr) | [
"def",
"height",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_ds_ysize",
"(",
"self",
".",
"_ptr",
")"
] | [
253,
4
] | [
257,
43
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.srs | (self) |
Return the SpatialReference used in this GDALRaster.
|
Return the SpatialReference used in this GDALRaster.
| def srs(self):
"""
Return the SpatialReference used in this GDALRaster.
"""
try:
wkt = capi.get_ds_projection_ref(self._ptr)
if not wkt:
return None
return SpatialReference(wkt, srs_type='wkt')
except SRSException:
r... | [
"def",
"srs",
"(",
"self",
")",
":",
"try",
":",
"wkt",
"=",
"capi",
".",
"get_ds_projection_ref",
"(",
"self",
".",
"_ptr",
")",
"if",
"not",
"wkt",
":",
"return",
"None",
"return",
"SpatialReference",
"(",
"wkt",
",",
"srs_type",
"=",
"'wkt'",
")",
... | [
260,
4
] | [
270,
23
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.srs | (self, value) |
Set the spatial reference used in this GDALRaster. The input can be
a SpatialReference or any parameter accepted by the SpatialReference
constructor.
|
Set the spatial reference used in this GDALRaster. The input can be
a SpatialReference or any parameter accepted by the SpatialReference
constructor.
| def srs(self, value):
"""
Set the spatial reference used in this GDALRaster. The input can be
a SpatialReference or any parameter accepted by the SpatialReference
constructor.
"""
if isinstance(value, SpatialReference):
srs = value
elif isinstance(valu... | [
"def",
"srs",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"SpatialReference",
")",
":",
"srs",
"=",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"str",
")",
")",
":",
"srs",
"=",
"SpatialReference... | [
273,
4
] | [
286,
21
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.srid | (self) |
Shortcut to access the srid of this GDALRaster.
|
Shortcut to access the srid of this GDALRaster.
| def srid(self):
"""
Shortcut to access the srid of this GDALRaster.
"""
return self.srs.srid | [
"def",
"srid",
"(",
"self",
")",
":",
"return",
"self",
".",
"srs",
".",
"srid"
] | [
289,
4
] | [
293,
28
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.srid | (self, value) |
Shortcut to set this GDALRaster's srs from an srid.
|
Shortcut to set this GDALRaster's srs from an srid.
| def srid(self, value):
"""
Shortcut to set this GDALRaster's srs from an srid.
"""
self.srs = value | [
"def",
"srid",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"srs",
"=",
"value"
] | [
296,
4
] | [
300,
24
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.geotransform | (self) |
Return the geotransform of the data source.
Return the default geotransform if it does not exist or has not been
set previously. The default is [0.0, 1.0, 0.0, 0.0, 0.0, -1.0].
|
Return the geotransform of the data source.
Return the default geotransform if it does not exist or has not been
set previously. The default is [0.0, 1.0, 0.0, 0.0, 0.0, -1.0].
| def geotransform(self):
"""
Return the geotransform of the data source.
Return the default geotransform if it does not exist or has not been
set previously. The default is [0.0, 1.0, 0.0, 0.0, 0.0, -1.0].
"""
# Create empty ctypes double array for data
gtf = (c_do... | [
"def",
"geotransform",
"(",
"self",
")",
":",
"# Create empty ctypes double array for data",
"gtf",
"=",
"(",
"c_double",
"*",
"6",
")",
"(",
")",
"capi",
".",
"get_ds_geotransform",
"(",
"self",
".",
"_ptr",
",",
"byref",
"(",
"gtf",
")",
")",
"return",
"... | [
303,
4
] | [
312,
24
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.geotransform | (self, values) | Set the geotransform for the data source. | Set the geotransform for the data source. | def geotransform(self, values):
"Set the geotransform for the data source."
if len(values) != 6 or not all(isinstance(x, (int, float)) for x in values):
raise ValueError('Geotransform must consist of 6 numeric values.')
# Create ctypes double array with input and write data
v... | [
"def",
"geotransform",
"(",
"self",
",",
"values",
")",
":",
"if",
"len",
"(",
"values",
")",
"!=",
"6",
"or",
"not",
"all",
"(",
"isinstance",
"(",
"x",
",",
"(",
"int",
",",
"float",
")",
")",
"for",
"x",
"in",
"values",
")",
":",
"raise",
"V... | [
315,
4
] | [
322,
21
] | python | en | ['en', 'en', 'en'] | True |
GDALRaster.origin | (self) |
Coordinates of the raster origin.
|
Coordinates of the raster origin.
| def origin(self):
"""
Coordinates of the raster origin.
"""
return TransformPoint(self, 'origin') | [
"def",
"origin",
"(",
"self",
")",
":",
"return",
"TransformPoint",
"(",
"self",
",",
"'origin'",
")"
] | [
325,
4
] | [
329,
45
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.scale | (self) |
Pixel scale in units of the raster projection.
|
Pixel scale in units of the raster projection.
| def scale(self):
"""
Pixel scale in units of the raster projection.
"""
return TransformPoint(self, 'scale') | [
"def",
"scale",
"(",
"self",
")",
":",
"return",
"TransformPoint",
"(",
"self",
",",
"'scale'",
")"
] | [
332,
4
] | [
336,
44
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.skew | (self) |
Skew of pixels (rotation parameters).
|
Skew of pixels (rotation parameters).
| def skew(self):
"""
Skew of pixels (rotation parameters).
"""
return TransformPoint(self, 'skew') | [
"def",
"skew",
"(",
"self",
")",
":",
"return",
"TransformPoint",
"(",
"self",
",",
"'skew'",
")"
] | [
339,
4
] | [
343,
43
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.extent | (self) |
Return the extent as a 4-tuple (xmin, ymin, xmax, ymax).
|
Return the extent as a 4-tuple (xmin, ymin, xmax, ymax).
| def extent(self):
"""
Return the extent as a 4-tuple (xmin, ymin, xmax, ymax).
"""
# Calculate boundary values based on scale and size
xval = self.origin.x + self.scale.x * self.width
yval = self.origin.y + self.scale.y * self.height
# Calculate min and max values... | [
"def",
"extent",
"(",
"self",
")",
":",
"# Calculate boundary values based on scale and size",
"xval",
"=",
"self",
".",
"origin",
".",
"x",
"+",
"self",
".",
"scale",
".",
"x",
"*",
"self",
".",
"width",
"yval",
"=",
"self",
".",
"origin",
".",
"y",
"+"... | [
346,
4
] | [
359,
37
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.warp | (self, ds_input, resampling='NearestNeighbour', max_error=0.0) |
Return a warped GDALRaster with the given input characteristics.
The input is expected to be a dictionary containing the parameters
of the target raster. Allowed values are width, height, SRID, origin,
scale, skew, datatype, driver, and name (filename).
By default, the warp fu... |
Return a warped GDALRaster with the given input characteristics. | def warp(self, ds_input, resampling='NearestNeighbour', max_error=0.0):
"""
Return a warped GDALRaster with the given input characteristics.
The input is expected to be a dictionary containing the parameters
of the target raster. Allowed values are width, height, SRID, origin,
s... | [
"def",
"warp",
"(",
"self",
",",
"ds_input",
",",
"resampling",
"=",
"'NearestNeighbour'",
",",
"max_error",
"=",
"0.0",
")",
":",
"# Get the parameters defining the geotransform, srid, and size of the raster",
"ds_input",
".",
"setdefault",
"(",
"'width'",
",",
"self",... | [
365,
4
] | [
418,
21
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.transform | (self, srid, driver=None, name=None, resampling='NearestNeighbour',
max_error=0.0) |
Return a copy of this raster reprojected into the given SRID.
|
Return a copy of this raster reprojected into the given SRID.
| def transform(self, srid, driver=None, name=None, resampling='NearestNeighbour',
max_error=0.0):
"""
Return a copy of this raster reprojected into the given SRID.
"""
# Convert the resampling algorithm name into an algorithm id
algorithm = GDAL_RESAMPLE_ALGORITH... | [
"def",
"transform",
"(",
"self",
",",
"srid",
",",
"driver",
"=",
"None",
",",
"name",
"=",
"None",
",",
"resampling",
"=",
"'NearestNeighbour'",
",",
"max_error",
"=",
"0.0",
")",
":",
"# Convert the resampling algorithm name into an algorithm id",
"algorithm",
"... | [
420,
4
] | [
456,
74
] | python | en | ['en', 'error', 'th'] | False |
GDALRaster.info | (self) |
Return information about this raster in a string format equivalent
to the output of the gdalinfo command line utility.
|
Return information about this raster in a string format equivalent
to the output of the gdalinfo command line utility.
| def info(self):
"""
Return information about this raster in a string format equivalent
to the output of the gdalinfo command line utility.
"""
if not capi.get_ds_info:
raise ValueError('GDAL ≥ 2.1 is required for using the info property.')
return capi.get_ds_i... | [
"def",
"info",
"(",
"self",
")",
":",
"if",
"not",
"capi",
".",
"get_ds_info",
":",
"raise",
"ValueError",
"(",
"'GDAL ≥ 2.1 is required for using the info property.')",
"",
"return",
"capi",
".",
"get_ds_info",
"(",
"self",
".",
"ptr",
",",
"None",
")",
".",
... | [
459,
4
] | [
466,
56
] | python | en | ['en', 'error', 'th'] | False |
GeoSQLCompiler.get_columns | (self, with_aliases=False) |
Return the list of columns to use in the select statement. If no
columns have been specified, returns all columns relating to fields in
the model.
If 'with_aliases' is true, any column names that are duplicated
(without the table names) are given unique aliases. This is needed ... |
Return the list of columns to use in the select statement. If no
columns have been specified, returns all columns relating to fields in
the model. | def get_columns(self, with_aliases=False):
"""
Return the list of columns to use in the select statement. If no
columns have been specified, returns all columns relating to fields in
the model.
If 'with_aliases' is true, any column names that are duplicated
(without the ... | [
"def",
"get_columns",
"(",
"self",
",",
"with_aliases",
"=",
"False",
")",
":",
"qn",
"=",
"self",
"qn2",
"=",
"self",
".",
"connection",
".",
"ops",
".",
"quote_name",
"result",
"=",
"[",
"'(%s) AS %s'",
"%",
"(",
"self",
".",
"get_extra_select_format",
... | [
9,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
GeoSQLCompiler.get_default_columns | (self, with_aliases=False, col_aliases=None,
start_alias=None, opts=None, as_pairs=False, from_parent=None) |
Computes the default columns for selecting every field in the base
model. Will sometimes be called to pull in related models (e.g. via
select_related), in which case "opts" and "start_alias" will be given
to provide a starting point for the traversal.
Returns a list of strings,... |
Computes the default columns for selecting every field in the base
model. Will sometimes be called to pull in related models (e.g. via
select_related), in which case "opts" and "start_alias" will be given
to provide a starting point for the traversal. | def get_default_columns(self, with_aliases=False, col_aliases=None,
start_alias=None, opts=None, as_pairs=False, from_parent=None):
"""
Computes the default columns for selecting every field in the base
model. Will sometimes be called to pull in related models (e.g. via
selec... | [
"def",
"get_default_columns",
"(",
"self",
",",
"with_aliases",
"=",
"False",
",",
"col_aliases",
"=",
"None",
",",
"start_alias",
"=",
"None",
",",
"opts",
"=",
"None",
",",
"as_pairs",
"=",
"False",
",",
"from_parent",
"=",
"None",
")",
":",
"result",
... | [
96,
4
] | [
147,
30
] | python | en | ['en', 'error', 'th'] | False |
GeoSQLCompiler.get_field_select | (self, field, alias=None, column=None) |
Returns the SELECT SQL string for the given field. Figures out
if any custom selection SQL is needed for the column The `alias`
keyword may be used to manually specify the database table where
the column exists, if not in the model associated with this
`GeoQuery`. Similarly, ... |
Returns the SELECT SQL string for the given field. Figures out
if any custom selection SQL is needed for the column The `alias`
keyword may be used to manually specify the database table where
the column exists, if not in the model associated with this
`GeoQuery`. Similarly, ... | def get_field_select(self, field, alias=None, column=None):
"""
Returns the SELECT SQL string for the given field. Figures out
if any custom selection SQL is needed for the column The `alias`
keyword may be used to manually specify the database table where
the column exists, if... | [
"def",
"get_field_select",
"(",
"self",
",",
"field",
",",
"alias",
"=",
"None",
",",
"column",
"=",
"None",
")",
":",
"sel_fmt",
"=",
"self",
".",
"get_select_format",
"(",
"field",
")",
"if",
"field",
"in",
"self",
".",
"query",
".",
"custom_select",
... | [
165,
4
] | [
179,
24
] | python | en | ['en', 'error', 'th'] | False |
GeoSQLCompiler.get_select_format | (self, fld) |
Returns the selection format string, depending on the requirements
of the spatial backend. For example, Oracle and MySQL require custom
selection formats in order to retrieve geometries in OGC WKT. For all
other fields a simple '%s' format string is returned.
|
Returns the selection format string, depending on the requirements
of the spatial backend. For example, Oracle and MySQL require custom
selection formats in order to retrieve geometries in OGC WKT. For all
other fields a simple '%s' format string is returned.
| def get_select_format(self, fld):
"""
Returns the selection format string, depending on the requirements
of the spatial backend. For example, Oracle and MySQL require custom
selection formats in order to retrieve geometries in OGC WKT. For all
other fields a simple '%s' format s... | [
"def",
"get_select_format",
"(",
"self",
",",
"fld",
")",
":",
"if",
"self",
".",
"connection",
".",
"ops",
".",
"select",
"and",
"hasattr",
"(",
"fld",
",",
"'geom_type'",
")",
":",
"# This allows operations to be done on fields in the SELECT,",
"# overriding their... | [
181,
4
] | [
205,
22
] | python | en | ['en', 'error', 'th'] | False |
GeoSQLCompiler._field_column | (self, field, table_alias=None, column=None) |
Helper function that returns the database column for the given field.
The table and column are returned (quoted) in the proper format, e.g.,
`"geoapp_city"."point"`. If `table_alias` is not specified, the
database table associated with the model of this `GeoQuery` will be
used.... |
Helper function that returns the database column for the given field.
The table and column are returned (quoted) in the proper format, e.g.,
`"geoapp_city"."point"`. If `table_alias` is not specified, the
database table associated with the model of this `GeoQuery` will be
used.... | def _field_column(self, field, table_alias=None, column=None):
"""
Helper function that returns the database column for the given field.
The table and column are returned (quoted) in the proper format, e.g.,
`"geoapp_city"."point"`. If `table_alias` is not specified, the
databas... | [
"def",
"_field_column",
"(",
"self",
",",
"field",
",",
"table_alias",
"=",
"None",
",",
"column",
"=",
"None",
")",
":",
"if",
"table_alias",
"is",
"None",
":",
"table_alias",
"=",
"self",
".",
"query",
".",
"get_meta",
"(",
")",
".",
"db_table",
"ret... | [
208,
4
] | [
220,
81
] | python | en | ['en', 'error', 'th'] | False |
random_feed_dict | (rng, placeholders) |
Returns random data to be used with `feed_dict`.
:param rng: A numpy.random.RandomState instance
:param placeholders: List of tensorflow placeholders
:return: A dict mapping placeholders to random numpy values
|
Returns random data to be used with `feed_dict`.
:param rng: A numpy.random.RandomState instance
:param placeholders: List of tensorflow placeholders
:return: A dict mapping placeholders to random numpy values
| def random_feed_dict(rng, placeholders):
"""
Returns random data to be used with `feed_dict`.
:param rng: A numpy.random.RandomState instance
:param placeholders: List of tensorflow placeholders
:return: A dict mapping placeholders to random numpy values
"""
output = {}
for placeholder... | [
"def",
"random_feed_dict",
"(",
"rng",
",",
"placeholders",
")",
":",
"output",
"=",
"{",
"}",
"for",
"placeholder",
"in",
"placeholders",
":",
"if",
"placeholder",
".",
"dtype",
"!=",
"\"float32\"",
":",
"raise",
"NotImplementedError",
"(",
")",
"value",
"=... | [
15,
0
] | [
31,
17
] | python | en | ['en', 'error', 'th'] | False |
vary_on_headers | (*headers) |
A view decorator that adds the specified headers to the Vary header of the
response. Usage:
@vary_on_headers('Cookie', 'Accept-language')
def index(request):
...
Note that the header names are not case-sensitive.
|
A view decorator that adds the specified headers to the Vary header of the
response. Usage: | def vary_on_headers(*headers):
"""
A view decorator that adds the specified headers to the Vary header of the
response. Usage:
@vary_on_headers('Cookie', 'Accept-language')
def index(request):
...
Note that the header names are not case-sensitive.
"""
def decorator(fun... | [
"def",
"vary_on_headers",
"(",
"*",
"headers",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
",",
"assigned",
"=",
"available_attrs",
"(",
"func",
")",
")",
"def",
"inner_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwar... | [
5,
0
] | [
23,
20
] | python | en | ['en', 'error', 'th'] | False |
vary_on_cookie | (func) |
A view decorator that adds "Cookie" to the Vary header of a response. This
indicates that a page's contents depends on cookies. Usage:
@vary_on_cookie
def index(request):
...
|
A view decorator that adds "Cookie" to the Vary header of a response. This
indicates that a page's contents depends on cookies. Usage: | def vary_on_cookie(func):
"""
A view decorator that adds "Cookie" to the Vary header of a response. This
indicates that a page's contents depends on cookies. Usage:
@vary_on_cookie
def index(request):
...
"""
@wraps(func, assigned=available_attrs(func))
def inner_fun... | [
"def",
"vary_on_cookie",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
",",
"assigned",
"=",
"available_attrs",
"(",
"func",
")",
")",
"def",
"inner_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"func",
"(",
"*",
... | [
26,
0
] | [
40,
21
] | python | en | ['en', 'error', 'th'] | False |
parse_dimension_string | (dim) |
Parse a dimension string ("WxH") into (width, height).
:param dim: Dimension string
:type dim: str
:return: Dimension tuple
:rtype: tuple[int, int]
|
Parse a dimension string ("WxH") into (width, height). | def parse_dimension_string(dim):
"""
Parse a dimension string ("WxH") into (width, height).
:param dim: Dimension string
:type dim: str
:return: Dimension tuple
:rtype: tuple[int, int]
"""
a = dim.split('x')
if len(a) != 2:
raise ValueError('"dim" must be <width>x<height>')
... | [
"def",
"parse_dimension_string",
"(",
"dim",
")",
":",
"a",
"=",
"dim",
".",
"split",
"(",
"'x'",
")",
"if",
"len",
"(",
"a",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'\"dim\" must be <width>x<height>'",
")",
"width",
",",
"height",
"=",
"a",
... | [
10,
0
] | [
31,
26
] | python | en | ['en', 'error', 'th'] | False |
ModelTests.test_related_gte_lookup | (self) |
Regression test for #10153: foreign key __gte lookups.
|
Regression test for #10153: foreign key __gte lookups.
| def test_related_gte_lookup(self):
"""
Regression test for #10153: foreign key __gte lookups.
"""
Worker.objects.filter(department__gte=0) | [
"def",
"test_related_gte_lookup",
"(",
"self",
")",
":",
"Worker",
".",
"objects",
".",
"filter",
"(",
"department__gte",
"=",
"0",
")"
] | [
21,
4
] | [
25,
48
] | python | en | ['en', 'error', 'th'] | False |
ModelTests.test_related_lte_lookup | (self) |
Regression test for #10153: foreign key __lte lookups.
|
Regression test for #10153: foreign key __lte lookups.
| def test_related_lte_lookup(self):
"""
Regression test for #10153: foreign key __lte lookups.
"""
Worker.objects.filter(department__lte=0) | [
"def",
"test_related_lte_lookup",
"(",
"self",
")",
":",
"Worker",
".",
"objects",
".",
"filter",
"(",
"department__lte",
"=",
"0",
")"
] | [
27,
4
] | [
31,
48
] | python | en | ['en', 'error', 'th'] | False |
ModelTests.test_sql_insert_compiler_return_id_attribute | (self) |
Regression test for #14019: SQLInsertCompiler.as_sql() failure
|
Regression test for #14019: SQLInsertCompiler.as_sql() failure
| def test_sql_insert_compiler_return_id_attribute(self):
"""
Regression test for #14019: SQLInsertCompiler.as_sql() failure
"""
db = router.db_for_write(Party)
query = InsertQuery(Party)
query.insert_values([Party._meta.fields[0]], [], raw=False)
# this line will r... | [
"def",
"test_sql_insert_compiler_return_id_attribute",
"(",
"self",
")",
":",
"db",
"=",
"router",
".",
"db_for_write",
"(",
"Party",
")",
"query",
"=",
"InsertQuery",
"(",
"Party",
")",
"query",
".",
"insert_values",
"(",
"[",
"Party",
".",
"_meta",
".",
"f... | [
33,
4
] | [
41,
45
] | python | en | ['en', 'error', 'th'] | False |
ModelTests.test_chained_fks | (self) |
Regression for #18432: Chained foreign keys with to_field produce incorrect query
|
Regression for #18432: Chained foreign keys with to_field produce incorrect query
| def test_chained_fks(self):
"""
Regression for #18432: Chained foreign keys with to_field produce incorrect query
"""
m1 = Model1.objects.create(pkey=1000)
m2 = Model2.objects.create(model1=m1)
m3 = Model3.objects.create(model2=m2)
# this is the actual test for ... | [
"def",
"test_chained_fks",
"(",
"self",
")",
":",
"m1",
"=",
"Model1",
".",
"objects",
".",
"create",
"(",
"pkey",
"=",
"1000",
")",
"m2",
"=",
"Model2",
".",
"objects",
".",
"create",
"(",
"model1",
"=",
"m1",
")",
"m3",
"=",
"Model3",
".",
"objec... | [
214,
4
] | [
225,
17
] | python | en | ['en', 'error', 'th'] | False |
EvaluateMethodTest.test_model_with_evaluate_method | (self) |
Ensures that you can filter by objects that have an 'evaluate' attr
|
Ensures that you can filter by objects that have an 'evaluate' attr
| def test_model_with_evaluate_method(self):
"""
Ensures that you can filter by objects that have an 'evaluate' attr
"""
dept = Department.objects.create(pk=1, name='abc')
dept.evaluate = 'abc'
Worker.objects.filter(department=dept) | [
"def",
"test_model_with_evaluate_method",
"(",
"self",
")",
":",
"dept",
"=",
"Department",
".",
"objects",
".",
"create",
"(",
"pk",
"=",
"1",
",",
"name",
"=",
"'abc'",
")",
"dept",
".",
"evaluate",
"=",
"'abc'",
"Worker",
".",
"objects",
".",
"filter"... | [
240,
4
] | [
246,
46
] | python | en | ['en', 'error', 'th'] | False |
preprocess_batch | (images_batch, preproc_func=None) |
Creates a preprocessing graph for a batch given a function that processes
a single image.
:param images_batch: A tensor for an image batch.
:param preproc_func: (optional function) A function that takes in a
tensor and returns a preprocessed input.
|
Creates a preprocessing graph for a batch given a function that processes
a single image. | def preprocess_batch(images_batch, preproc_func=None):
"""
Creates a preprocessing graph for a batch given a function that processes
a single image.
:param images_batch: A tensor for an image batch.
:param preproc_func: (optional function) A function that takes in a
tensor and returns a pre... | [
"def",
"preprocess_batch",
"(",
"images_batch",
",",
"preproc_func",
"=",
"None",
")",
":",
"if",
"preproc_func",
"is",
"None",
":",
"return",
"images_batch",
"with",
"tf",
".",
"variable_scope",
"(",
"\"preprocess\"",
")",
":",
"images_list",
"=",
"tf",
".",
... | [
4,
0
] | [
24,
24
] | python | en | ['en', 'error', 'th'] | False |
ping_google | (sitemap_url=None, ping_url=PING_URL, sitemap_uses_https=True) |
Alert Google that the sitemap for the current site has been updated.
If sitemap_url is provided, it should be an absolute path to the sitemap
for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this
function will attempt to deduce it by using urls.reverse().
|
Alert Google that the sitemap for the current site has been updated.
If sitemap_url is provided, it should be an absolute path to the sitemap
for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this
function will attempt to deduce it by using urls.reverse().
| def ping_google(sitemap_url=None, ping_url=PING_URL, sitemap_uses_https=True):
"""
Alert Google that the sitemap for the current site has been updated.
If sitemap_url is provided, it should be an absolute path to the sitemap
for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this
... | [
"def",
"ping_google",
"(",
"sitemap_url",
"=",
"None",
",",
"ping_url",
"=",
"PING_URL",
",",
"sitemap_uses_https",
"=",
"True",
")",
":",
"sitemap_full_url",
"=",
"_get_sitemap_full_url",
"(",
"sitemap_url",
",",
"sitemap_uses_https",
")",
"params",
"=",
"urlenco... | [
17,
0
] | [
26,
41
] | python | en | ['en', 'error', 'th'] | False |
default_never_cache_responses | (view_func: ViewFuncT) | Patched version of the standard Django never_cache_responses
decorator that adds headers to a response so that it will never be
cached, unless the view code has already set a Cache-Control
header.
| Patched version of the standard Django never_cache_responses
decorator that adds headers to a response so that it will never be
cached, unless the view code has already set a Cache-Control
header.
| def default_never_cache_responses(view_func: ViewFuncT) -> ViewFuncT:
"""Patched version of the standard Django never_cache_responses
decorator that adds headers to a response so that it will never be
cached, unless the view code has already set a Cache-Control
header.
"""
@wraps(view_func)
... | [
"def",
"default_never_cache_responses",
"(",
"view_func",
":",
"ViewFuncT",
")",
"->",
"ViewFuncT",
":",
"@",
"wraps",
"(",
"view_func",
")",
"def",
"_wrapped_view_func",
"(",
"request",
":",
"HttpRequest",
",",
"*",
"args",
":",
"object",
",",
"*",
"*",
"kw... | [
23,
0
] | [
39,
46
] | python | en | ['en', 'en', 'en'] | True |
rest_dispatch | (request: HttpRequest, **kwargs: Any) | Dispatch to a REST API endpoint.
Unauthenticated endpoints should not use this, as authentication is verified
in the following ways:
* for paths beginning with /api, HTTP basic auth
* for paths beginning with /json (used by the web client), the session token
This calls the function named i... | Dispatch to a REST API endpoint. | def rest_dispatch(request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Dispatch to a REST API endpoint.
Unauthenticated endpoints should not use this, as authentication is verified
in the following ways:
* for paths beginning with /api, HTTP basic auth
* for paths beginning with /json (... | [
"def",
"rest_dispatch",
"(",
"request",
":",
"HttpRequest",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"HttpResponse",
":",
"supported_methods",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"request",
",",
"\"save... | [
44,
0
] | [
167,
66
] | python | en | ['en', 'en', 'en'] | True |
Command.load_label | (self, fixture_label) |
Loads fixtures files for a given label.
|
Loads fixtures files for a given label.
| def load_label(self, fixture_label):
"""
Loads fixtures files for a given label.
"""
for fixture_file, fixture_dir, fixture_name in self.find_fixtures(fixture_label):
_, ser_fmt, cmp_fmt = self.parse_name(os.path.basename(fixture_file))
open_method, mode = self.co... | [
"def",
"load_label",
"(",
"self",
",",
"fixture_label",
")",
":",
"for",
"fixture_file",
",",
"fixture_dir",
",",
"fixture_name",
"in",
"self",
".",
"find_fixtures",
"(",
"fixture_label",
")",
":",
"_",
",",
"ser_fmt",
",",
"cmp_fmt",
"=",
"self",
".",
"pa... | [
118,
4
] | [
168,
17
] | python | en | ['en', 'error', 'th'] | False |
Command.find_fixtures | (self, fixture_label) |
Finds fixture files for a given label.
|
Finds fixture files for a given label.
| def find_fixtures(self, fixture_label):
"""
Finds fixture files for a given label.
"""
fixture_name, ser_fmt, cmp_fmt = self.parse_name(fixture_label)
databases = [self.using, None]
cmp_fmts = list(self.compression_formats.keys()) if cmp_fmt is None else [cmp_fmt]
... | [
"def",
"find_fixtures",
"(",
"self",
",",
"fixture_label",
")",
":",
"fixture_name",
",",
"ser_fmt",
",",
"cmp_fmt",
"=",
"self",
".",
"parse_name",
"(",
"fixture_label",
")",
"databases",
"=",
"[",
"self",
".",
"using",
",",
"None",
"]",
"cmp_fmts",
"=",
... | [
171,
4
] | [
228,
28
] | python | en | ['en', 'error', 'th'] | False |
Command.fixture_dirs | (self) |
Return a list of fixture directories.
The list contains the 'fixtures' subdirectory of each installed
application, if it exists, the directories in FIXTURE_DIRS, and the
current directory.
|
Return a list of fixture directories. | def fixture_dirs(self):
"""
Return a list of fixture directories.
The list contains the 'fixtures' subdirectory of each installed
application, if it exists, the directories in FIXTURE_DIRS, and the
current directory.
"""
dirs = []
for app_config in apps.g... | [
"def",
"fixture_dirs",
"(",
"self",
")",
":",
"dirs",
"=",
"[",
"]",
"for",
"app_config",
"in",
"apps",
".",
"get_app_configs",
"(",
")",
":",
"if",
"self",
".",
"app_label",
"and",
"app_config",
".",
"label",
"!=",
"self",
".",
"app_label",
":",
"cont... | [
231,
4
] | [
249,
19
] | python | en | ['en', 'error', 'th'] | False |
Command.parse_name | (self, fixture_name) |
Splits fixture name in name, serialization format, compression format.
|
Splits fixture name in name, serialization format, compression format.
| def parse_name(self, fixture_name):
"""
Splits fixture name in name, serialization format, compression format.
"""
parts = fixture_name.rsplit('.', 2)
if len(parts) > 1 and parts[-1] in self.compression_formats:
cmp_fmt = parts[-1]
parts = parts[:-1]
... | [
"def",
"parse_name",
"(",
"self",
",",
"fixture_name",
")",
":",
"parts",
"=",
"fixture_name",
".",
"rsplit",
"(",
"'.'",
",",
"2",
")",
"if",
"len",
"(",
"parts",
")",
">",
"1",
"and",
"parts",
"[",
"-",
"1",
"]",
"in",
"self",
".",
"compression_f... | [
251,
4
] | [
276,
37
] | python | en | ['en', 'error', 'th'] | False |
CloudWatch.configure_alarms | (self) | Configure Cloudwatch Alarms for each instance.
The algorithm needs to manage missing alarm as well updating existing alarms
| Configure Cloudwatch Alarms for each instance. | def configure_alarms(self):
""" Configure Cloudwatch Alarms for each instance.
The algorithm needs to manage missing alarm as well updating existing alarms
"""
now = self.context["now"]
client = self.context["cloudwatch.client"]
valid_alarms = []
nb_of_up... | [
"def",
"configure_alarms",
"(",
"self",
")",
":",
"now",
"=",
"self",
".",
"context",
"[",
"\"now\"",
"]",
"client",
"=",
"self",
".",
"context",
"[",
"\"cloudwatch.client\"",
"]",
"valid_alarms",
"=",
"[",
"]",
"nb_of_updated_alarms",
"=",
"0",
"max_update_... | [
396,
4
] | [
500,
69
] | python | en | ['en', 'en', 'en'] | True |
rounded | (func) |
Decorator for conditionally rounding function result
By default the result is rounded to two decimal places, but the rounding
can be turned off by giving parameter "rounded=False" when calling the
function.
|
Decorator for conditionally rounding function result | def rounded(func):
"""
Decorator for conditionally rounding function result
By default the result is rounded to two decimal places, but the rounding
can be turned off by giving parameter "rounded=False" when calling the
function.
"""
@wraps(func)
def wrapped(*args, **kwargs):
ro... | [
"def",
"rounded",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"rounded",
"=",
"kwargs",
".",
"pop",
"(",
"'rounded'",
",",
"True",
")",
"value",
"=",
"func",
"(",
... | [
15,
0
] | [
30,
18
] | python | en | ['en', 'error', 'th'] | False |
linux_distribution | (full_distribution_name=True) |
Return information about the current OS distribution as a tuple
``(id_name, version, codename)`` with items as follows:
* ``id_name``: If *full_distribution_name* is false, the result of
:func:`distro.id`. Otherwise, the result of :func:`distro.name`.
* ``version``: The result of :func:`distr... |
Return information about the current OS distribution as a tuple
``(id_name, version, codename)`` with items as follows: | def linux_distribution(full_distribution_name=True):
"""
Return information about the current OS distribution as a tuple
``(id_name, version, codename)`` with items as follows:
* ``id_name``: If *full_distribution_name* is false, the result of
:func:`distro.id`. Otherwise, the result of :func:`d... | [
"def",
"linux_distribution",
"(",
"full_distribution_name",
"=",
"True",
")",
":",
"return",
"_distro",
".",
"linux_distribution",
"(",
"full_distribution_name",
")"
] | [
99,
0
] | [
124,
61
] | python | en | ['en', 'error', 'th'] | False |
id | () |
Return the distro ID of the current distribution, as a
machine-readable string.
For a number of OS distributions, the returned distro ID value is
*reliable*, in the sense that it is documented and that it does not change
across releases of the distribution.
This package maintains the followin... |
Return the distro ID of the current distribution, as a
machine-readable string. | def id():
"""
Return the distro ID of the current distribution, as a
machine-readable string.
For a number of OS distributions, the returned distro ID value is
*reliable*, in the sense that it is documented and that it does not change
across releases of the distribution.
This package maint... | [
"def",
"id",
"(",
")",
":",
"return",
"_distro",
".",
"id",
"(",
")"
] | [
127,
0
] | [
203,
23
] | python | en | ['en', 'error', 'th'] | False |
name | (pretty=False) |
Return the name of the current OS distribution, as a human-readable
string.
If *pretty* is false, the name is returned without version or codename.
(e.g. "CentOS Linux")
If *pretty* is true, the version and codename are appended.
(e.g. "CentOS Linux 7.1.1503 (Core)")
**Lookup hierarchy:*... |
Return the name of the current OS distribution, as a human-readable
string. | def name(pretty=False):
"""
Return the name of the current OS distribution, as a human-readable
string.
If *pretty* is false, the name is returned without version or codename.
(e.g. "CentOS Linux")
If *pretty* is true, the version and codename are appended.
(e.g. "CentOS Linux 7.1.1503 (Co... | [
"def",
"name",
"(",
"pretty",
"=",
"False",
")",
":",
"return",
"_distro",
".",
"name",
"(",
"pretty",
")"
] | [
206,
0
] | [
242,
31
] | python | en | ['en', 'error', 'th'] | False |
version | (pretty=False, best=False) |
Return the version of the current OS distribution, as a human-readable
string.
If *pretty* is false, the version is returned without codename (e.g.
"7.0").
If *pretty* is true, the codename in parenthesis is appended, if the
codename is non-empty (e.g. "7.0 (Maipo)").
Some distributions ... |
Return the version of the current OS distribution, as a human-readable
string. | def version(pretty=False, best=False):
"""
Return the version of the current OS distribution, as a human-readable
string.
If *pretty* is false, the version is returned without codename (e.g.
"7.0").
If *pretty* is true, the codename in parenthesis is appended, if the
codename is non-empty ... | [
"def",
"version",
"(",
"pretty",
"=",
"False",
",",
"best",
"=",
"False",
")",
":",
"return",
"_distro",
".",
"version",
"(",
"pretty",
",",
"best",
")"
] | [
245,
0
] | [
286,
40
] | python | en | ['en', 'error', 'th'] | False |
version_parts | (best=False) |
Return the version of the current OS distribution as a tuple
``(major, minor, build_number)`` with items as follows:
* ``major``: The result of :func:`distro.major_version`.
* ``minor``: The result of :func:`distro.minor_version`.
* ``build_number``: The result of :func:`distro.build_number`.... |
Return the version of the current OS distribution as a tuple
``(major, minor, build_number)`` with items as follows: | def version_parts(best=False):
"""
Return the version of the current OS distribution as a tuple
``(major, minor, build_number)`` with items as follows:
* ``major``: The result of :func:`distro.major_version`.
* ``minor``: The result of :func:`distro.minor_version`.
* ``build_number``: The ... | [
"def",
"version_parts",
"(",
"best",
"=",
"False",
")",
":",
"return",
"_distro",
".",
"version_parts",
"(",
"best",
")"
] | [
289,
0
] | [
303,
38
] | python | en | ['en', 'error', 'th'] | False |
major_version | (best=False) |
Return the major version of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The major version is the first
part of the dot-separated version string.
For a description of the *best* parameter, see the :func:`distro.version`
method.
|
Return the major version of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The major version is the first
part of the dot-separated version string. | def major_version(best=False):
"""
Return the major version of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The major version is the first
part of the dot-separated version string.
For a description of the *best* parameter, see the :func:`distr... | [
"def",
"major_version",
"(",
"best",
"=",
"False",
")",
":",
"return",
"_distro",
".",
"major_version",
"(",
"best",
")"
] | [
306,
0
] | [
316,
38
] | python | en | ['en', 'error', 'th'] | False |
minor_version | (best=False) |
Return the minor version of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The minor version is the second
part of the dot-separated version string.
For a description of the *best* parameter, see the :func:`distro.version`
method.
|
Return the minor version of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The minor version is the second
part of the dot-separated version string. | def minor_version(best=False):
"""
Return the minor version of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The minor version is the second
part of the dot-separated version string.
For a description of the *best* parameter, see the :func:`dist... | [
"def",
"minor_version",
"(",
"best",
"=",
"False",
")",
":",
"return",
"_distro",
".",
"minor_version",
"(",
"best",
")"
] | [
319,
0
] | [
329,
38
] | python | en | ['en', 'error', 'th'] | False |
build_number | (best=False) |
Return the build number of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The build number is the third part
of the dot-separated version string.
For a description of the *best* parameter, see the :func:`distro.version`
method.
|
Return the build number of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The build number is the third part
of the dot-separated version string. | def build_number(best=False):
"""
Return the build number of the current OS distribution, as a string,
if provided.
Otherwise, the empty string is returned. The build number is the third part
of the dot-separated version string.
For a description of the *best* parameter, see the :func:`distro.v... | [
"def",
"build_number",
"(",
"best",
"=",
"False",
")",
":",
"return",
"_distro",
".",
"build_number",
"(",
"best",
")"
] | [
332,
0
] | [
342,
37
] | python | en | ['en', 'error', 'th'] | False |
like | () |
Return a space-separated list of distro IDs of distributions that are
closely related to the current OS distribution in regards to packaging
and programming interfaces, for example distributions the current
distribution is a derivative from.
**Lookup hierarchy:**
This information item is only... |
Return a space-separated list of distro IDs of distributions that are
closely related to the current OS distribution in regards to packaging
and programming interfaces, for example distributions the current
distribution is a derivative from. | def like():
"""
Return a space-separated list of distro IDs of distributions that are
closely related to the current OS distribution in regards to packaging
and programming interfaces, for example distributions the current
distribution is a derivative from.
**Lookup hierarchy:**
This infor... | [
"def",
"like",
"(",
")",
":",
"return",
"_distro",
".",
"like",
"(",
")"
] | [
345,
0
] | [
359,
25
] | python | en | ['en', 'error', 'th'] | False |
codename | () |
Return the codename for the release of the current OS distribution,
as a string.
If the distribution does not have a codename, an empty string is returned.
Note that the returned codename is not always really a codename. For
example, openSUSE returns "x86_64". This function does not handle such
... |
Return the codename for the release of the current OS distribution,
as a string. | def codename():
"""
Return the codename for the release of the current OS distribution,
as a string.
If the distribution does not have a codename, an empty string is returned.
Note that the returned codename is not always really a codename. For
example, openSUSE returns "x86_64". This function... | [
"def",
"codename",
"(",
")",
":",
"return",
"_distro",
".",
"codename",
"(",
")"
] | [
362,
0
] | [
383,
29
] | python | en | ['en', 'error', 'th'] | False |
info | (pretty=False, best=False) |
Return certain machine-readable information items about the current OS
distribution in a dictionary, as shown in the following example:
.. sourcecode:: python
{
'id': 'rhel',
'version': '7.0',
'version_parts': {
'major': '7',
'mi... |
Return certain machine-readable information items about the current OS
distribution in a dictionary, as shown in the following example: | def info(pretty=False, best=False):
"""
Return certain machine-readable information items about the current OS
distribution in a dictionary, as shown in the following example:
.. sourcecode:: python
{
'id': 'rhel',
'version': '7.0',
'version_parts': {
... | [
"def",
"info",
"(",
"pretty",
"=",
"False",
",",
"best",
"=",
"False",
")",
":",
"return",
"_distro",
".",
"info",
"(",
"pretty",
",",
"best",
")"
] | [
386,
0
] | [
427,
37
] | python | en | ['en', 'error', 'th'] | False |
os_release_info | () |
Return a dictionary containing key-value pairs for the information items
from the os-release file data source of the current OS distribution.
See `os-release file`_ for details about these information items.
|
Return a dictionary containing key-value pairs for the information items
from the os-release file data source of the current OS distribution. | def os_release_info():
"""
Return a dictionary containing key-value pairs for the information items
from the os-release file data source of the current OS distribution.
See `os-release file`_ for details about these information items.
"""
return _distro.os_release_info() | [
"def",
"os_release_info",
"(",
")",
":",
"return",
"_distro",
".",
"os_release_info",
"(",
")"
] | [
430,
0
] | [
437,
36
] | python | en | ['en', 'error', 'th'] | False |
lsb_release_info | () |
Return a dictionary containing key-value pairs for the information items
from the lsb_release command data source of the current OS distribution.
See `lsb_release command output`_ for details about these information
items.
|
Return a dictionary containing key-value pairs for the information items
from the lsb_release command data source of the current OS distribution. | def lsb_release_info():
"""
Return a dictionary containing key-value pairs for the information items
from the lsb_release command data source of the current OS distribution.
See `lsb_release command output`_ for details about these information
items.
"""
return _distro.lsb_release_info() | [
"def",
"lsb_release_info",
"(",
")",
":",
"return",
"_distro",
".",
"lsb_release_info",
"(",
")"
] | [
440,
0
] | [
448,
37
] | python | en | ['en', 'error', 'th'] | False |
distro_release_info | () |
Return a dictionary containing key-value pairs for the information items
from the distro release file data source of the current OS distribution.
See `distro release file`_ for details about these information items.
|
Return a dictionary containing key-value pairs for the information items
from the distro release file data source of the current OS distribution. | def distro_release_info():
"""
Return a dictionary containing key-value pairs for the information items
from the distro release file data source of the current OS distribution.
See `distro release file`_ for details about these information items.
"""
return _distro.distro_release_info() | [
"def",
"distro_release_info",
"(",
")",
":",
"return",
"_distro",
".",
"distro_release_info",
"(",
")"
] | [
451,
0
] | [
458,
40
] | python | en | ['en', 'error', 'th'] | False |
uname_info | () |
Return a dictionary containing key-value pairs for the information items
from the distro release file data source of the current OS distribution.
|
Return a dictionary containing key-value pairs for the information items
from the distro release file data source of the current OS distribution.
| def uname_info():
"""
Return a dictionary containing key-value pairs for the information items
from the distro release file data source of the current OS distribution.
"""
return _distro.uname_info() | [
"def",
"uname_info",
"(",
")",
":",
"return",
"_distro",
".",
"uname_info",
"(",
")"
] | [
461,
0
] | [
466,
31
] | python | en | ['en', 'error', 'th'] | False |
os_release_attr | (attribute) |
Return a single named information item from the os-release file data source
of the current OS distribution.
Parameters:
* ``attribute`` (string): Key of the information item.
Returns:
* (string): Value of the information item, if the item exists.
The empty string, if the item does not... |
Return a single named information item from the os-release file data source
of the current OS distribution. | def os_release_attr(attribute):
"""
Return a single named information item from the os-release file data source
of the current OS distribution.
Parameters:
* ``attribute`` (string): Key of the information item.
Returns:
* (string): Value of the information item, if the item exists.
... | [
"def",
"os_release_attr",
"(",
"attribute",
")",
":",
"return",
"_distro",
".",
"os_release_attr",
"(",
"attribute",
")"
] | [
469,
0
] | [
485,
45
] | python | en | ['en', 'error', 'th'] | False |
lsb_release_attr | (attribute) |
Return a single named information item from the lsb_release command output
data source of the current OS distribution.
Parameters:
* ``attribute`` (string): Key of the information item.
Returns:
* (string): Value of the information item, if the item exists.
The empty string, if the it... |
Return a single named information item from the lsb_release command output
data source of the current OS distribution. | def lsb_release_attr(attribute):
"""
Return a single named information item from the lsb_release command output
data source of the current OS distribution.
Parameters:
* ``attribute`` (string): Key of the information item.
Returns:
* (string): Value of the information item, if the item e... | [
"def",
"lsb_release_attr",
"(",
"attribute",
")",
":",
"return",
"_distro",
".",
"lsb_release_attr",
"(",
"attribute",
")"
] | [
488,
0
] | [
505,
46
] | python | en | ['en', 'error', 'th'] | False |
distro_release_attr | (attribute) |
Return a single named information item from the distro release file
data source of the current OS distribution.
Parameters:
* ``attribute`` (string): Key of the information item.
Returns:
* (string): Value of the information item, if the item exists.
The empty string, if the item does... |
Return a single named information item from the distro release file
data source of the current OS distribution. | def distro_release_attr(attribute):
"""
Return a single named information item from the distro release file
data source of the current OS distribution.
Parameters:
* ``attribute`` (string): Key of the information item.
Returns:
* (string): Value of the information item, if the item exist... | [
"def",
"distro_release_attr",
"(",
"attribute",
")",
":",
"return",
"_distro",
".",
"distro_release_attr",
"(",
"attribute",
")"
] | [
508,
0
] | [
524,
49
] | python | en | ['en', 'error', 'th'] | False |
uname_attr | (attribute) |
Return a single named information item from the distro release file
data source of the current OS distribution.
Parameters:
* ``attribute`` (string): Key of the information item.
Returns:
* (string): Value of the information item, if the item exists.
The empty string, if the... |
Return a single named information item from the distro release file
data source of the current OS distribution. | def uname_attr(attribute):
"""
Return a single named information item from the distro release file
data source of the current OS distribution.
Parameters:
* ``attribute`` (string): Key of the information item.
Returns:
* (string): Value of the information item, if the item exists.
... | [
"def",
"uname_attr",
"(",
"attribute",
")",
":",
"return",
"_distro",
".",
"uname_attr",
"(",
"attribute",
")"
] | [
527,
0
] | [
541,
40
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.__init__ | (self,
include_lsb=True,
os_release_file='',
distro_release_file='',
include_uname=True) |
The initialization method of this class gathers information from the
available data sources, and stores that in private instance attributes.
Subsequent access to the information items uses these private instance
attributes, so that the data sources are read only once.
Parameter... |
The initialization method of this class gathers information from the
available data sources, and stores that in private instance attributes.
Subsequent access to the information items uses these private instance
attributes, so that the data sources are read only once. | def __init__(self,
include_lsb=True,
os_release_file='',
distro_release_file='',
include_uname=True):
"""
The initialization method of this class gathers information from the
available data sources, and stores that in private in... | [
"def",
"__init__",
"(",
"self",
",",
"include_lsb",
"=",
"True",
",",
"os_release_file",
"=",
"''",
",",
"distro_release_file",
"=",
"''",
",",
"include_uname",
"=",
"True",
")",
":",
"self",
".",
"os_release_file",
"=",
"os_release_file",
"or",
"os",
".",
... | [
577,
4
] | [
653,
42
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.__repr__ | (self) | Return repr of all info
| Return repr of all info
| def __repr__(self):
"""Return repr of all info
"""
return \
"LinuxDistribution(" \
"os_release_file={self.os_release_file!r}, " \
"distro_release_file={self.distro_release_file!r}, " \
"include_lsb={self.include_lsb!r}, " \
"include_una... | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"\"LinuxDistribution(\"",
"\"os_release_file={self.os_release_file!r}, \"",
"\"distro_release_file={self.distro_release_file!r}, \"",
"\"include_lsb={self.include_lsb!r}, \"",
"\"include_uname={self.include_uname!r}, \"",
"\"_os_release_inf... | [
655,
4
] | [
668,
26
] | python | en | ['en', 'no', 'en'] | True |
LinuxDistribution.linux_distribution | (self, full_distribution_name=True) |
Return information about the OS distribution that is compatible
with Python's :func:`platform.linux_distribution`, supporting a subset
of its parameters.
For details, see :func:`distro.linux_distribution`.
|
Return information about the OS distribution that is compatible
with Python's :func:`platform.linux_distribution`, supporting a subset
of its parameters. | def linux_distribution(self, full_distribution_name=True):
"""
Return information about the OS distribution that is compatible
with Python's :func:`platform.linux_distribution`, supporting a subset
of its parameters.
For details, see :func:`distro.linux_distribution`.
""... | [
"def",
"linux_distribution",
"(",
"self",
",",
"full_distribution_name",
"=",
"True",
")",
":",
"return",
"(",
"self",
".",
"name",
"(",
")",
"if",
"full_distribution_name",
"else",
"self",
".",
"id",
"(",
")",
",",
"self",
".",
"version",
"(",
")",
",",... | [
670,
4
] | [
682,
9
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.id | (self) | Return the distro ID of the OS distribution, as a string.
For details, see :func:`distro.id`.
| Return the distro ID of the OS distribution, as a string. | def id(self):
"""Return the distro ID of the OS distribution, as a string.
For details, see :func:`distro.id`.
"""
def normalize(distro_id, table):
distro_id = distro_id.lower().replace(' ', '_')
return table.get(distro_id, distro_id)
distro_id = self.os... | [
"def",
"id",
"(",
"self",
")",
":",
"def",
"normalize",
"(",
"distro_id",
",",
"table",
")",
":",
"distro_id",
"=",
"distro_id",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"' '",
",",
"'_'",
")",
"return",
"table",
".",
"get",
"(",
"distro_id",
"... | [
684,
4
] | [
709,
17
] | python | en | ['en', 'en', 'en'] | True |
LinuxDistribution.name | (self, pretty=False) |
Return the name of the OS distribution, as a string.
For details, see :func:`distro.name`.
|
Return the name of the OS distribution, as a string. | def name(self, pretty=False):
"""
Return the name of the OS distribution, as a string.
For details, see :func:`distro.name`.
"""
name = self.os_release_attr('name') \
or self.lsb_release_attr('distributor_id') \
or self.distro_release_attr('name') \
... | [
"def",
"name",
"(",
"self",
",",
"pretty",
"=",
"False",
")",
":",
"name",
"=",
"self",
".",
"os_release_attr",
"(",
"'name'",
")",
"or",
"self",
".",
"lsb_release_attr",
"(",
"'distributor_id'",
")",
"or",
"self",
".",
"distro_release_attr",
"(",
"'name'"... | [
711,
4
] | [
730,
25
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.version | (self, pretty=False, best=False) |
Return the version of the OS distribution, as a string.
For details, see :func:`distro.version`.
|
Return the version of the OS distribution, as a string. | def version(self, pretty=False, best=False):
"""
Return the version of the OS distribution, as a string.
For details, see :func:`distro.version`.
"""
versions = [
self.os_release_attr('version_id'),
self.lsb_release_attr('release'),
self.distr... | [
"def",
"version",
"(",
"self",
",",
"pretty",
"=",
"False",
",",
"best",
"=",
"False",
")",
":",
"versions",
"=",
"[",
"self",
".",
"os_release_attr",
"(",
"'version_id'",
")",
",",
"self",
".",
"lsb_release_attr",
"(",
"'release'",
")",
",",
"self",
"... | [
732,
4
] | [
764,
22
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.version_parts | (self, best=False) |
Return the version of the OS distribution, as a tuple of version
numbers.
For details, see :func:`distro.version_parts`.
|
Return the version of the OS distribution, as a tuple of version
numbers. | def version_parts(self, best=False):
"""
Return the version of the OS distribution, as a tuple of version
numbers.
For details, see :func:`distro.version_parts`.
"""
version_str = self.version(best=best)
if version_str:
version_regex = re.compile(r'(\... | [
"def",
"version_parts",
"(",
"self",
",",
"best",
"=",
"False",
")",
":",
"version_str",
"=",
"self",
".",
"version",
"(",
"best",
"=",
"best",
")",
"if",
"version_str",
":",
"version_regex",
"=",
"re",
".",
"compile",
"(",
"r'(\\d+)\\.?(\\d+)?\\.?(\\d+)?'",... | [
766,
4
] | [
780,
25
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.major_version | (self, best=False) |
Return the major version number of the current distribution.
For details, see :func:`distro.major_version`.
|
Return the major version number of the current distribution. | def major_version(self, best=False):
"""
Return the major version number of the current distribution.
For details, see :func:`distro.major_version`.
"""
return self.version_parts(best)[0] | [
"def",
"major_version",
"(",
"self",
",",
"best",
"=",
"False",
")",
":",
"return",
"self",
".",
"version_parts",
"(",
"best",
")",
"[",
"0",
"]"
] | [
782,
4
] | [
788,
42
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.minor_version | (self, best=False) |
Return the minor version number of the current distribution.
For details, see :func:`distro.minor_version`.
|
Return the minor version number of the current distribution. | def minor_version(self, best=False):
"""
Return the minor version number of the current distribution.
For details, see :func:`distro.minor_version`.
"""
return self.version_parts(best)[1] | [
"def",
"minor_version",
"(",
"self",
",",
"best",
"=",
"False",
")",
":",
"return",
"self",
".",
"version_parts",
"(",
"best",
")",
"[",
"1",
"]"
] | [
790,
4
] | [
796,
42
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.build_number | (self, best=False) |
Return the build number of the current distribution.
For details, see :func:`distro.build_number`.
|
Return the build number of the current distribution. | def build_number(self, best=False):
"""
Return the build number of the current distribution.
For details, see :func:`distro.build_number`.
"""
return self.version_parts(best)[2] | [
"def",
"build_number",
"(",
"self",
",",
"best",
"=",
"False",
")",
":",
"return",
"self",
".",
"version_parts",
"(",
"best",
")",
"[",
"2",
"]"
] | [
798,
4
] | [
804,
42
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.like | (self) |
Return the IDs of distributions that are like the OS distribution.
For details, see :func:`distro.like`.
|
Return the IDs of distributions that are like the OS distribution. | def like(self):
"""
Return the IDs of distributions that are like the OS distribution.
For details, see :func:`distro.like`.
"""
return self.os_release_attr('id_like') or '' | [
"def",
"like",
"(",
"self",
")",
":",
"return",
"self",
".",
"os_release_attr",
"(",
"'id_like'",
")",
"or",
"''"
] | [
806,
4
] | [
812,
52
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.codename | (self) |
Return the codename of the OS distribution.
For details, see :func:`distro.codename`.
|
Return the codename of the OS distribution. | def codename(self):
"""
Return the codename of the OS distribution.
For details, see :func:`distro.codename`.
"""
try:
# Handle os_release specially since distros might purposefully set
# this to empty string to have no codename
return self._o... | [
"def",
"codename",
"(",
"self",
")",
":",
"try",
":",
"# Handle os_release specially since distros might purposefully set",
"# this to empty string to have no codename",
"return",
"self",
".",
"_os_release_info",
"[",
"'codename'",
"]",
"except",
"KeyError",
":",
"return",
... | [
814,
4
] | [
827,
21
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.info | (self, pretty=False, best=False) |
Return certain machine-readable information about the OS
distribution.
For details, see :func:`distro.info`.
|
Return certain machine-readable information about the OS
distribution. | def info(self, pretty=False, best=False):
"""
Return certain machine-readable information about the OS
distribution.
For details, see :func:`distro.info`.
"""
return dict(
id=self.id(),
version=self.version(pretty, best),
version_parts... | [
"def",
"info",
"(",
"self",
",",
"pretty",
"=",
"False",
",",
"best",
"=",
"False",
")",
":",
"return",
"dict",
"(",
"id",
"=",
"self",
".",
"id",
"(",
")",
",",
"version",
"=",
"self",
".",
"version",
"(",
"pretty",
",",
"best",
")",
",",
"ver... | [
829,
4
] | [
846,
9
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.os_release_info | (self) |
Return a dictionary containing key-value pairs for the information
items from the os-release file data source of the OS distribution.
For details, see :func:`distro.os_release_info`.
|
Return a dictionary containing key-value pairs for the information
items from the os-release file data source of the OS distribution. | def os_release_info(self):
"""
Return a dictionary containing key-value pairs for the information
items from the os-release file data source of the OS distribution.
For details, see :func:`distro.os_release_info`.
"""
return self._os_release_info | [
"def",
"os_release_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_os_release_info"
] | [
848,
4
] | [
855,
36
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.lsb_release_info | (self) |
Return a dictionary containing key-value pairs for the information
items from the lsb_release command data source of the OS
distribution.
For details, see :func:`distro.lsb_release_info`.
|
Return a dictionary containing key-value pairs for the information
items from the lsb_release command data source of the OS
distribution. | def lsb_release_info(self):
"""
Return a dictionary containing key-value pairs for the information
items from the lsb_release command data source of the OS
distribution.
For details, see :func:`distro.lsb_release_info`.
"""
return self._lsb_release_info | [
"def",
"lsb_release_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lsb_release_info"
] | [
857,
4
] | [
865,
37
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.distro_release_info | (self) |
Return a dictionary containing key-value pairs for the information
items from the distro release file data source of the OS
distribution.
For details, see :func:`distro.distro_release_info`.
|
Return a dictionary containing key-value pairs for the information
items from the distro release file data source of the OS
distribution. | def distro_release_info(self):
"""
Return a dictionary containing key-value pairs for the information
items from the distro release file data source of the OS
distribution.
For details, see :func:`distro.distro_release_info`.
"""
return self._distro_release_info | [
"def",
"distro_release_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_distro_release_info"
] | [
867,
4
] | [
875,
40
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.uname_info | (self) |
Return a dictionary containing key-value pairs for the information
items from the uname command data source of the OS distribution.
For details, see :func:`distro.uname_info`.
|
Return a dictionary containing key-value pairs for the information
items from the uname command data source of the OS distribution. | def uname_info(self):
"""
Return a dictionary containing key-value pairs for the information
items from the uname command data source of the OS distribution.
For details, see :func:`distro.uname_info`.
"""
return self._uname_info | [
"def",
"uname_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_uname_info"
] | [
877,
4
] | [
884,
31
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.os_release_attr | (self, attribute) |
Return a single named information item from the os-release file data
source of the OS distribution.
For details, see :func:`distro.os_release_attr`.
|
Return a single named information item from the os-release file data
source of the OS distribution. | def os_release_attr(self, attribute):
"""
Return a single named information item from the os-release file data
source of the OS distribution.
For details, see :func:`distro.os_release_attr`.
"""
return self._os_release_info.get(attribute, '') | [
"def",
"os_release_attr",
"(",
"self",
",",
"attribute",
")",
":",
"return",
"self",
".",
"_os_release_info",
".",
"get",
"(",
"attribute",
",",
"''",
")"
] | [
886,
4
] | [
893,
55
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.lsb_release_attr | (self, attribute) |
Return a single named information item from the lsb_release command
output data source of the OS distribution.
For details, see :func:`distro.lsb_release_attr`.
|
Return a single named information item from the lsb_release command
output data source of the OS distribution. | def lsb_release_attr(self, attribute):
"""
Return a single named information item from the lsb_release command
output data source of the OS distribution.
For details, see :func:`distro.lsb_release_attr`.
"""
return self._lsb_release_info.get(attribute, '') | [
"def",
"lsb_release_attr",
"(",
"self",
",",
"attribute",
")",
":",
"return",
"self",
".",
"_lsb_release_info",
".",
"get",
"(",
"attribute",
",",
"''",
")"
] | [
895,
4
] | [
902,
56
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.distro_release_attr | (self, attribute) |
Return a single named information item from the distro release file
data source of the OS distribution.
For details, see :func:`distro.distro_release_attr`.
|
Return a single named information item from the distro release file
data source of the OS distribution. | def distro_release_attr(self, attribute):
"""
Return a single named information item from the distro release file
data source of the OS distribution.
For details, see :func:`distro.distro_release_attr`.
"""
return self._distro_release_info.get(attribute, '') | [
"def",
"distro_release_attr",
"(",
"self",
",",
"attribute",
")",
":",
"return",
"self",
".",
"_distro_release_info",
".",
"get",
"(",
"attribute",
",",
"''",
")"
] | [
904,
4
] | [
911,
59
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution.uname_attr | (self, attribute) |
Return a single named information item from the uname command
output data source of the OS distribution.
For details, see :func:`distro.uname_release_attr`.
|
Return a single named information item from the uname command
output data source of the OS distribution. | def uname_attr(self, attribute):
"""
Return a single named information item from the uname command
output data source of the OS distribution.
For details, see :func:`distro.uname_release_attr`.
"""
return self._uname_info.get(attribute, '') | [
"def",
"uname_attr",
"(",
"self",
",",
"attribute",
")",
":",
"return",
"self",
".",
"_uname_info",
".",
"get",
"(",
"attribute",
",",
"''",
")"
] | [
913,
4
] | [
920,
50
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution._os_release_info | (self) |
Get the information items from the specified os-release file.
Returns:
A dictionary containing all information items.
|
Get the information items from the specified os-release file. | def _os_release_info(self):
"""
Get the information items from the specified os-release file.
Returns:
A dictionary containing all information items.
"""
if os.path.isfile(self.os_release_file):
with open(self.os_release_file) as release_file:
... | [
"def",
"_os_release_info",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"os_release_file",
")",
":",
"with",
"open",
"(",
"self",
".",
"os_release_file",
")",
"as",
"release_file",
":",
"return",
"self",
".",
"_parse_o... | [
923,
4
] | [
933,
17
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution._parse_os_release_content | (lines) |
Parse the lines of an os-release file.
Parameters:
* lines: Iterable through the lines in the os-release file.
Each line must be a unicode string or a UTF-8 encoded byte
string.
Returns:
A dictionary containing all information items.
... |
Parse the lines of an os-release file. | def _parse_os_release_content(lines):
"""
Parse the lines of an os-release file.
Parameters:
* lines: Iterable through the lines in the os-release file.
Each line must be a unicode string or a UTF-8 encoded byte
string.
Returns:
A ... | [
"def",
"_parse_os_release_content",
"(",
"lines",
")",
":",
"props",
"=",
"{",
"}",
"lexer",
"=",
"shlex",
".",
"shlex",
"(",
"lines",
",",
"posix",
"=",
"True",
")",
"lexer",
".",
"whitespace_split",
"=",
"True",
"# The shlex module defines its `wordchars` vari... | [
936,
4
] | [
998,
20
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution._lsb_release_info | (self) |
Get the information items from the lsb_release command output.
Returns:
A dictionary containing all information items.
|
Get the information items from the lsb_release command output. | def _lsb_release_info(self):
"""
Get the information items from the lsb_release command output.
Returns:
A dictionary containing all information items.
"""
if not self.include_lsb:
return {}
with open(os.devnull, 'w') as devnull:
try:
... | [
"def",
"_lsb_release_info",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"include_lsb",
":",
"return",
"{",
"}",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"'w'",
")",
"as",
"devnull",
":",
"try",
":",
"cmd",
"=",
"(",
"'lsb_release'",
",",
... | [
1001,
4
] | [
1017,
55
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution._parse_lsb_release_content | (lines) |
Parse the output of the lsb_release command.
Parameters:
* lines: Iterable through the lines of the lsb_release output.
Each line must be a unicode string or a UTF-8 encoded byte
string.
Returns:
A dictionary containing all information it... |
Parse the output of the lsb_release command. | def _parse_lsb_release_content(lines):
"""
Parse the output of the lsb_release command.
Parameters:
* lines: Iterable through the lines of the lsb_release output.
Each line must be a unicode string or a UTF-8 encoded byte
string.
Returns:
... | [
"def",
"_parse_lsb_release_content",
"(",
"lines",
")",
":",
"props",
"=",
"{",
"}",
"for",
"line",
"in",
"lines",
":",
"kv",
"=",
"line",
".",
"strip",
"(",
"'\\n'",
")",
".",
"split",
"(",
"':'",
",",
"1",
")",
"if",
"len",
"(",
"kv",
")",
"!="... | [
1020,
4
] | [
1041,
20
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution._distro_release_info | (self) |
Get the information items from the specified distro release file.
Returns:
A dictionary containing all information items.
|
Get the information items from the specified distro release file. | def _distro_release_info(self):
"""
Get the information items from the specified distro release file.
Returns:
A dictionary containing all information items.
"""
if self.distro_release_file:
# If it was specified, we use it and parse what we can, even if
... | [
"def",
"_distro_release_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"distro_release_file",
":",
"# If it was specified, we use it and parse what we can, even if",
"# its file name or content does not match the expected pattern.",
"distro_info",
"=",
"self",
".",
"_parse_distro... | [
1086,
4
] | [
1151,
21
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution._parse_distro_release_file | (self, filepath) |
Parse a distro release file.
Parameters:
* filepath: Path name of the distro release file.
Returns:
A dictionary containing all information items.
|
Parse a distro release file. | def _parse_distro_release_file(self, filepath):
"""
Parse a distro release file.
Parameters:
* filepath: Path name of the distro release file.
Returns:
A dictionary containing all information items.
"""
try:
with open(filepath) as fp:
... | [
"def",
"_parse_distro_release_file",
"(",
"self",
",",
"filepath",
")",
":",
"try",
":",
"with",
"open",
"(",
"filepath",
")",
"as",
"fp",
":",
"# Only parse the first line. For instance, on SLES there",
"# are multiple lines. We don't want them...",
"return",
"self",
"."... | [
1153,
4
] | [
1173,
21
] | python | en | ['en', 'error', 'th'] | False |
LinuxDistribution._parse_distro_release_content | (line) |
Parse a line from a distro release file.
Parameters:
* line: Line from the distro release file. Must be a unicode string
or a UTF-8 encoded byte string.
Returns:
A dictionary containing all information items.
|
Parse a line from a distro release file. | def _parse_distro_release_content(line):
"""
Parse a line from a distro release file.
Parameters:
* line: Line from the distro release file. Must be a unicode string
or a UTF-8 encoded byte string.
Returns:
A dictionary containing all information ite... | [
"def",
"_parse_distro_release_content",
"(",
"line",
")",
":",
"matches",
"=",
"_DISTRO_RELEASE_CONTENT_REVERSED_PATTERN",
".",
"match",
"(",
"line",
".",
"strip",
"(",
")",
"[",
":",
":",
"-",
"1",
"]",
")",
"distro_info",
"=",
"{",
"}",
"if",
"matches",
... | [
1176,
4
] | [
1199,
26
] | python | en | ['en', 'error', 'th'] | False |
WorkerTest.test_push_notifications_worker | (self) |
The push notifications system has its own comprehensive test suite,
so we can limit ourselves to simple unit testing the queue processor,
without going deeper into the system - by mocking the handle_push_notification
functions to immediately produce the effect we want, to test its handl... |
The push notifications system has its own comprehensive test suite,
so we can limit ourselves to simple unit testing the queue processor,
without going deeper into the system - by mocking the handle_push_notification
functions to immediately produce the effect we want, to test its handl... | def test_push_notifications_worker(self) -> None:
"""
The push notifications system has its own comprehensive test suite,
so we can limit ourselves to simple unit testing the queue processor,
without going deeper into the system - by mocking the handle_push_notification
functions... | [
"def",
"test_push_notifications_worker",
"(",
"self",
")",
"->",
"None",
":",
"fake_client",
"=",
"self",
".",
"FakeClient",
"(",
")",
"def",
"fake_publish",
"(",
"queue_name",
":",
"str",
",",
"event",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"pro... | [
228,
4
] | [
300,
17
] | python | en | ['en', 'error', 'th'] | False |
WorkerTest.test_email_sending_worker_retries | (self) | Tests the retry_send_email_failures decorator to make sure it
retries sending the email 3 times and then gives up. | Tests the retry_send_email_failures decorator to make sure it
retries sending the email 3 times and then gives up. | def test_email_sending_worker_retries(self) -> None:
"""Tests the retry_send_email_failures decorator to make sure it
retries sending the email 3 times and then gives up."""
fake_client = self.FakeClient()
data = {
"template_prefix": "zerver/emails/confirm_new_email",
... | [
"def",
"test_email_sending_worker_retries",
"(",
"self",
")",
"->",
"None",
":",
"fake_client",
"=",
"self",
".",
"FakeClient",
"(",
")",
"data",
"=",
"{",
"\"template_prefix\"",
":",
"\"zerver/emails/confirm_new_email\"",
",",
"\"to_emails\"",
":",
"[",
"self",
"... | [
400,
4
] | [
432,
71
] | python | en | ['en', 'en', 'en'] | True |
splitUp | (pred) | Parse a single version comparison.
Return (comparison string, StrictVersion)
| Parse a single version comparison. | def splitUp(pred):
"""Parse a single version comparison.
Return (comparison string, StrictVersion)
"""
res = re_splitComparison.match(pred)
if not res:
raise ValueError("bad package restriction syntax: %r" % pred)
comp, verStr = res.groups()
return (comp, distutils.version.StrictVer... | [
"def",
"splitUp",
"(",
"pred",
")",
":",
"res",
"=",
"re_splitComparison",
".",
"match",
"(",
"pred",
")",
"if",
"not",
"res",
":",
"raise",
"ValueError",
"(",
"\"bad package restriction syntax: %r\"",
"%",
"pred",
")",
"comp",
",",
"verStr",
"=",
"res",
"... | [
16,
0
] | [
25,
58
] | python | en | ['en', 'fr', 'en'] | True |
split_provision | (value) | Return the name and optional version number of a provision.
The version number, if given, will be returned as a `StrictVersion`
instance, otherwise it will be `None`.
>>> split_provision('mypkg')
('mypkg', None)
>>> split_provision(' mypkg( 1.2 ) ')
('mypkg', StrictVersion ('1.2'))
| Return the name and optional version number of a provision. | def split_provision(value):
"""Return the name and optional version number of a provision.
The version number, if given, will be returned as a `StrictVersion`
instance, otherwise it will be `None`.
>>> split_provision('mypkg')
('mypkg', None)
>>> split_provision(' mypkg( 1.2 ) ')
('mypkg',... | [
"def",
"split_provision",
"(",
"value",
")",
":",
"global",
"_provision_rx",
"if",
"_provision_rx",
"is",
"None",
":",
"_provision_rx",
"=",
"re",
".",
"compile",
"(",
"r\"([a-zA-Z_]\\w*(?:\\.[a-zA-Z_]\\w*)*)(?:\\s*\\(\\s*([^)\\s]+)\\s*\\))?$\"",
",",
"re",
".",
"ASCII"... | [
142,
0
] | [
165,
26
] | python | en | ['en', 'en', 'en'] | True |
VersionPredicate.__init__ | (self, versionPredicateStr) | Parse a version predicate string.
| Parse a version predicate string.
| def __init__(self, versionPredicateStr):
"""Parse a version predicate string.
"""
# Fields:
# name: package name
# pred: list of (comparison string, StrictVersion)
versionPredicateStr = versionPredicateStr.strip()
if not versionPredicateStr:
r... | [
"def",
"__init__",
"(",
"self",
",",
"versionPredicateStr",
")",
":",
"# Fields:",
"# name: package name",
"# pred: list of (comparison string, StrictVersion)",
"versionPredicateStr",
"=",
"versionPredicateStr",
".",
"strip",
"(",
")",
"if",
"not",
"versionPredicateSt... | [
95,
4
] | [
120,
26
] | python | ht | ['sk', 'ht', 'it'] | False |
VersionPredicate.satisfied_by | (self, version) | True if version is compatible with all the predicates in self.
The parameter version must be acceptable to the StrictVersion
constructor. It may be either a string or StrictVersion.
| True if version is compatible with all the predicates in self.
The parameter version must be acceptable to the StrictVersion
constructor. It may be either a string or StrictVersion.
| def satisfied_by(self, version):
"""True if version is compatible with all the predicates in self.
The parameter version must be acceptable to the StrictVersion
constructor. It may be either a string or StrictVersion.
"""
for cond, ver in self.pred:
if not compmap[co... | [
"def",
"satisfied_by",
"(",
"self",
",",
"version",
")",
":",
"for",
"cond",
",",
"ver",
"in",
"self",
".",
"pred",
":",
"if",
"not",
"compmap",
"[",
"cond",
"]",
"(",
"version",
",",
"ver",
")",
":",
"return",
"False",
"return",
"True"
] | [
129,
4
] | [
137,
19
] | python | en | ['en', 'en', 'en'] | True |
PostGISIntrospection.get_geometry_type | (self, table_name, description) |
The geometry type OID used by PostGIS does not indicate the particular
type of field that a geometry column is (e.g., whether it's a
PointField or a PolygonField). Thus, this routine queries the PostGIS
metadata tables to determine the geometry type.
|
The geometry type OID used by PostGIS does not indicate the particular
type of field that a geometry column is (e.g., whether it's a
PointField or a PolygonField). Thus, this routine queries the PostGIS
metadata tables to determine the geometry type.
| def get_geometry_type(self, table_name, description):
"""
The geometry type OID used by PostGIS does not indicate the particular
type of field that a geometry column is (e.g., whether it's a
PointField or a PolygonField). Thus, this routine queries the PostGIS
metadata tables to... | [
"def",
"get_geometry_type",
"(",
"self",
",",
"table_name",
",",
"description",
")",
":",
"with",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"as",
"cursor",
":",
"cursor",
".",
"execute",
"(",
"\"\"\"\n SELECT t.coord_dimension, t.srid, t.typ... | [
28,
4
] | [
59,
39
] | python | en | ['en', 'error', 'th'] | False |
user_groups_in_realm_serialized | (realm: Realm) | This function is used in do_events_register code path so this code
should be performant. We need to do 2 database queries because
Django's ORM doesn't properly support the left join between
UserGroup and UserGroupMembership that we need.
| This function is used in do_events_register code path so this code
should be performant. We need to do 2 database queries because
Django's ORM doesn't properly support the left join between
UserGroup and UserGroupMembership that we need.
| def user_groups_in_realm_serialized(realm: Realm) -> List[Dict[str, Any]]:
"""This function is used in do_events_register code path so this code
should be performant. We need to do 2 database queries because
Django's ORM doesn't properly support the left join between
UserGroup and UserGroupMembership t... | [
"def",
"user_groups_in_realm_serialized",
"(",
"realm",
":",
"Realm",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"realm_groups",
"=",
"UserGroup",
".",
"objects",
".",
"filter",
"(",
"realm",
"=",
"realm",
")",
"group_dicts",
... | [
26,
0
] | [
50,
80
] | python | en | ['en', 'en', 'en'] | True |
mnist_tutorial | (
train_start=0,
train_end=60000,
test_start=0,
test_end=10000,
nb_epochs=NB_EPOCHS,
batch_size=BATCH_SIZE,
learning_rate=LEARNING_RATE,
clean_train=CLEAN_TRAIN,
testing=False,
backprop_through_attack=BACKPROP_THROUGH_ATTACK,
nb_filters=NB_FILTERS,
num_threads=None,
l... |
MNIST cleverhans tutorial
:param train_start: index of first training set example
:param train_end: index of last training set example
:param test_start: index of first test set example
:param test_end: index of last test set example
:param nb_epochs: number of epochs to train model
:param ... |
MNIST cleverhans tutorial
:param train_start: index of first training set example
:param train_end: index of last training set example
:param test_start: index of first test set example
:param test_end: index of last test set example
:param nb_epochs: number of epochs to train model
:param ... | def mnist_tutorial(
train_start=0,
train_end=60000,
test_start=0,
test_end=10000,
nb_epochs=NB_EPOCHS,
batch_size=BATCH_SIZE,
learning_rate=LEARNING_RATE,
clean_train=CLEAN_TRAIN,
testing=False,
backprop_through_attack=BACKPROP_THROUGH_ATTACK,
nb_filters=NB_FILTERS,
num_t... | [
"def",
"mnist_tutorial",
"(",
"train_start",
"=",
"0",
",",
"train_end",
"=",
"60000",
",",
"test_start",
"=",
"0",
",",
"test_end",
"=",
"10000",
",",
"nb_epochs",
"=",
"NB_EPOCHS",
",",
"batch_size",
"=",
"BATCH_SIZE",
",",
"learning_rate",
"=",
"LEARNING_... | [
37,
0
] | [
210,
17
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.