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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
import_library | (name) |
Load a Library object from a template tag module.
|
Load a Library object from a template tag module.
| def import_library(name):
"""
Load a Library object from a template tag module.
"""
try:
module = import_module(name)
except ImportError as e:
raise InvalidTemplateLibrary(
"Invalid template library specified. ImportError raised when "
"trying to load '%s': %s... | [
"def",
"import_library",
"(",
"name",
")",
":",
"try",
":",
"module",
"=",
"import_module",
"(",
"name",
")",
"except",
"ImportError",
"as",
"e",
":",
"raise",
"InvalidTemplateLibrary",
"(",
"\"Invalid template library specified. ImportError raised when \"",
"\"trying t... | [
315,
0
] | [
331,
9
] | python | en | ['en', 'error', 'th'] | False |
Library.filter | (self, name=None, filter_func=None, **flags) |
Register a callable as a template filter. Example:
@register.filter
def lower(value):
return value.lower()
|
Register a callable as a template filter. Example: | def filter(self, name=None, filter_func=None, **flags):
"""
Register a callable as a template filter. Example:
@register.filter
def lower(value):
return value.lower()
"""
if name is None and filter_func is None:
# @register.filter()
de... | [
"def",
"filter",
"(",
"self",
",",
"name",
"=",
"None",
",",
"filter_func",
"=",
"None",
",",
"*",
"*",
"flags",
")",
":",
"if",
"name",
"is",
"None",
"and",
"filter_func",
"is",
"None",
":",
"# @register.filter()",
"def",
"dec",
"(",
"func",
")",
":... | [
56,
4
] | [
96,
13
] | python | en | ['en', 'error', 'th'] | False |
Library.simple_tag | (self, func=None, takes_context=None, name=None) |
Register a callable as a compiled template tag. Example:
@register.simple_tag
def hello(*args, **kwargs):
return 'world'
|
Register a callable as a compiled template tag. Example: | def simple_tag(self, func=None, takes_context=None, name=None):
"""
Register a callable as a compiled template tag. Example:
@register.simple_tag
def hello(*args, **kwargs):
return 'world'
"""
def dec(func):
params, varargs, varkw, defaults = geta... | [
"def",
"simple_tag",
"(",
"self",
",",
"func",
"=",
"None",
",",
"takes_context",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"def",
"dec",
"(",
"func",
")",
":",
"params",
",",
"varargs",
",",
"varkw",
",",
"defaults",
"=",
"getargspec",
"(",
... | [
102,
4
] | [
136,
72
] | python | en | ['en', 'error', 'th'] | False |
Library.inclusion_tag | (self, filename, func=None, takes_context=None, name=None) |
Register a callable as an inclusion tag:
@register.inclusion_tag('results.html')
def show_results(poll):
choices = poll.choice_set.all()
return {'choices': choices}
|
Register a callable as an inclusion tag: | def inclusion_tag(self, filename, func=None, takes_context=None, name=None):
"""
Register a callable as an inclusion tag:
@register.inclusion_tag('results.html')
def show_results(poll):
choices = poll.choice_set.all()
return {'choices': choices}
"""
... | [
"def",
"inclusion_tag",
"(",
"self",
",",
"filename",
",",
"func",
"=",
"None",
",",
"takes_context",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"def",
"dec",
"(",
"func",
")",
":",
"params",
",",
"varargs",
",",
"varkw",
",",
"defaults",
"=",
... | [
146,
4
] | [
171,
18
] | python | en | ['en', 'error', 'th'] | False |
InclusionNode.render | (self, context) |
Render the specified template and context. Cache the template object
in render_context to avoid reparsing and loading when used in a for
loop.
|
Render the specified template and context. Cache the template object
in render_context to avoid reparsing and loading when used in a for
loop.
| def render(self, context):
"""
Render the specified template and context. Cache the template object
in render_context to avoid reparsing and loading when used in a for
loop.
"""
resolved_args, resolved_kwargs = self.get_resolved_arguments(context)
_dict = self.fun... | [
"def",
"render",
"(",
"self",
",",
"context",
")",
":",
"resolved_args",
",",
"resolved_kwargs",
"=",
"self",
".",
"get_resolved_arguments",
"(",
"context",
")",
"_dict",
"=",
"self",
".",
"func",
"(",
"*",
"resolved_args",
",",
"*",
"*",
"resolved_kwargs",
... | [
217,
4
] | [
244,
36
] | python | en | ['en', 'error', 'th'] | False |
_sample_mask | (ratio, test_mask, l) | Create mask. | Create mask. | def _sample_mask(ratio, test_mask, l):
"""Create mask."""
i =0
idx = []
if test_mask is None:
test_mask = np.zeros(l)
#idx1 = random.choice(l)
while( i < int(ratio*l)):
idx1 = random.choice(range(l))
if test_mask[idx1] ==0:
idx.append(idx1)
i+=1
... | [
"def",
"_sample_mask",
"(",
"ratio",
",",
"test_mask",
",",
"l",
")",
":",
"i",
"=",
"0",
"idx",
"=",
"[",
"]",
"if",
"test_mask",
"is",
"None",
":",
"test_mask",
"=",
"np",
".",
"zeros",
"(",
"l",
")",
"#idx1 = random.choice(l)",
"while",
"(",
"i",
... | [
99,
0
] | [
114,
15
] | python | en | ['en', 'sm', 'en'] | False |
CameraClick.capture | (self) |
Function to capture the images and give them the names
according to their captured time and date.
|
Function to capture the images and give them the names
according to their captured time and date.
| def capture(self):
'''
Function to capture the images and give them the names
according to their captured time and date.
'''
camera = self.ids['camera']
timestr = time.strftime("%Y%m%d_%H%M%S")
camera.export_to_png("IMG_{}.png".format(timestr))
print("Capt... | [
"def",
"capture",
"(",
"self",
")",
":",
"camera",
"=",
"self",
".",
"ids",
"[",
"'camera'",
"]",
"timestr",
"=",
"time",
".",
"strftime",
"(",
"\"%Y%m%d_%H%M%S\"",
")",
"camera",
".",
"export_to_png",
"(",
"\"IMG_{}.png\"",
".",
"format",
"(",
"timestr",
... | [
41,
4
] | [
49,
25
] | python | en | ['en', 'error', 'th'] | False |
load_handler | (path, *args, **kwargs) |
Given a path to a handler, return an instance of that handler.
E.g.::
>>> from django.http import HttpRequest
>>> request = HttpRequest()
>>> load_handler('django.core.files.uploadhandler.TemporaryFileUploadHandler', request)
<TemporaryFileUploadHandler object at 0x...>
|
Given a path to a handler, return an instance of that handler. | def load_handler(path, *args, **kwargs):
"""
Given a path to a handler, return an instance of that handler.
E.g.::
>>> from django.http import HttpRequest
>>> request = HttpRequest()
>>> load_handler('django.core.files.uploadhandler.TemporaryFileUploadHandler', request)
<Tem... | [
"def",
"load_handler",
"(",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"import_string",
"(",
"path",
")",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
207,
0
] | [
217,
47
] | python | en | ['en', 'error', 'th'] | False |
FileUploadHandler.handle_raw_input | (self, input_data, META, content_length, boundary, encoding=None) |
Handle the raw input from the client.
Parameters:
:input_data:
An object that supports reading via .read().
:META:
``request.META``.
:content_length:
The (integer) value of the Content-Length header from the
... |
Handle the raw input from the client. | def handle_raw_input(self, input_data, META, content_length, boundary, encoding=None):
"""
Handle the raw input from the client.
Parameters:
:input_data:
An object that supports reading via .read().
:META:
``request.META``.
:c... | [
"def",
"handle_raw_input",
"(",
"self",
",",
"input_data",
",",
"META",
",",
"content_length",
",",
"boundary",
",",
"encoding",
"=",
"None",
")",
":",
"pass"
] | [
78,
4
] | [
94,
12
] | python | en | ['en', 'error', 'th'] | False |
FileUploadHandler.new_file | (self, field_name, file_name, content_type, content_length, charset=None, content_type_extra=None) |
Signal that a new file has been started.
Warning: As with any data from the client, you should not trust
content_length (and sometimes won't even get it).
|
Signal that a new file has been started. | def new_file(self, field_name, file_name, content_type, content_length, charset=None, content_type_extra=None):
"""
Signal that a new file has been started.
Warning: As with any data from the client, you should not trust
content_length (and sometimes won't even get it).
"""
... | [
"def",
"new_file",
"(",
"self",
",",
"field_name",
",",
"file_name",
",",
"content_type",
",",
"content_length",
",",
"charset",
"=",
"None",
",",
"content_type_extra",
"=",
"None",
")",
":",
"self",
".",
"field_name",
"=",
"field_name",
"self",
".",
"file_n... | [
96,
4
] | [
108,
52
] | python | en | ['en', 'error', 'th'] | False |
FileUploadHandler.receive_data_chunk | (self, raw_data, start) |
Receive data from the streamed upload parser. ``start`` is the position
in the file of the chunk.
|
Receive data from the streamed upload parser. ``start`` is the position
in the file of the chunk.
| def receive_data_chunk(self, raw_data, start):
"""
Receive data from the streamed upload parser. ``start`` is the position
in the file of the chunk.
"""
raise NotImplementedError('subclasses of FileUploadHandler must provide a receive_data_chunk() method') | [
"def",
"receive_data_chunk",
"(",
"self",
",",
"raw_data",
",",
"start",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of FileUploadHandler must provide a receive_data_chunk() method'",
")"
] | [
110,
4
] | [
115,
111
] | python | en | ['en', 'error', 'th'] | False |
FileUploadHandler.file_complete | (self, file_size) |
Signal that a file has completed. File size corresponds to the actual
size accumulated by all the chunks.
Subclasses should return a valid ``UploadedFile`` object.
|
Signal that a file has completed. File size corresponds to the actual
size accumulated by all the chunks. | def file_complete(self, file_size):
"""
Signal that a file has completed. File size corresponds to the actual
size accumulated by all the chunks.
Subclasses should return a valid ``UploadedFile`` object.
"""
raise NotImplementedError('subclasses of FileUploadHandler must... | [
"def",
"file_complete",
"(",
"self",
",",
"file_size",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of FileUploadHandler must provide a file_complete() method'",
")"
] | [
117,
4
] | [
124,
106
] | python | en | ['en', 'error', 'th'] | False |
FileUploadHandler.upload_complete | (self) |
Signal that the upload is complete. Subclasses should perform cleanup
that is necessary for this handler.
|
Signal that the upload is complete. Subclasses should perform cleanup
that is necessary for this handler.
| def upload_complete(self):
"""
Signal that the upload is complete. Subclasses should perform cleanup
that is necessary for this handler.
"""
pass | [
"def",
"upload_complete",
"(",
"self",
")",
":",
"pass"
] | [
126,
4
] | [
131,
12
] | python | en | ['en', 'error', 'th'] | False |
TemporaryFileUploadHandler.new_file | (self, *args, **kwargs) |
Create the file object to append to as data is coming in.
|
Create the file object to append to as data is coming in.
| def new_file(self, *args, **kwargs):
"""
Create the file object to append to as data is coming in.
"""
super(TemporaryFileUploadHandler, self).new_file(*args, **kwargs)
self.file = TemporaryUploadedFile(self.file_name, self.content_type, 0, self.charset, self.content_type_extra) | [
"def",
"new_file",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"TemporaryFileUploadHandler",
",",
"self",
")",
".",
"new_file",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"file",
"=",
"TemporaryUp... | [
141,
4
] | [
146,
118
] | python | en | ['en', 'error', 'th'] | False |
MemoryFileUploadHandler.handle_raw_input | (self, input_data, META, content_length, boundary, encoding=None) |
Use the content_length to signal whether or not this handler should be in use.
|
Use the content_length to signal whether or not this handler should be in use.
| def handle_raw_input(self, input_data, META, content_length, boundary, encoding=None):
"""
Use the content_length to signal whether or not this handler should be in use.
"""
# Check the content-length header to see if we should
# If the post is too large, we cannot use the Memory... | [
"def",
"handle_raw_input",
"(",
"self",
",",
"input_data",
",",
"META",
",",
"content_length",
",",
"boundary",
",",
"encoding",
"=",
"None",
")",
":",
"# Check the content-length header to see if we should",
"# If the post is too large, we cannot use the Memory handler.",
"i... | [
162,
4
] | [
171,
33
] | python | en | ['en', 'error', 'th'] | False |
MemoryFileUploadHandler.receive_data_chunk | (self, raw_data, start) |
Add the data to the BytesIO file.
|
Add the data to the BytesIO file.
| def receive_data_chunk(self, raw_data, start):
"""
Add the data to the BytesIO file.
"""
if self.activated:
self.file.write(raw_data)
else:
return raw_data | [
"def",
"receive_data_chunk",
"(",
"self",
",",
"raw_data",
",",
"start",
")",
":",
"if",
"self",
".",
"activated",
":",
"self",
".",
"file",
".",
"write",
"(",
"raw_data",
")",
"else",
":",
"return",
"raw_data"
] | [
179,
4
] | [
186,
27
] | python | en | ['en', 'error', 'th'] | False |
MemoryFileUploadHandler.file_complete | (self, file_size) |
Return a file object if we're activated.
|
Return a file object if we're activated.
| def file_complete(self, file_size):
"""
Return a file object if we're activated.
"""
if not self.activated:
return
self.file.seek(0)
return InMemoryUploadedFile(
file=self.file,
field_name=self.field_name,
name=self.file_na... | [
"def",
"file_complete",
"(",
"self",
",",
"file_size",
")",
":",
"if",
"not",
"self",
".",
"activated",
":",
"return",
"self",
".",
"file",
".",
"seek",
"(",
"0",
")",
"return",
"InMemoryUploadedFile",
"(",
"file",
"=",
"self",
".",
"file",
",",
"field... | [
188,
4
] | [
204,
9
] | 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 |
TestImageChooserBlock.get_image_filename | (self, image, filterspec) |
Get the generated filename for a resized image
|
Get the generated filename for a resized image
| def get_image_filename(self, image, filterspec):
"""
Get the generated filename for a resized image
"""
name, ext = os.path.splitext(os.path.basename(image.file.name))
return '{}images/{}.{}{}'.format(
settings.MEDIA_URL, name, filterspec, ext) | [
"def",
"get_image_filename",
"(",
"self",
",",
"image",
",",
"filterspec",
")",
":",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"image",
".",
"file",
".",
"name",
")",
")",
"return",
"... | [
32,
4
] | [
38,
54
] | 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 |
generate_django_secretkey | () | Secret key generation taken from Django's startproject.py | Secret key generation taken from Django's startproject.py | def generate_django_secretkey() -> str:
"""Secret key generation taken from Django's startproject.py"""
# We do in-function imports so that we only do the expensive work
# of importing cryptography modules when necessary.
#
# This helps optimize noop provision performance.
from django.utils.cry... | [
"def",
"generate_django_secretkey",
"(",
")",
"->",
"str",
":",
"# We do in-function imports so that we only do the expensive work",
"# of importing cryptography modules when necessary.",
"#",
"# This helps optimize noop provision performance.",
"from",
"django",
".",
"utils",
".",
"... | [
49,
0
] | [
59,
39
] | python | en | ['en', 'fy', '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 |
create_fits_hdu | () |
Create a fake AARTFAAC file used as a base for the emulated servers. Could
be anything but for now we just take the fits file from the test data.
returns:
astropy.io.fits.HDUList: a fits object
|
Create a fake AARTFAAC file used as a base for the emulated servers. Could
be anything but for now we just take the fits file from the test data. | def create_fits_hdu():
"""
Create a fake AARTFAAC file used as a base for the emulated servers. Could
be anything but for now we just take the fits file from the test data.
returns:
astropy.io.fits.HDUList: a fits object
"""
hdulist = fits.open(path.join(DATAPATH, 'accessors/aartfaac.fi... | [
"def",
"create_fits_hdu",
"(",
")",
":",
"hdulist",
"=",
"fits",
".",
"open",
"(",
"path",
".",
"join",
"(",
"DATAPATH",
",",
"'accessors/aartfaac.fits'",
")",
")",
"hdu",
"=",
"hdulist",
"[",
"0",
"]",
"return",
"hdu"
] | [
86,
0
] | [
96,
14
] | python | en | ['en', 'error', 'th'] | False |
serialize_hdu | (hdu) |
Serialize a fits object.
args:
hdu (astropy.io.fits.HDUList): a fits object
returns:
str: a serialized fits object.
|
Serialize a fits object. | def serialize_hdu(hdu):
"""
Serialize a fits object.
args:
hdu (astropy.io.fits.HDUList): a fits object
returns:
str: a serialized fits object.
"""
data = struct.pack('=%sf' % hdu.data.size, *hdu.data.flatten('F'))
header = hdu.header.tostring()
return data, header | [
"def",
"serialize_hdu",
"(",
"hdu",
")",
":",
"data",
"=",
"struct",
".",
"pack",
"(",
"'=%sf'",
"%",
"hdu",
".",
"data",
".",
"size",
",",
"*",
"hdu",
".",
"data",
".",
"flatten",
"(",
"'F'",
")",
")",
"header",
"=",
"hdu",
".",
"header",
".",
... | [
99,
0
] | [
110,
23
] | python | en | ['en', 'error', 'th'] | False |
create_header | (fits_length, array_length) |
make a AARTFAAC header. Header is padded with zeros up to 512 bytes.
args:
fits_lenght (int): how long will the fits header be
array_length (int): How long will the data be
returns:
str: aartfaac header ready for transmission.
|
make a AARTFAAC header. Header is padded with zeros up to 512 bytes. | def create_header(fits_length, array_length):
"""
make a AARTFAAC header. Header is padded with zeros up to 512 bytes.
args:
fits_lenght (int): how long will the fits header be
array_length (int): How long will the data be
returns:
str: aartfaac header ready for transmission.
... | [
"def",
"create_header",
"(",
"fits_length",
",",
"array_length",
")",
":",
"# 512 - 16: Q = 8, L = 4",
"return",
"struct",
".",
"pack",
"(",
"'=QLL496x'",
",",
"CHECKSUM",
",",
"fits_length",
",",
"array_length",
")"
] | [
113,
0
] | [
125,
71
] | python | en | ['en', 'error', 'th'] | False |
make_window | (hdu) |
Construct a complete serialised image including aartfaac header
args:
hdu (astropy.io.fits.HDUList): the first header
returns:
str: serialised fits file
|
Construct a complete serialised image including aartfaac header | def make_window(hdu):
"""
Construct a complete serialised image including aartfaac header
args:
hdu (astropy.io.fits.HDUList): the first header
returns:
str: serialised fits file
"""
result = StringIO.StringIO()
data, fits_header = serialize_hdu(hdu)
header = create_head... | [
"def",
"make_window",
"(",
"hdu",
")",
":",
"result",
"=",
"StringIO",
".",
"StringIO",
"(",
")",
"data",
",",
"fits_header",
"=",
"serialize_hdu",
"(",
"hdu",
")",
"header",
"=",
"create_header",
"(",
"len",
"(",
"fits_header",
")",
",",
"len",
"(",
"... | [
128,
0
] | [
143,
28
] | python | en | ['en', 'error', 'th'] | False |
client_handler | (conn, addr, freq) |
Handling a client connection. Will push a serialised fits image plus
AARTFAAC header to the connected client, triggered by an external queue
supplying timestamps.
args:
conn (socket.socket): The connection with the client
addr (str): address of the client
freq (int): the subban... |
Handling a client connection. Will push a serialised fits image plus
AARTFAAC header to the connected client, triggered by an external queue
supplying timestamps. | def client_handler(conn, addr, freq):
"""
Handling a client connection. Will push a serialised fits image plus
AARTFAAC header to the connected client, triggered by an external queue
supplying timestamps.
args:
conn (socket.socket): The connection with the client
addr (str): address... | [
"def",
"client_handler",
"(",
"conn",
",",
"addr",
",",
"freq",
")",
":",
"repeater",
"=",
"Repeater",
"(",
")",
"port",
"=",
"conn",
".",
"getsockname",
"(",
")",
"[",
"1",
"]",
"logger",
".",
"info",
"(",
"'connection from {} on {}'",
".",
"format",
... | [
146,
0
] | [
176,
31
] | python | en | ['en', 'error', 'th'] | False |
socket_listener | (port, freq) |
Will listen on a specific socket and fire of threads if a client connects.
Will try to reconnect every 5 seconds in case of connect failure.
args:
port (int): On that port to listen
freq (int): The corresponds frequency that belongs to the port
|
Will listen on a specific socket and fire of threads if a client connects.
Will try to reconnect every 5 seconds in case of connect failure. | def socket_listener(port, freq):
"""
Will listen on a specific socket and fire of threads if a client connects.
Will try to reconnect every 5 seconds in case of connect failure.
args:
port (int): On that port to listen
freq (int): The corresponds frequency that belongs to the port
"... | [
"def",
"socket_listener",
"(",
"port",
",",
"freq",
")",
":",
"# loop and sleep for 5 until we can bind",
"while",
"True",
":",
"try",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"# don't wa... | [
179,
0
] | [
214,
21
] | python | en | ['en', 'error', 'th'] | False |
timer | (queue) |
Pushes a timestamp on a Queue exactly every second.
args:
queue (Queue.Queue): a queue
|
Pushes a timestamp on a Queue exactly every second. | def timer(queue):
"""
Pushes a timestamp on a Queue exactly every second.
args:
queue (Queue.Queue): a queue
"""
while True:
# We use monotonic so the timing doesn't drift.
duty_cycle = 1 # seconds
time.sleep(duty_cycle - monotonic.monotonic() % duty_cycle)
... | [
"def",
"timer",
"(",
"queue",
")",
":",
"while",
"True",
":",
"# We use monotonic so the timing doesn't drift.",
"duty_cycle",
"=",
"1",
"# seconds",
"time",
".",
"sleep",
"(",
"duty_cycle",
"-",
"monotonic",
".",
"monotonic",
"(",
")",
"%",
"duty_cycle",
")",
... | [
217,
0
] | [
230,
22
] | python | en | ['en', 'error', 'th'] | False |
emulator | (ports=DEFAULT_PORTS, freqs=DEFAULT_FREQS) |
Run the aartfaac stream emulator. Will listen on all ports defined in ports
and change the frequency in the fits headers according to the freqs list.
Daemon function, does not return.
args:
ports (tuple): list of ints representing ports
freqs (tuple): list of frequencies
|
Run the aartfaac stream emulator. Will listen on all ports defined in ports
and change the frequency in the fits headers according to the freqs list. | def emulator(ports=DEFAULT_PORTS, freqs=DEFAULT_FREQS):
"""
Run the aartfaac stream emulator. Will listen on all ports defined in ports
and change the frequency in the fits headers according to the freqs list.
Daemon function, does not return.
args:
ports (tuple): list of ints representing... | [
"def",
"emulator",
"(",
"ports",
"=",
"DEFAULT_PORTS",
",",
"freqs",
"=",
"DEFAULT_FREQS",
")",
":",
"heartbeat_queue",
"=",
"Queue",
"(",
")",
"repeater",
"=",
"Repeater",
"(",
")",
"timer_thread",
"=",
"Thread",
"(",
"target",
"=",
"timer",
",",
"name",
... | [
233,
0
] | [
266,
21
] | python | en | ['en', 'error', 'th'] | False |
Repeater.run | (self, in_queue) |
Monitor incoming queue for message, repeat them to all subscribers
|
Monitor incoming queue for message, repeat them to all subscribers
| def run(self, in_queue):
"""
Monitor incoming queue for message, repeat them to all subscribers
"""
while True:
mesg = in_queue.get()
self.put(mesg) | [
"def",
"run",
"(",
"self",
",",
"in_queue",
")",
":",
"while",
"True",
":",
"mesg",
"=",
"in_queue",
".",
"get",
"(",
")",
"self",
".",
"put",
"(",
"mesg",
")"
] | [
41,
4
] | [
47,
26
] | python | en | ['en', 'error', 'th'] | False |
Repeater.put | (self, mesg) |
broadcast message to all subscribers
args:
mesg (object):
|
broadcast message to all subscribers | def put(self, mesg):
"""
broadcast message to all subscribers
args:
mesg (object):
"""
with self.lock:
logger.debug("relaying to {} subscribers".format(len(self.receivers)))
[r.put(mesg) for r in self.receivers] | [
"def",
"put",
"(",
"self",
",",
"mesg",
")",
":",
"with",
"self",
".",
"lock",
":",
"logger",
".",
"debug",
"(",
"\"relaying to {} subscribers\"",
".",
"format",
"(",
"len",
"(",
"self",
".",
"receivers",
")",
")",
")",
"[",
"r",
".",
"put",
"(",
"... | [
49,
4
] | [
58,
49
] | python | en | ['en', 'error', 'th'] | False |
Repeater.subscribe | (self, queue) |
Add a queue to the subscription list
args:
out_queue (Queue.Queue):
|
Add a queue to the subscription list | def subscribe(self, queue):
"""
Add a queue to the subscription list
args:
out_queue (Queue.Queue):
"""
logger.debug("subscriber")
with self.lock:
self.receivers.append(queue) | [
"def",
"subscribe",
"(",
"self",
",",
"queue",
")",
":",
"logger",
".",
"debug",
"(",
"\"subscriber\"",
")",
"with",
"self",
".",
"lock",
":",
"self",
".",
"receivers",
".",
"append",
"(",
"queue",
")"
] | [
60,
4
] | [
69,
40
] | python | en | ['en', 'error', 'th'] | False |
Repeater.unsubscribe | (self, out_queue) |
Remove a queue from the subscription list
args:
out_queue (Queue.Queue):
|
Remove a queue from the subscription list | def unsubscribe(self, out_queue):
"""
Remove a queue from the subscription list
args:
out_queue (Queue.Queue):
"""
logger.debug("unsubscriber")
with self.lock:
try:
self.receivers.remove(out_queue)
except ValueError:
... | [
"def",
"unsubscribe",
"(",
"self",
",",
"out_queue",
")",
":",
"logger",
".",
"debug",
"(",
"\"unsubscriber\"",
")",
"with",
"self",
".",
"lock",
":",
"try",
":",
"self",
".",
"receivers",
".",
"remove",
"(",
"out_queue",
")",
"except",
"ValueError",
":"... | [
71,
4
] | [
83,
49
] | python | en | ['en', 'error', 'th'] | False |
permalink | (func) |
Decorator that calls urls.reverse() to return a URL using parameters
returned by the decorated function "func".
"func" should be a function that returns a tuple in one of the
following formats:
(viewname, viewargs)
(viewname, viewargs, viewkwargs)
|
Decorator that calls urls.reverse() to return a URL using parameters
returned by the decorated function "func". | def permalink(func):
"""
Decorator that calls urls.reverse() to return a URL using parameters
returned by the decorated function "func".
"func" should be a function that returns a tuple in one of the
following formats:
(viewname, viewargs)
(viewname, viewargs, viewkwargs)
"""
... | [
"def",
"permalink",
"(",
"func",
")",
":",
"import",
"warnings",
"from",
"functools",
"import",
"wraps",
"from",
"django",
".",
"urls",
"import",
"reverse",
"from",
"django",
".",
"utils",
".",
"deprecation",
"import",
"RemovedInDjango21Warning",
"warnings",
"."... | [
31,
0
] | [
58,
16
] | python | en | ['en', 'error', 'th'] | False |
DatabaseWrapper.disable_constraint_checking | (self) |
Disables foreign key checks, primarily for use in adding rows with forward references. Always returns True,
to indicate constraint checks need to be re-enabled.
|
Disables foreign key checks, primarily for use in adding rows with forward references. Always returns True,
to indicate constraint checks need to be re-enabled.
| def disable_constraint_checking(self):
"""
Disables foreign key checks, primarily for use in adding rows with forward references. Always returns True,
to indicate constraint checks need to be re-enabled.
"""
self.cursor().execute('SET foreign_key_checks=0')
return True | [
"def",
"disable_constraint_checking",
"(",
"self",
")",
":",
"self",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"'SET foreign_key_checks=0'",
")",
"return",
"True"
] | [
308,
4
] | [
314,
19
] | python | en | ['en', 'error', 'th'] | False |
DatabaseWrapper.enable_constraint_checking | (self) |
Re-enable foreign key checks after they have been disabled.
|
Re-enable foreign key checks after they have been disabled.
| def enable_constraint_checking(self):
"""
Re-enable foreign key checks after they have been disabled.
"""
# Override needs_rollback in case constraint_checks_disabled is
# nested inside transaction.atomic.
self.needs_rollback, needs_rollback = False, self.needs_rollback
... | [
"def",
"enable_constraint_checking",
"(",
"self",
")",
":",
"# Override needs_rollback in case constraint_checks_disabled is",
"# nested inside transaction.atomic.",
"self",
".",
"needs_rollback",
",",
"needs_rollback",
"=",
"False",
",",
"self",
".",
"needs_rollback",
"try",
... | [
316,
4
] | [
326,
48
] | python | en | ['en', 'error', 'th'] | False |
DatabaseWrapper.check_constraints | (self, table_names=None) |
Checks each table name in `table_names` for rows with invalid foreign
key references. This method is intended to be used in conjunction with
`disable_constraint_checking()` and `enable_constraint_checking()`, to
determine if rows with invalid references were entered while constraint
... |
Checks each table name in `table_names` for rows with invalid foreign
key references. This method is intended to be used in conjunction with
`disable_constraint_checking()` and `enable_constraint_checking()`, to
determine if rows with invalid references were entered while constraint
... | def check_constraints(self, table_names=None):
"""
Checks each table name in `table_names` for rows with invalid foreign
key references. This method is intended to be used in conjunction with
`disable_constraint_checking()` and `enable_constraint_checking()`, to
determine if rows... | [
"def",
"check_constraints",
"(",
"self",
",",
"table_names",
"=",
"None",
")",
":",
"cursor",
"=",
"self",
".",
"cursor",
"(",
")",
"if",
"table_names",
"is",
"None",
":",
"table_names",
"=",
"self",
".",
"introspection",
".",
"table_names",
"(",
"cursor",... | [
328,
4
] | [
372,
21
] | python | en | ['en', 'error', 'th'] | False |
printc | (text, color) | Print in color. | Print in color. | def printc(text, color):
"""Print in color."""
if sys.stdout.isatty():
print("\033["+codeCodes[color]+"m"+text+"\033[0m")
else:
print(text) | [
"def",
"printc",
"(",
"text",
",",
"color",
")",
":",
"if",
"sys",
".",
"stdout",
".",
"isatty",
"(",
")",
":",
"print",
"(",
"\"\\033[\"",
"+",
"codeCodes",
"[",
"color",
"]",
"+",
"\"m\"",
"+",
"text",
"+",
"\"\\033[0m\"",
")",
"else",
":",
"prin... | [
34,
0
] | [
39,
19
] | python | en | ['en', 'en', 'en'] | True |
UnifiedJobTemplate.is_successful | (self) | An unified_job_template is considered successful when:
1) status == 'successful'
2) not last_update_failed
3) last_updated
| An unified_job_template is considered successful when:
1) status == 'successful'
2) not last_update_failed
3) last_updated
| def is_successful(self):
"""An unified_job_template is considered successful when:
1) status == 'successful'
2) not last_update_failed
3) last_updated
"""
return super(UnifiedJobTemplate, self).is_successful and not self.last_update_failed and self.last_updated is not Non... | [
"def",
"is_successful",
"(",
"self",
")",
":",
"return",
"super",
"(",
"UnifiedJobTemplate",
",",
"self",
")",
".",
"is_successful",
"and",
"not",
"self",
".",
"last_update_failed",
"and",
"self",
".",
"last_updated",
"is",
"not",
"None"
] | [
63,
4
] | [
69,
126
] | python | en | ['en', 'en', 'en'] | True |
TestOne2Many.tearDown | (self) | remove all stuff after the test has been run | remove all stuff after the test has been run | def tearDown(self):
"""remove all stuff after the test has been run"""
tkp.db.rollback() | [
"def",
"tearDown",
"(",
"self",
")",
":",
"tkp",
".",
"db",
".",
"rollback",
"(",
")"
] | [
748,
4
] | [
750,
25
] | python | en | ['en', 'en', 'en'] | True |
TestMany2One.tearDown | (self) | remove all stuff after the test has been run | remove all stuff after the test has been run | def tearDown(self):
"""remove all stuff after the test has been run"""
tkp.db.rollback() | [
"def",
"tearDown",
"(",
"self",
")",
":",
"tkp",
".",
"db",
".",
"rollback",
"(",
")"
] | [
938,
4
] | [
940,
25
] | python | en | ['en', 'en', 'en'] | True |
TestMany2Many.tearDown | (self) | remove all stuff after the test has been run | remove all stuff after the test has been run | def tearDown(self):
"""remove all stuff after the test has been run"""
tkp.db.rollback() | [
"def",
"tearDown",
"(",
"self",
")",
":",
"tkp",
".",
"db",
".",
"rollback",
"(",
")"
] | [
1130,
4
] | [
1132,
25
] | python | en | ['en', 'en', 'en'] | True |
TestMany2Many.insert_many_to_many_sources | (self, dataset, im_params,
image1_srcs, image2_srcs, dr_limit) |
Load 2 images in the database according to im_params,
then populate with image1_srcs / image2_srcs accordingly, and
associate.
Return dicts representing relevant runcat, and extractedsource
entries. The 'runcat' dicts have a nested 'assoc' dict added,
represent... |
Load 2 images in the database according to im_params,
then populate with image1_srcs / image2_srcs accordingly, and
associate.
Return dicts representing relevant runcat, and extractedsource
entries. The 'runcat' dicts have a nested 'assoc' dict added,
represent... | def insert_many_to_many_sources(self, dataset, im_params,
image1_srcs, image2_srcs, dr_limit):
"""
Load 2 images in the database according to im_params,
then populate with image1_srcs / image2_srcs accordingly, and
associate.
Return d... | [
"def",
"insert_many_to_many_sources",
"(",
"self",
",",
"dataset",
",",
"im_params",
",",
"image1_srcs",
",",
"image2_srcs",
",",
"dr_limit",
")",
":",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"im_params",
")",
",",
"2",
")",
"# Check that we have chosen suf... | [
1135,
4
] | [
1220,
32
] | python | en | ['en', 'error', 'th'] | False |
TestMany2Many.summarise_associations | (runcat, extracted) | Print a nice summary of the results dictionaries
(as ouput by insert_many_to_many_sources) | Print a nice summary of the results dictionaries
(as ouput by insert_many_to_many_sources) | def summarise_associations(runcat, extracted):
"""Print a nice summary of the results dictionaries
(as ouput by insert_many_to_many_sources)"""
print "\nSources input:"
for ex in sorted(extracted, key=lambda x:x['image']):
print ', '.join(kw + ':' + str(ex[kw]) for kw in
... | [
"def",
"summarise_associations",
"(",
"runcat",
",",
"extracted",
")",
":",
"print",
"\"\\nSources input:\"",
"for",
"ex",
"in",
"sorted",
"(",
"extracted",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"'image'",
"]",
")",
":",
"print",
"', '",
".",
"j... | [
1223,
4
] | [
1241,
13
] | python | en | ['en', 'en', 'en'] | True |
TestMany2Many.test_many2many_reduced_to_two_1_to_many_one_1to1 | (self) | This handles the case where we have two sources in first image
and two in second image.
The two sources in the second image can be associated with one source
from the first image, whereas the other source is not assocaited with
any from the second image.
Both sources in the sec... | This handles the case where we have two sources in first image
and two in second image.
The two sources in the second image can be associated with one source
from the first image, whereas the other source is not assocaited with
any from the second image.
Both sources in the sec... | def test_many2many_reduced_to_two_1_to_many_one_1to1(self):
"""This handles the case where we have two sources in first image
and two in second image.
The two sources in the second image can be associated with one source
from the first image, whereas the other source is not assocaited w... | [
"def",
"test_many2many_reduced_to_two_1_to_many_one_1to1",
"(",
"self",
")",
":",
"self",
".",
"picture",
"=",
"r\"\"\"\n 3\n o\n \\\n 1 * * 2\n /\n o\n 4\n \"\"\"",
"dataset",
"=",
"DataSet",
"(",... | [
1245,
4
] | [
1337,
50
] | python | en | ['en', 'en', 'en'] | True |
TestMany2Many.test_many2many_reduced_to_two_1to1 | (self) | This handles the case where we have two sources in first image
and two in second image.
Both sources in the second image can be associated with both sources
in the first image. However, checking the DR radius reduces the
associations to be two of the type 1 to 1.
The runcat will ... | This handles the case where we have two sources in first image
and two in second image.
Both sources in the second image can be associated with both sources
in the first image. However, checking the DR radius reduces the
associations to be two of the type 1 to 1.
The runcat will ... | def test_many2many_reduced_to_two_1to1(self):
"""This handles the case where we have two sources in first image
and two in second image.
Both sources in the second image can be associated with both sources
in the first image. However, checking the DR radius reduces the
associatio... | [
"def",
"test_many2many_reduced_to_two_1to1",
"(",
"self",
")",
":",
"dataset",
"=",
"DataSet",
"(",
"data",
"=",
"{",
"'description'",
":",
"'assoc test set: n-m, '",
"+",
"self",
".",
"_testMethodName",
"}",
")",
"self",
".",
"picture",
"=",
"r\"\"\"\n ... | [
1340,
4
] | [
1413,
50
] | python | en | ['en', 'en', 'en'] | True |
TestMany2Many.test_many2many_pathological_equilateral_rhombus | (self) | This handles the case where we have two sources in first image and
two in second image.
The two sources in the second image are *both equidistant from both
of the original sources*.
In this case, it is not clear how to 'prune' the candidate associations,
and our SQL breaks. The ... | This handles the case where we have two sources in first image and
two in second image.
The two sources in the second image are *both equidistant from both
of the original sources*. | def test_many2many_pathological_equilateral_rhombus(self):
"""This handles the case where we have two sources in first image and
two in second image.
The two sources in the second image are *both equidistant from both
of the original sources*.
In this case, it is not clear how t... | [
"def",
"test_many2many_pathological_equilateral_rhombus",
"(",
"self",
")",
":",
"dataset",
"=",
"DataSet",
"(",
"data",
"=",
"{",
"'description'",
":",
"'assoc test set: n-m, '",
"+",
"self",
".",
"_testMethodName",
"}",
")",
"# So in this case, we have 2 sources in imag... | [
1415,
4
] | [
1462,
67
] | python | en | ['en', 'en', 'en'] | True |
WriteHmap | (output_name, filelist) | Generates a header map based on |filelist|.
Per Mark Mentovai:
A header map is structured essentially as a hash table, keyed by names used
in #includes, and providing pathnames to the actual files.
The implementation below and the comment above comes from inspecting:
http://www.opensource.apple.com/so... | Generates a header map based on |filelist|. | def WriteHmap(output_name, filelist):
"""Generates a header map based on |filelist|.
Per Mark Mentovai:
A header map is structured essentially as a hash table, keyed by names used
in #includes, and providing pathnames to the actual files.
The implementation below and the comment above comes from inspe... | [
"def",
"WriteHmap",
"(",
"output_name",
",",
"filelist",
")",
":",
"magic",
"=",
"1751998832",
"version",
"=",
"1",
"_reserved",
"=",
"0",
"count",
"=",
"len",
"(",
"filelist",
")",
"capacity",
"=",
"NextGreaterPowerOf2",
"(",
"count",
")",
"strings_offset",... | [
700,
0
] | [
771,
46
] | python | en | ['en', 'en', 'en'] | True |
MacTool.Dispatch | (self, args) | Dispatches a string command to a method. | Dispatches a string command to a method. | def Dispatch(self, args):
"""Dispatches a string command to a method."""
if len(args) < 1:
raise Exception("Not enough arguments")
method = "Exec%s" % self._CommandifyName(args[0])
return getattr(self, method)(*args[1:]) | [
"def",
"Dispatch",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"1",
":",
"raise",
"Exception",
"(",
"\"Not enough arguments\"",
")",
"method",
"=",
"\"Exec%s\"",
"%",
"self",
".",
"_CommandifyName",
"(",
"args",
"[",
"0",
"]... | [
39,
4
] | [
45,
47
] | 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.