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
SecureTransportContext.check_hostname
(self, value)
SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file.
SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file.
def check_hostname(self, value): """ SecureTransport cannot have its hostname checking disabled. For more, see the comment on getpeercert() in this file. """ pass
[ "def", "check_hostname", "(", "self", ",", "value", ")", ":", "pass" ]
[ 809, 4 ]
[ 814, 12 ]
python
en
['en', 'error', 'th']
False
SecureTransportContext.set_alpn_protocols
(self, protocols)
Sets the ALPN protocols that will later be set on the context. Raises a NotImplementedError if ALPN is not supported.
Sets the ALPN protocols that will later be set on the context.
def set_alpn_protocols(self, protocols): """ Sets the ALPN protocols that will later be set on the context. Raises a NotImplementedError if ALPN is not supported. """ if not hasattr(Security, "SSLSetALPNProtocols"): raise NotImplementedError( "SecureT...
[ "def", "set_alpn_protocols", "(", "self", ",", "protocols", ")", ":", "if", "not", "hasattr", "(", "Security", ",", "\"SSLSetALPNProtocols\"", ")", ":", "raise", "NotImplementedError", "(", "\"SecureTransport supports ALPN only in macOS 10.12+\"", ")", "self", ".", "_...
[ 876, 4 ]
[ 886, 72 ]
python
en
['en', 'error', 'th']
False
nagios_from_file
(results_file: str)
Returns a nagios-appropriate string and return code obtained by parsing the desired file on disk. The file on disk should be of format %s|%s % (timestamp, nagios_string) This file is created by various nagios checking cron jobs such as check-rabbitmq-queues and check-rabbitmq-consumers
Returns a nagios-appropriate string and return code obtained by parsing the desired file on disk. The file on disk should be of format
def nagios_from_file(results_file: str) -> Tuple[int, str]: """Returns a nagios-appropriate string and return code obtained by parsing the desired file on disk. The file on disk should be of format %s|%s % (timestamp, nagios_string) This file is created by various nagios checking cron jobs such as ...
[ "def", "nagios_from_file", "(", "results_file", ":", "str", ")", "->", "Tuple", "[", "int", ",", "str", "]", ":", "try", ":", "with", "open", "(", "results_file", ")", "as", "f", ":", "data", "=", "f", ".", "read", "(", ")", ".", "strip", "(", ")...
[ 4, 0 ]
[ 40, 36 ]
python
en
['en', 'en', 'en']
True
TestExtractPanelDefinitionsFromModelAdmin.test_model_edit_handler
(self)
loads the 'create' view and verifies that form fields are returned which have been defined via model Person.edit_handler
loads the 'create' view and verifies that form fields are returned which have been defined via model Person.edit_handler
def test_model_edit_handler(self): """loads the 'create' view and verifies that form fields are returned which have been defined via model Person.edit_handler""" response = self.client.get('/admin/modeladmintest/person/create/') self.assertEqual( [field_name for field_name in...
[ "def", "test_model_edit_handler", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/admin/modeladmintest/person/create/'", ")", "self", ".", "assertEqual", "(", "[", "field_name", "for", "field_name", "in", "response", ".", "cont...
[ 19, 4 ]
[ 26, 9 ]
python
en
['en', 'en', 'en']
True
TestExtractPanelDefinitionsFromModelAdmin.test_model_form_view_edit_handler_called
(self, mock_modelformview_get_edit_handler)
loads the ``create`` view and verifies that modelformview edit_handler is called
loads the ``create`` view and verifies that modelformview edit_handler is called
def test_model_form_view_edit_handler_called(self, mock_modelformview_get_edit_handler): """loads the ``create`` view and verifies that modelformview edit_handler is called""" self.client.get('/admin/modeladmintest/person/create/') self.assertGreater(len(mock_modelformview_get_edit_handler.call_...
[ "def", "test_model_form_view_edit_handler_called", "(", "self", ",", "mock_modelformview_get_edit_handler", ")", ":", "self", ".", "client", ".", "get", "(", "'/admin/modeladmintest/person/create/'", ")", "self", ".", "assertGreater", "(", "len", "(", "mock_modelformview_...
[ 29, 4 ]
[ 32, 86 ]
python
en
['en', 'en', 'en']
True
TestExtractPanelDefinitionsFromModelAdmin.test_model_admin_edit_handler_called
(self, mock_modeladmin_get_edit_handler)
loads the ``create`` view and verifies that modeladmin edit_handler is called
loads the ``create`` view and verifies that modeladmin edit_handler is called
def test_model_admin_edit_handler_called(self, mock_modeladmin_get_edit_handler): """loads the ``create`` view and verifies that modeladmin edit_handler is called""" # constructing the request in order to be able to assert it request = self.factory.get('/admin/modeladmintest/person/create/') ...
[ "def", "test_model_admin_edit_handler_called", "(", "self", ",", "mock_modeladmin_get_edit_handler", ")", ":", "# constructing the request in order to be able to assert it", "request", "=", "self", ".", "factory", ".", "get", "(", "'/admin/modeladmintest/person/create/'", ")", ...
[ 35, 4 ]
[ 48, 57 ]
python
en
['en', 'en', 'en']
True
TestExtractPanelDefinitionsFromModelAdmin.test_model_panels
(self)
loads the 'create' view and verifies that form fields are returned which have been defined via model Friend.panels
loads the 'create' view and verifies that form fields are returned which have been defined via model Friend.panels
def test_model_panels(self): """loads the 'create' view and verifies that form fields are returned which have been defined via model Friend.panels""" response = self.client.get('/admin/modeladmintest/friend/create/') self.assertEqual( [field_name for field_name in response.co...
[ "def", "test_model_panels", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/admin/modeladmintest/friend/create/'", ")", "self", ".", "assertEqual", "(", "[", "field_name", "for", "field_name", "in", "response", ".", "context", ...
[ 50, 4 ]
[ 57, 9 ]
python
en
['en', 'en', 'en']
True
TestExtractPanelDefinitionsFromModelAdmin.test_model_admin_edit_handler
(self)
loads the 'create' view and verifies that form fields are returned which have been defined via model VisitorAdmin.edit_handler
loads the 'create' view and verifies that form fields are returned which have been defined via model VisitorAdmin.edit_handler
def test_model_admin_edit_handler(self): """loads the 'create' view and verifies that form fields are returned which have been defined via model VisitorAdmin.edit_handler""" response = self.client.get('/admin/modeladmintest/visitor/create/') self.assertEqual( [field_name for ...
[ "def", "test_model_admin_edit_handler", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/admin/modeladmintest/visitor/create/'", ")", "self", ".", "assertEqual", "(", "[", "field_name", "for", "field_name", "in", "response", ".", ...
[ 59, 4 ]
[ 66, 9 ]
python
en
['en', 'en', 'en']
True
TestExtractPanelDefinitionsFromModelAdmin.test_model_admin_panels
(self)
loads the 'create' view and verifies that form fields are returned which have been defined via model ContributorAdmin.panels
loads the 'create' view and verifies that form fields are returned which have been defined via model ContributorAdmin.panels
def test_model_admin_panels(self): """loads the 'create' view and verifies that form fields are returned which have been defined via model ContributorAdmin.panels""" response = self.client.get('/admin/modeladmintest/contributor/create/') self.assertEqual( [field_name for fiel...
[ "def", "test_model_admin_panels", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/admin/modeladmintest/contributor/create/'", ")", "self", ".", "assertEqual", "(", "[", "field_name", "for", "field_name", "in", "response", ".", ...
[ 68, 4 ]
[ 75, 9 ]
python
en
['en', 'en', 'en']
True
TestExtractPanelDefinitionsFromModelAdmin.test_model_admin_panel_edit_handler_priority
(self)
verifies that model admin panels are preferred over model panels
verifies that model admin panels are preferred over model panels
def test_model_admin_panel_edit_handler_priority(self): """verifies that model admin panels are preferred over model panels""" # check if Person panel or edit_handler definition is used for # form creation, since PersonAdmin has neither panels nor an # edit_handler defined model_...
[ "def", "test_model_admin_panel_edit_handler_priority", "(", "self", ")", ":", "# check if Person panel or edit_handler definition is used for", "# form creation, since PersonAdmin has neither panels nor an", "# edit_handler defined", "model_admin", "=", "PersonAdmin", "(", ")", "edit_han...
[ 77, 4 ]
[ 130, 9 ]
python
en
['en', 'en', 'en']
True
authenticate_with_password
(request, page_view_restriction_id, page_id)
Handle a submission of PasswordViewRestrictionForm to grant view access over a subtree that is protected by a PageViewRestriction
Handle a submission of PasswordViewRestrictionForm to grant view access over a subtree that is protected by a PageViewRestriction
def authenticate_with_password(request, page_view_restriction_id, page_id): """ Handle a submission of PasswordViewRestrictionForm to grant view access over a subtree that is protected by a PageViewRestriction """ restriction = get_object_or_404(PageViewRestriction, id=page_view_restriction_id) ...
[ "def", "authenticate_with_password", "(", "request", ",", "page_view_restriction_id", ",", "page_id", ")", ":", "restriction", "=", "get_object_or_404", "(", "PageViewRestriction", ",", "id", "=", "page_view_restriction_id", ")", "page", "=", "get_object_or_404", "(", ...
[ 28, 0 ]
[ 50, 75 ]
python
en
['en', 'error', 'th']
False
_fd
(f)
Get a filedescriptor from something which could be a file or an fd.
Get a filedescriptor from something which could be a file or an fd.
def _fd(f): """Get a filedescriptor from something which could be a file or an fd.""" return f.fileno() if hasattr(f, 'fileno') else f
[ "def", "_fd", "(", "f", ")", ":", "return", "f", ".", "fileno", "(", ")", "if", "hasattr", "(", "f", ",", "'fileno'", ")", "else", "f" ]
[ 23, 0 ]
[ 25, 52 ]
python
en
['en', 'en', 'en']
True
deprecate_current_app
(func)
Handle deprecation of the current_app parameter of the views.
Handle deprecation of the current_app parameter of the views.
def deprecate_current_app(func): """ Handle deprecation of the current_app parameter of the views. """ @functools.wraps(func) def inner(*args, **kwargs): if 'current_app' in kwargs: warnings.warn( "Passing `current_app` as a keyword argument is deprecated. " ...
[ "def", "deprecate_current_app", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'current_app'", "in", "kwargs", ":", "warnings", ".", "warn", "(", "\...
[ 36, 0 ]
[ 54, 16 ]
python
en
['en', 'error', 'th']
False
logout_then_login
(request, login_url=None, extra_context=_sentinel)
Logs out the user if they are logged in. Then redirects to the log-in page.
Logs out the user if they are logged in. Then redirects to the log-in page.
def logout_then_login(request, login_url=None, extra_context=_sentinel): """ Logs out the user if they are logged in. Then redirects to the log-in page. """ if extra_context is not _sentinel: warnings.warn( "The unused `extra_context` parameter to `logout_then_login` " "i...
[ "def", "logout_then_login", "(", "request", ",", "login_url", "=", "None", ",", "extra_context", "=", "_sentinel", ")", ":", "if", "extra_context", "is", "not", "_sentinel", ":", "warnings", ".", "warn", "(", "\"The unused `extra_context` parameter to `logout_then_log...
[ 210, 0 ]
[ 223, 59 ]
python
en
['en', 'error', 'th']
False
redirect_to_login
(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME)
Redirects the user to the login page, passing the given 'next' page
Redirects the user to the login page, passing the given 'next' page
def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """ Redirects the user to the login page, passing the given 'next' page """ resolved_url = resolve_url(login_url or settings.LOGIN_URL) login_url_parts = list(urlparse(resolved_url)) if r...
[ "def", "redirect_to_login", "(", "next", ",", "login_url", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ")", ":", "resolved_url", "=", "resolve_url", "(", "login_url", "or", "settings", ".", "LOGIN_URL", ")", "login_url_parts", "=", "list",...
[ 226, 0 ]
[ 239, 60 ]
python
en
['en', 'error', 'th']
False
password_reset_confirm
(request, uidb64=None, token=None, template_name='registration/password_reset_confirm.html', token_generator=default_token_generator, set_password_form=SetPasswordForm, post_reset_redirect=None, ...
View that checks the hash in a password reset link and presents a form for entering a new password.
View that checks the hash in a password reset link and presents a form for entering a new password.
def password_reset_confirm(request, uidb64=None, token=None, template_name='registration/password_reset_confirm.html', token_generator=default_token_generator, set_password_form=SetPasswordForm, post_reset_redire...
[ "def", "password_reset_confirm", "(", "request", ",", "uidb64", "=", "None", ",", "token", "=", "None", ",", "template_name", "=", "'registration/password_reset_confirm.html'", ",", "token_generator", "=", "default_token_generator", ",", "set_password_form", "=", "SetPa...
[ 316, 0 ]
[ 363, 60 ]
python
en
['en', 'error', 'th']
False
LoginView.get_success_url
(self)
Ensure the user-originating redirection URL is safe.
Ensure the user-originating redirection URL is safe.
def get_success_url(self): """Ensure the user-originating redirection URL is safe.""" redirect_to = self.request.POST.get( self.redirect_field_name, self.request.GET.get(self.redirect_field_name, '') ) url_is_safe = is_safe_url( url=redirect_to, ...
[ "def", "get_success_url", "(", "self", ")", ":", "redirect_to", "=", "self", ".", "request", ".", "POST", ".", "get", "(", "self", ".", "redirect_field_name", ",", "self", ".", "request", ".", "GET", ".", "get", "(", "self", ".", "redirect_field_name", "...
[ 91, 4 ]
[ 104, 26 ]
python
en
['en', 'en', 'en']
True
LoginView.form_valid
(self, form)
Security check complete. Log the user in.
Security check complete. Log the user in.
def form_valid(self, form): """Security check complete. Log the user in.""" auth_login(self.request, form.get_user()) return HttpResponseRedirect(self.get_success_url())
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "auth_login", "(", "self", ".", "request", ",", "form", ".", "get_user", "(", ")", ")", "return", "HttpResponseRedirect", "(", "self", ".", "get_success_url", "(", ")", ")" ]
[ 114, 4 ]
[ 117, 59 ]
python
en
['en', 'en', 'en']
True
RecordingHandler.emit
(self, record)
:type record: logging.LogRecord :return:
def emit(self, record): """ :type record: logging.LogRecord :return: """ if record.levelno == logging.INFO: self.write_log(self.info_buff, record.msg, record.args) elif record.levelno == logging.ERROR: self.write_log(self.err_buff, record.msg, rec...
[ "def", "emit", "(", "self", ",", "record", ")", ":", "if", "record", ".", "levelno", "==", "logging", ".", "INFO", ":", "self", ".", "write_log", "(", "self", ".", "info_buff", ",", "record", ".", "msg", ",", "record", ".", "args", ")", "elif", "re...
[ 162, 4 ]
[ 175, 68 ]
python
en
['en', 'error', 'th']
False
PipInstaller.prepare
(self)
pip-installer expect follow definition: - service pip-install temp: false # install to ~/.bzt instead of artifacts dir packages: - first_pkg - second_pkg
pip-installer expect follow definition: - service pip-install temp: false # install to ~/.bzt instead of artifacts dir packages: - first_pkg - second_pkg
def prepare(self): """ pip-installer expect follow definition: - service pip-install temp: false # install to ~/.bzt instead of artifacts dir packages: - first_pkg - second_pkg """ self.packages = self.parameters.get("packages", self.pack...
[ "def", "prepare", "(", "self", ")", ":", "self", ".", "packages", "=", "self", ".", "parameters", ".", "get", "(", "\"packages\"", ",", "self", ".", "packages", ")", "# todo: add versions (dict format?)", "if", "not", "self", ".", "packages", ":", "return", ...
[ 81, 4 ]
[ 109, 36 ]
python
en
['en', 'error', 'th']
False
check_union
(allowed_type_funcs: Collection[Validator[ResultT]])
Use this validator if an argument is of a variable type (e.g. processing properties that might be strings or booleans). `allowed_type_funcs`: the check_* validator functions for the possible data types for this variable.
Use this validator if an argument is of a variable type (e.g. processing properties that might be strings or booleans).
def check_union(allowed_type_funcs: Collection[Validator[ResultT]]) -> Validator[ResultT]: """ Use this validator if an argument is of a variable type (e.g. processing properties that might be strings or booleans). `allowed_type_funcs`: the check_* validator functions for the possible data types fo...
[ "def", "check_union", "(", "allowed_type_funcs", ":", "Collection", "[", "Validator", "[", "ResultT", "]", "]", ")", "->", "Validator", "[", "ResultT", "]", ":", "def", "enumerated_type_check", "(", "var_name", ":", "str", ",", "val", ":", "object", ")", "...
[ 307, 0 ]
[ 324, 32 ]
python
en
['en', 'error', 'th']
False
validate_select_field_data
(field_data: ProfileFieldData)
This function is used to validate the data sent to the server while creating/editing choices of the choice field in Organization settings.
This function is used to validate the data sent to the server while creating/editing choices of the choice field in Organization settings.
def validate_select_field_data(field_data: ProfileFieldData) -> Dict[str, Dict[str, str]]: """ This function is used to validate the data sent to the server while creating/editing choices of the choice field in Organization settings. """ validator = check_dict_only( [ ("text", ch...
[ "def", "validate_select_field_data", "(", "field_data", ":", "ProfileFieldData", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", ":", "validator", "=", "check_dict_only", "(", "[", "(", "\"text\"", ",", "check_required_string", ...
[ 372, 0 ]
[ 391, 54 ]
python
en
['en', 'error', 'th']
False
validate_select_field
(var_name: str, field_data: str, value: object)
This function is used to validate the value selected by the user against a choice field. This is not used to validate admin data.
This function is used to validate the value selected by the user against a choice field. This is not used to validate admin data.
def validate_select_field(var_name: str, field_data: str, value: object) -> str: """ This function is used to validate the value selected by the user against a choice field. This is not used to validate admin data. """ s = check_string(var_name, value) field_data_dict = orjson.loads(field_data) ...
[ "def", "validate_select_field", "(", "var_name", ":", "str", ",", "field_data", ":", "str", ",", "value", ":", "object", ")", "->", "str", ":", "s", "=", "check_string", "(", "var_name", ",", "value", ")", "field_data_dict", "=", "orjson", ".", "loads", ...
[ 394, 0 ]
[ 404, 12 ]
python
en
['en', 'error', 'th']
False
process_identifiers
(l)
process_identifiers - process all identifiers and modify them to have consistent names across all platforms; specifically across ELF and MachO. For example, MachO inserts an additional understore at the beginning of names. This function removes that.
process_identifiers - process all identifiers and modify them to have consistent names across all platforms; specifically across ELF and MachO. For example, MachO inserts an additional understore at the beginning of names. This function removes that.
def process_identifiers(l): """ process_identifiers - process all identifiers and modify them to have consistent names across all platforms; specifically across ELF and MachO. For example, MachO inserts an additional understore at the beginning of names. This function removes that. """ parts...
[ "def", "process_identifiers", "(", "l", ")", ":", "parts", "=", "re", ".", "split", "(", "r'([a-zA-Z0-9_]+)'", ",", "l", ")", "new_line", "=", "''", "for", "tk", "in", "parts", ":", "if", "is_identifier", "(", "tk", ")", ":", "if", "tk", ".", "starts...
[ 63, 0 ]
[ 80, 19 ]
python
en
['en', 'error', 'th']
False
process_asm
(asm)
Strip the ASM of unwanted directives and lines
Strip the ASM of unwanted directives and lines
def process_asm(asm): """ Strip the ASM of unwanted directives and lines """ new_contents = '' asm = transform_labels(asm) # TODO: Add more things we want to remove discard_regexes = [ re.compile("\s+\..*$"), # directive re.compile("\s*#(NO_APP|APP)$"), #inline ASM r...
[ "def", "process_asm", "(", "asm", ")", ":", "new_contents", "=", "''", "asm", "=", "transform_labels", "(", "asm", ")", "# TODO: Add more things we want to remove", "discard_regexes", "=", "[", "re", ".", "compile", "(", "\"\\s+\\..*$\"", ")", ",", "# directive", ...
[ 83, 0 ]
[ 120, 23 ]
python
en
['en', 'error', 'th']
False
parse_tag
(tag)
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances. Returning a set is required due to the possibility that the tag is a compressed tag set.
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
def parse_tag(tag): # type: (str) -> FrozenSet[Tag] """ Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances. Returning a set is required due to the possibility that the tag is a compressed tag set. """ tags = set() interpreters, abis, platforms = tag.split("-...
[ "def", "parse_tag", "(", "tag", ")", ":", "# type: (str) -> FrozenSet[Tag]", "tags", "=", "set", "(", ")", "interpreters", ",", "abis", ",", "platforms", "=", "tag", ".", "split", "(", "\"-\"", ")", "for", "interpreter", "in", "interpreters", ".", "split", ...
[ 114, 0 ]
[ 128, 26 ]
python
en
['en', 'error', 'th']
False
_warn_keyword_parameter
(func_name, kwargs)
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
def _warn_keyword_parameter(func_name, kwargs): # type: (str, Dict[str, bool]) -> bool """ Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only. """ if not kwargs: return False elif len(kwargs) > 1 or "warn" not in kwargs: kwargs.pop("warn", None) ...
[ "def", "_warn_keyword_parameter", "(", "func_name", ",", "kwargs", ")", ":", "# type: (str, Dict[str, bool]) -> bool", "if", "not", "kwargs", ":", "return", "False", "elif", "len", "(", "kwargs", ")", ">", "1", "or", "\"warn\"", "not", "in", "kwargs", ":", "kw...
[ 131, 0 ]
[ 144, 25 ]
python
en
['en', 'error', 'th']
False
_abi3_applies
(python_version)
Determine if the Python version supports abi3. PEP 384 was first implemented in Python 3.2.
Determine if the Python version supports abi3.
def _abi3_applies(python_version): # type: (PythonVersion) -> bool """ Determine if the Python version supports abi3. PEP 384 was first implemented in Python 3.2. """ return len(python_version) > 1 and tuple(python_version) >= (3, 2)
[ "def", "_abi3_applies", "(", "python_version", ")", ":", "# type: (PythonVersion) -> bool", "return", "len", "(", "python_version", ")", ">", "1", "and", "tuple", "(", "python_version", ")", ">=", "(", "3", ",", "2", ")" ]
[ 162, 0 ]
[ 169, 70 ]
python
en
['en', 'error', 'th']
False
cpython_tags
( python_version=None, # type: Optional[PythonVersion] abis=None, # type: Optional[Iterable[str]] platforms=None, # type: Optional[Iterable[str]] **kwargs # type: bool )
Yields the tags for a CPython interpreter. The tags consist of: - cp<python_version>-<abi>-<platform> - cp<python_version>-abi3-<platform> - cp<python_version>-none-<platform> - cp<less than python_version>-abi3-<platform> # Older Python versions down to 3.2. If python_version only speci...
Yields the tags for a CPython interpreter.
def cpython_tags( python_version=None, # type: Optional[PythonVersion] abis=None, # type: Optional[Iterable[str]] platforms=None, # type: Optional[Iterable[str]] **kwargs # type: bool ): # type: (...) -> Iterator[Tag] """ Yields the tags for a CPython interpreter. The tags consist o...
[ "def", "cpython_tags", "(", "python_version", "=", "None", ",", "# type: Optional[PythonVersion]", "abis", "=", "None", ",", "# type: Optional[Iterable[str]]", "platforms", "=", "None", ",", "# type: Optional[Iterable[str]]", "*", "*", "kwargs", "# type: bool", ")", ":"...
[ 209, 0 ]
[ 266, 57 ]
python
en
['en', 'error', 'th']
False
generic_tags
( interpreter=None, # type: Optional[str] abis=None, # type: Optional[Iterable[str]] platforms=None, # type: Optional[Iterable[str]] **kwargs # type: bool )
Yields the tags for a generic interpreter. The tags consist of: - <interpreter>-<abi>-<platform> The "none" ABI will be added if it was not explicitly provided.
Yields the tags for a generic interpreter.
def generic_tags( interpreter=None, # type: Optional[str] abis=None, # type: Optional[Iterable[str]] platforms=None, # type: Optional[Iterable[str]] **kwargs # type: bool ): # type: (...) -> Iterator[Tag] """ Yields the tags for a generic interpreter. The tags consist of: - <int...
[ "def", "generic_tags", "(", "interpreter", "=", "None", ",", "# type: Optional[str]", "abis", "=", "None", ",", "# type: Optional[Iterable[str]]", "platforms", "=", "None", ",", "# type: Optional[Iterable[str]]", "*", "*", "kwargs", "# type: bool", ")", ":", "# type: ...
[ 276, 0 ]
[ 304, 50 ]
python
en
['en', 'error', 'th']
False
_py_interpreter_range
(py_version)
Yields Python versions in descending order. After the latest version, the major-only version will be yielded, and then all previous versions of that major version.
Yields Python versions in descending order.
def _py_interpreter_range(py_version): # type: (PythonVersion) -> Iterator[str] """ Yields Python versions in descending order. After the latest version, the major-only version will be yielded, and then all previous versions of that major version. """ if len(py_version) > 1: yield "...
[ "def", "_py_interpreter_range", "(", "py_version", ")", ":", "# type: (PythonVersion) -> Iterator[str]", "if", "len", "(", "py_version", ")", ">", "1", ":", "yield", "\"py{version}\"", ".", "format", "(", "version", "=", "_version_nodot", "(", "py_version", "[", "...
[ 307, 0 ]
[ 320, 86 ]
python
en
['en', 'error', 'th']
False
compatible_tags
( python_version=None, # type: Optional[PythonVersion] interpreter=None, # type: Optional[str] platforms=None, # type: Optional[Iterable[str]] )
Yields the sequence of tags that are compatible with a specific version of Python. The tags consist of: - py*-none-<platform> - <interpreter>-none-any # ... if `interpreter` is provided. - py*-none-any
Yields the sequence of tags that are compatible with a specific version of Python.
def compatible_tags( python_version=None, # type: Optional[PythonVersion] interpreter=None, # type: Optional[str] platforms=None, # type: Optional[Iterable[str]] ): # type: (...) -> Iterator[Tag] """ Yields the sequence of tags that are compatible with a specific version of Python. The t...
[ "def", "compatible_tags", "(", "python_version", "=", "None", ",", "# type: Optional[PythonVersion]", "interpreter", "=", "None", ",", "# type: Optional[str]", "platforms", "=", "None", ",", "# type: Optional[Iterable[str]]", ")", ":", "# type: (...) -> Iterator[Tag]", "if"...
[ 323, 0 ]
[ 346, 41 ]
python
en
['en', 'error', 'th']
False
mac_platforms
(version=None, arch=None)
Yields the platform tags for a macOS system. The `version` parameter is a two-item tuple specifying the macOS version to generate platform tags for. The `arch` parameter is the CPU architecture to generate platform tags for. Both parameters default to the appropriate value for the current system. ...
Yields the platform tags for a macOS system.
def mac_platforms(version=None, arch=None): # type: (Optional[MacVersion], Optional[str]) -> Iterator[str] """ Yields the platform tags for a macOS system. The `version` parameter is a two-item tuple specifying the macOS version to generate platform tags for. The `arch` parameter is the CPU archite...
[ "def", "mac_platforms", "(", "version", "=", "None", ",", "arch", "=", "None", ")", ":", "# type: (Optional[MacVersion], Optional[str]) -> Iterator[str]", "version_str", ",", "_", ",", "cpu_arch", "=", "platform", ".", "mac_ver", "(", ")", "# type: ignore", "if", ...
[ 388, 0 ]
[ 415, 13 ]
python
en
['en', 'error', 'th']
False
_glibc_version_string_confstr
()
Primary implementation of glibc_version_string using os.confstr.
Primary implementation of glibc_version_string using os.confstr.
def _glibc_version_string_confstr(): # type: () -> Optional[str] """ Primary implementation of glibc_version_string using os.confstr. """ # os.confstr is quite a bit faster than ctypes.DLL. It's also less likely # to be broken or missing. This strategy is used in the standard library # platf...
[ "def", "_glibc_version_string_confstr", "(", ")", ":", "# type: () -> Optional[str]", "# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely", "# to be broken or missing. This strategy is used in the standard library", "# platform module.", "# https://github.com/python/cpython/...
[ 439, 0 ]
[ 458, 18 ]
python
en
['en', 'error', 'th']
False
_glibc_version_string_ctypes
()
Fallback implementation of glibc_version_string using ctypes.
Fallback implementation of glibc_version_string using ctypes.
def _glibc_version_string_ctypes(): # type: () -> Optional[str] """ Fallback implementation of glibc_version_string using ctypes. """ try: import ctypes except ImportError: return None # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen # manpage says, "...
[ "def", "_glibc_version_string_ctypes", "(", ")", ":", "# type: () -> Optional[str]", "try", ":", "import", "ctypes", "except", "ImportError", ":", "return", "None", "# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen", "# manpage says, \"If filename is NULL, then th...
[ 461, 0 ]
[ 492, 22 ]
python
en
['en', 'error', 'th']
False
_platform_tags
()
Provides the platform tags for this installation.
Provides the platform tags for this installation.
def _platform_tags(): # type: () -> Iterator[str] """ Provides the platform tags for this installation. """ if platform.system() == "Darwin": return mac_platforms() elif platform.system() == "Linux": return _linux_platforms() else: return _generic_platforms()
[ "def", "_platform_tags", "(", ")", ":", "# type: () -> Iterator[str]", "if", "platform", ".", "system", "(", ")", "==", "\"Darwin\"", ":", "return", "mac_platforms", "(", ")", "elif", "platform", ".", "system", "(", ")", "==", "\"Linux\"", ":", "return", "_l...
[ 682, 0 ]
[ 692, 35 ]
python
en
['en', 'error', 'th']
False
interpreter_name
()
Returns the name of the running interpreter.
Returns the name of the running interpreter.
def interpreter_name(): # type: () -> str """ Returns the name of the running interpreter. """ try: name = sys.implementation.name # type: ignore except AttributeError: # pragma: no cover # Python 2.7 compatibility. name = platform.python_implementation().lower() re...
[ "def", "interpreter_name", "(", ")", ":", "# type: () -> str", "try", ":", "name", "=", "sys", ".", "implementation", ".", "name", "# type: ignore", "except", "AttributeError", ":", "# pragma: no cover", "# Python 2.7 compatibility.", "name", "=", "platform", ".", "...
[ 695, 0 ]
[ 705, 52 ]
python
en
['en', 'error', 'th']
False
interpreter_version
(**kwargs)
Returns the version of the running interpreter.
Returns the version of the running interpreter.
def interpreter_version(**kwargs): # type: (bool) -> str """ Returns the version of the running interpreter. """ warn = _warn_keyword_parameter("interpreter_version", kwargs) version = _get_config_var("py_version_nodot", warn=warn) if version: version = str(version) else: ...
[ "def", "interpreter_version", "(", "*", "*", "kwargs", ")", ":", "# type: (bool) -> str", "warn", "=", "_warn_keyword_parameter", "(", "\"interpreter_version\"", ",", "kwargs", ")", "version", "=", "_get_config_var", "(", "\"py_version_nodot\"", ",", "warn", "=", "w...
[ 708, 0 ]
[ 719, 18 ]
python
en
['en', 'error', 'th']
False
sys_tags
(**kwargs)
Returns the sequence of tag triples for the running interpreter. The order of the sequence corresponds to priority order for the interpreter, from most to least important.
Returns the sequence of tag triples for the running interpreter.
def sys_tags(**kwargs): # type: (bool) -> Iterator[Tag] """ Returns the sequence of tag triples for the running interpreter. The order of the sequence corresponds to priority order for the interpreter, from most to least important. """ warn = _warn_keyword_parameter("sys_tags", kwargs) ...
[ "def", "sys_tags", "(", "*", "*", "kwargs", ")", ":", "# type: (bool) -> Iterator[Tag]", "warn", "=", "_warn_keyword_parameter", "(", "\"sys_tags\"", ",", "kwargs", ")", "interp_name", "=", "interpreter_name", "(", ")", "if", "interp_name", "==", "\"cp\"", ":", ...
[ 731, 0 ]
[ 750, 17 ]
python
en
['en', 'error', 'th']
False
response_chunks
(response, chunk_size=CONTENT_CHUNK_SIZE)
Given a requests Response, provide the data chunks.
Given a requests Response, provide the data chunks.
def response_chunks(response, chunk_size=CONTENT_CHUNK_SIZE): # type: (Response, int) -> Iterator[bytes] """Given a requests Response, provide the data chunks. """ try: # Special case for urllib3. for chunk in response.raw.stream( chunk_size, # We use decode_conte...
[ "def", "response_chunks", "(", "response", ",", "chunk_size", "=", "CONTENT_CHUNK_SIZE", ")", ":", "# type: (Response, int) -> Iterator[bytes]", "try", ":", "# Special case for urllib3.", "for", "chunk", "in", "response", ".", "raw", ".", "stream", "(", "chunk_size", ...
[ 57, 0 ]
[ 96, 23 ]
python
en
['en', 'en', 'en']
True
TestPageQuerySet.test_sibling_of_default
(self)
sibling_of should default to an inclusive definition of sibling if 'inclusive' flag not passed
sibling_of should default to an inclusive definition of sibling if 'inclusive' flag not passed
def test_sibling_of_default(self): """ sibling_of should default to an inclusive definition of sibling if 'inclusive' flag not passed """ events_index = Page.objects.get(url_path='/home/events/') event = Page.objects.get(url_path='/home/events/christmas/') pages =...
[ "def", "test_sibling_of_default", "(", "self", ")", ":", "events_index", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/events/'", ")", "event", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/events/christmas/'",...
[ 200, 4 ]
[ 214, 59 ]
python
en
['en', 'error', 'th']
False
TestPageQuerySet.test_not_sibling_of_default
(self)
not_sibling_of should default to an inclusive definition of sibling - i.e. eliminate self from the results as well - if 'inclusive' flag not passed
not_sibling_of should default to an inclusive definition of sibling - i.e. eliminate self from the results as well - if 'inclusive' flag not passed
def test_not_sibling_of_default(self): """ not_sibling_of should default to an inclusive definition of sibling - i.e. eliminate self from the results as well - if 'inclusive' flag not passed """ events_index = Page.objects.get(url_path='/home/events/') event = Pag...
[ "def", "test_not_sibling_of_default", "(", "self", ")", ":", "events_index", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/events/'", ")", "event", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/events/christmas...
[ 240, 4 ]
[ 258, 66 ]
python
en
['en', 'error', 'th']
False
TestFirstCommonAncestor.test_event_pages
(self)
Common ancestor for EventPages
Common ancestor for EventPages
def test_event_pages(self): """Common ancestor for EventPages""" # As there are event pages in multiple trees under /home/, the home # page is the common ancestor self.assertEqual( Page.objects.get(slug='home'), self.all_events.first_common_ancestor())
[ "def", "test_event_pages", "(", "self", ")", ":", "# As there are event pages in multiple trees under /home/, the home", "# page is the common ancestor", "self", ".", "assertEqual", "(", "Page", ".", "objects", ".", "get", "(", "slug", "=", "'home'", ")", ",", "self", ...
[ 890, 4 ]
[ 896, 52 ]
python
en
['en', 'en', 'en']
True
TestFirstCommonAncestor.test_normal_event_pages
(self)
Common ancestor for EventPages, excluding /other/ events
Common ancestor for EventPages, excluding /other/ events
def test_normal_event_pages(self): """Common ancestor for EventPages, excluding /other/ events""" self.assertEqual( Page.objects.get(slug='events'), self.regular_events.first_common_ancestor())
[ "def", "test_normal_event_pages", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "Page", ".", "objects", ".", "get", "(", "slug", "=", "'events'", ")", ",", "self", ".", "regular_events", ".", "first_common_ancestor", "(", ")", ")" ]
[ 898, 4 ]
[ 902, 56 ]
python
en
['en', 'en', 'en']
True
TestFirstCommonAncestor.test_normal_event_pages_include_self
(self)
Common ancestor for EventPages, excluding /other/ events, with include_self=True
Common ancestor for EventPages, excluding /other/ events, with include_self=True
def test_normal_event_pages_include_self(self): """ Common ancestor for EventPages, excluding /other/ events, with include_self=True """ self.assertEqual( Page.objects.get(slug='events'), self.regular_events.first_common_ancestor(include_self=True))
[ "def", "test_normal_event_pages_include_self", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "Page", ".", "objects", ".", "get", "(", "slug", "=", "'events'", ")", ",", "self", ".", "regular_events", ".", "first_common_ancestor", "(", "include_self", ...
[ 904, 4 ]
[ 911, 73 ]
python
en
['en', 'error', 'th']
False
TestFirstCommonAncestor.test_single_page_no_include_self
(self)
Test getting a single page, with include_self=False.
Test getting a single page, with include_self=False.
def test_single_page_no_include_self(self): """Test getting a single page, with include_self=False.""" self.assertEqual( Page.objects.get(slug='events'), Page.objects.filter(title='Christmas').first_common_ancestor())
[ "def", "test_single_page_no_include_self", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "Page", ".", "objects", ".", "get", "(", "slug", "=", "'events'", ")", ",", "Page", ".", "objects", ".", "filter", "(", "title", "=", "'Christmas'", ")", "...
[ 913, 4 ]
[ 917, 75 ]
python
en
['en', 'en', 'en']
True
TestFirstCommonAncestor.test_single_page_include_self
(self)
Test getting a single page, with include_self=True.
Test getting a single page, with include_self=True.
def test_single_page_include_self(self): """Test getting a single page, with include_self=True.""" self.assertEqual( Page.objects.get(title='Christmas'), Page.objects.filter(title='Christmas').first_common_ancestor(include_self=True))
[ "def", "test_single_page_include_self", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "Page", ".", "objects", ".", "get", "(", "title", "=", "'Christmas'", ")", ",", "Page", ".", "objects", ".", "filter", "(", "title", "=", "'Christmas'", ")", ...
[ 919, 4 ]
[ 923, 92 ]
python
en
['en', 'en', 'en']
True
getrgb
(color)
Convert a color string to an RGB tuple. If the string cannot be parsed, this function raises a :py:exc:`ValueError` exception. .. versionadded:: 1.1.4 :param color: A color string :return: ``(red, green, blue[, alpha])``
Convert a color string to an RGB tuple. If the string cannot be parsed, this function raises a :py:exc:`ValueError` exception.
def getrgb(color): """ Convert a color string to an RGB tuple. If the string cannot be parsed, this function raises a :py:exc:`ValueError` exception. .. versionadded:: 1.1.4 :param color: A color string :return: ``(red, green, blue[, alpha])`` """ color = color.lower() rgb = col...
[ "def", "getrgb", "(", "color", ")", ":", "color", "=", "color", ".", "lower", "(", ")", "rgb", "=", "colormap", ".", "get", "(", "color", ",", "None", ")", "if", "rgb", ":", "if", "isinstance", "(", "rgb", ",", "tuple", ")", ":", "return", "rgb",...
[ 24, 0 ]
[ 115, 63 ]
python
en
['en', 'error', 'th']
False
getcolor
(color, mode)
Same as :py:func:`~PIL.ImageColor.getrgb`, but converts the RGB value to a greyscale value if the mode is not color or a palette image. If the string cannot be parsed, this function raises a :py:exc:`ValueError` exception. .. versionadded:: 1.1.4 :param color: A color string :return: ``(grayl...
Same as :py:func:`~PIL.ImageColor.getrgb`, but converts the RGB value to a greyscale value if the mode is not color or a palette image. If the string cannot be parsed, this function raises a :py:exc:`ValueError` exception.
def getcolor(color, mode): """ Same as :py:func:`~PIL.ImageColor.getrgb`, but converts the RGB value to a greyscale value if the mode is not color or a palette image. If the string cannot be parsed, this function raises a :py:exc:`ValueError` exception. .. versionadded:: 1.1.4 :param color: A ...
[ "def", "getcolor", "(", "color", ",", "mode", ")", ":", "# same as getrgb, but converts the result to the given mode", "color", ",", "alpha", "=", "getrgb", "(", "color", ")", ",", "255", "if", "len", "(", "color", ")", "==", "4", ":", "color", ",", "alpha",...
[ 118, 0 ]
[ 144, 16 ]
python
en
['en', 'error', 'th']
False
SpatiaLiteOperations.spatial_version
(self)
Determine the version of the SpatiaLite library.
Determine the version of the SpatiaLite library.
def spatial_version(self): """Determine the version of the SpatiaLite library.""" try: version = self.spatialite_version_tuple()[1:] except Exception as msg: new_msg = ( 'Cannot determine the SpatiaLite version for the "%s" ' 'database (err...
[ "def", "spatial_version", "(", "self", ")", ":", "try", ":", "version", "=", "self", ".", "spatialite_version_tuple", "(", ")", "[", "1", ":", "]", "except", "Exception", "as", "msg", ":", "new_msg", "=", "(", "'Cannot determine the SpatiaLite version for the \"...
[ 121, 4 ]
[ 133, 22 ]
python
en
['en', 'en', 'en']
True
SpatiaLiteOperations.convert_extent
(self, box, srid)
Convert the polygon data received from SpatiaLite to min/max values.
Convert the polygon data received from SpatiaLite to min/max values.
def convert_extent(self, box, srid): """ Convert the polygon data received from SpatiaLite to min/max values. """ if box is None: return None shell = Geometry(box, srid).shell xmin, ymin = shell[0][:2] xmax, ymax = shell[2][:2] return (xmin, ym...
[ "def", "convert_extent", "(", "self", ",", "box", ",", "srid", ")", ":", "if", "box", "is", "None", ":", "return", "None", "shell", "=", "Geometry", "(", "box", ",", "srid", ")", ".", "shell", "xmin", ",", "ymin", "=", "shell", "[", "0", "]", "["...
[ 135, 4 ]
[ 144, 39 ]
python
en
['en', 'error', 'th']
False
SpatiaLiteOperations.geo_db_type
(self, f)
Returns None because geometry columns are added via the `AddGeometryColumn` stored procedure on SpatiaLite.
Returns None because geometry columns are added via the `AddGeometryColumn` stored procedure on SpatiaLite.
def geo_db_type(self, f): """ Returns None because geometry columns are added via the `AddGeometryColumn` stored procedure on SpatiaLite. """ return None
[ "def", "geo_db_type", "(", "self", ",", "f", ")", ":", "return", "None" ]
[ 146, 4 ]
[ 151, 19 ]
python
en
['en', 'error', 'th']
False
SpatiaLiteOperations.get_distance
(self, f, value, lookup_type, **kwargs)
Returns the distance parameters for the given geometry field, lookup value, and lookup type.
Returns the distance parameters for the given geometry field, lookup value, and lookup type.
def get_distance(self, f, value, lookup_type, **kwargs): """ Returns the distance parameters for the given geometry field, lookup value, and lookup type. """ if not value: return [] value = value[0] if isinstance(value, Distance): if f.geod...
[ "def", "get_distance", "(", "self", ",", "f", ",", "value", ",", "lookup_type", ",", "*", "*", "kwargs", ")", ":", "if", "not", "value", ":", "return", "[", "]", "value", "=", "value", "[", "0", "]", "if", "isinstance", "(", "value", ",", "Distance...
[ 153, 4 ]
[ 173, 27 ]
python
en
['en', 'error', 'th']
False
SpatiaLiteOperations.get_geom_placeholder
(self, f, value, compiler)
Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the Transform() and GeomFromText() function call(s).
Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the Transform() and GeomFromText() function call(s).
def get_geom_placeholder(self, f, value, compiler): """ Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the Transform() and GeomFromText() function call(s). """ def transform_value(v...
[ "def", "get_geom_placeholder", "(", "self", ",", "f", ",", "value", ",", "compiler", ")", ":", "def", "transform_value", "(", "value", ",", "srid", ")", ":", "return", "not", "(", "value", "is", "None", "or", "value", ".", "srid", "==", "srid", ")", ...
[ 175, 4 ]
[ 197, 62 ]
python
en
['en', 'error', 'th']
False
SpatiaLiteOperations._get_spatialite_func
(self, func)
Helper routine for calling SpatiaLite functions and returning their result. Any error occurring in this method should be handled by the caller.
Helper routine for calling SpatiaLite functions and returning their result. Any error occurring in this method should be handled by the caller.
def _get_spatialite_func(self, func): """ Helper routine for calling SpatiaLite functions and returning their result. Any error occurring in this method should be handled by the caller. """ cursor = self.connection._cursor() try: cursor.execute('SELECT...
[ "def", "_get_spatialite_func", "(", "self", ",", "func", ")", ":", "cursor", "=", "self", ".", "connection", ".", "_cursor", "(", ")", "try", ":", "cursor", ".", "execute", "(", "'SELECT %s'", "%", "func", ")", "row", "=", "cursor", ".", "fetchone", "(...
[ 199, 4 ]
[ 211, 21 ]
python
en
['en', 'error', 'th']
False
SpatiaLiteOperations.geos_version
(self)
Returns the version of GEOS used by SpatiaLite as a string.
Returns the version of GEOS used by SpatiaLite as a string.
def geos_version(self): "Returns the version of GEOS used by SpatiaLite as a string." return self._get_spatialite_func('geos_version()')
[ "def", "geos_version", "(", "self", ")", ":", "return", "self", ".", "_get_spatialite_func", "(", "'geos_version()'", ")" ]
[ 213, 4 ]
[ 215, 58 ]
python
en
['en', 'en', 'en']
True
SpatiaLiteOperations.proj4_version
(self)
Returns the version of the PROJ.4 library used by SpatiaLite.
Returns the version of the PROJ.4 library used by SpatiaLite.
def proj4_version(self): "Returns the version of the PROJ.4 library used by SpatiaLite." return self._get_spatialite_func('proj4_version()')
[ "def", "proj4_version", "(", "self", ")", ":", "return", "self", ".", "_get_spatialite_func", "(", "'proj4_version()'", ")" ]
[ 217, 4 ]
[ 219, 59 ]
python
en
['en', 'en', 'en']
True
SpatiaLiteOperations.lwgeom_version
(self)
Return the version of LWGEOM library used by SpatiaLite.
Return the version of LWGEOM library used by SpatiaLite.
def lwgeom_version(self): """Return the version of LWGEOM library used by SpatiaLite.""" return self._get_spatialite_func('lwgeom_version()')
[ "def", "lwgeom_version", "(", "self", ")", ":", "return", "self", ".", "_get_spatialite_func", "(", "'lwgeom_version()'", ")" ]
[ 221, 4 ]
[ 223, 60 ]
python
en
['en', 'en', 'en']
True
SpatiaLiteOperations.spatialite_version
(self)
Returns the SpatiaLite library version as a string.
Returns the SpatiaLite library version as a string.
def spatialite_version(self): "Returns the SpatiaLite library version as a string." return self._get_spatialite_func('spatialite_version()')
[ "def", "spatialite_version", "(", "self", ")", ":", "return", "self", ".", "_get_spatialite_func", "(", "'spatialite_version()'", ")" ]
[ 225, 4 ]
[ 227, 64 ]
python
en
['en', 'en', 'en']
True
SpatiaLiteOperations.spatialite_version_tuple
(self)
Returns the SpatiaLite version as a tuple (version string, major, minor, subminor).
Returns the SpatiaLite version as a tuple (version string, major, minor, subminor).
def spatialite_version_tuple(self): """ Returns the SpatiaLite version as a tuple (version string, major, minor, subminor). """ version = self.spatialite_version() m = self.version_regex.match(version) if m: major = int(m.group('major')) m...
[ "def", "spatialite_version_tuple", "(", "self", ")", ":", "version", "=", "self", ".", "spatialite_version", "(", ")", "m", "=", "self", ".", "version_regex", ".", "match", "(", "version", ")", "if", "m", ":", "major", "=", "int", "(", "m", ".", "group...
[ 229, 4 ]
[ 244, 47 ]
python
en
['en', 'error', 'th']
False
SpatiaLiteOperations.spatial_aggregate_name
(self, agg_name)
Returns the spatial aggregate SQL template and function for the given Aggregate instance.
Returns the spatial aggregate SQL template and function for the given Aggregate instance.
def spatial_aggregate_name(self, agg_name): """ Returns the spatial aggregate SQL template and function for the given Aggregate instance. """ agg_name = 'unionagg' if agg_name.lower() == 'union' else agg_name.lower() return getattr(self, agg_name)
[ "def", "spatial_aggregate_name", "(", "self", ",", "agg_name", ")", ":", "agg_name", "=", "'unionagg'", "if", "agg_name", ".", "lower", "(", ")", "==", "'union'", "else", "agg_name", ".", "lower", "(", ")", "return", "getattr", "(", "self", ",", "agg_name"...
[ 246, 4 ]
[ 252, 38 ]
python
en
['en', 'error', 'th']
False
Loader.load_template_source
(self, template_name, template_dirs=None)
Loads templates from Python eggs via pkg_resource.resource_string. For every installed app, it tries to get the resource (app, template_name).
Loads templates from Python eggs via pkg_resource.resource_string.
def load_template_source(self, template_name, template_dirs=None): """ Loads templates from Python eggs via pkg_resource.resource_string. For every installed app, it tries to get the resource (app, template_name). """ warnings.warn( 'The load_template_sources() metho...
[ "def", "load_template_source", "(", "self", ",", "template_name", ",", "template_dirs", "=", "None", ")", ":", "warnings", ".", "warn", "(", "'The load_template_sources() method is deprecated. Use '", "'get_template() or get_contents() instead.'", ",", "RemovedInDjango20Warning...
[ 57, 4 ]
[ 73, 49 ]
python
en
['en', 'error', 'th']
False
FencedCodeExtension.extendMarkdown
(self, md: Markdown)
Add FencedBlockPreprocessor to the Markdown instance.
Add FencedBlockPreprocessor to the Markdown instance.
def extendMarkdown(self, md: Markdown) -> None: """Add FencedBlockPreprocessor to the Markdown instance.""" md.registerExtension(self) processor = FencedBlockPreprocessor( md, run_content_validators=self.config["run_content_validators"][0] ) md.preprocessors.register(...
[ "def", "extendMarkdown", "(", "self", ",", "md", ":", "Markdown", ")", "->", "None", ":", "md", ".", "registerExtension", "(", "self", ")", "processor", "=", "FencedBlockPreprocessor", "(", "md", ",", "run_content_validators", "=", "self", ".", "config", "["...
[ 158, 4 ]
[ 164, 69 ]
python
en
['en', 'it', 'en']
True
FencedBlockPreprocessor.run
(self, lines: Iterable[str])
Match and store Fenced Code Blocks in the HtmlStash.
Match and store Fenced Code Blocks in the HtmlStash.
def run(self, lines: Iterable[str]) -> List[str]: """Match and store Fenced Code Blocks in the HtmlStash.""" output: List[str] = [] processor = self self.handlers: List[BaseHandler] = [] default_language = None try: default_language = self.md.zulip_realm.de...
[ "def", "run", "(", "self", ",", "lines", ":", "Iterable", "[", "str", "]", ")", "->", "List", "[", "str", "]", ":", "output", ":", "List", "[", "str", "]", "=", "[", "]", "processor", "=", "self", "self", ".", "handlers", ":", "List", "[", "Bas...
[ 380, 4 ]
[ 407, 21 ]
python
en
['en', 'en', 'en']
True
FencedBlockPreprocessor._escape
(self, txt: str)
basic html escaping
basic html escaping
def _escape(self, txt: str) -> str: """basic html escaping""" txt = txt.replace("&", "&amp;") txt = txt.replace("<", "&lt;") txt = txt.replace(">", "&gt;") txt = txt.replace('"', "&quot;") return txt
[ "def", "_escape", "(", "self", ",", "txt", ":", "str", ")", "->", "str", ":", "txt", "=", "txt", ".", "replace", "(", "\"&\"", ",", "\"&amp;\"", ")", "txt", "=", "txt", ".", "replace", "(", "\"<\"", ",", "\"&lt;\"", ")", "txt", "=", "txt", ".", ...
[ 503, 4 ]
[ 509, 18 ]
python
en
['es', 'en', 'en']
True
TestRecentEditsPanel.test_panel
(self)
Test if the panel actually returns expected pages
Test if the panel actually returns expected pages
def test_panel(self): """Test if the panel actually returns expected pages """ self.login(username='bob', password='password') # change a page self.change_something("Bob's edit") # set a user to 'mock' a request self.client.user = get_user_model().objects.get(email='bob@e...
[ "def", "test_panel", "(", "self", ")", ":", "self", ".", "login", "(", "username", "=", "'bob'", ",", "password", "=", "'password'", ")", "# change a page", "self", ".", "change_something", "(", "\"Bob's edit\"", ")", "# set a user to 'mock' a request", "self", ...
[ 79, 4 ]
[ 91, 98 ]
python
en
['en', 'en', 'en']
True
register
(hook_name, fn=None, order=0)
Register hook for ``hook_name``. Can be used as a decorator:: @register('hook_name') def my_hook(...): pass or as a function call:: def my_hook(...): pass register('hook_name', my_hook)
Register hook for ``hook_name``. Can be used as a decorator::
def register(hook_name, fn=None, order=0): """ Register hook for ``hook_name``. Can be used as a decorator:: @register('hook_name') def my_hook(...): pass or as a function call:: def my_hook(...): pass register('hook_name', my_hook) """ # P...
[ "def", "register", "(", "hook_name", ",", "fn", "=", "None", ",", "order", "=", "0", ")", ":", "# Pretend to be a decorator if fn is not supplied", "if", "fn", "is", "None", ":", "def", "decorator", "(", "fn", ")", ":", "register", "(", "hook_name", ",", "...
[ 9, 0 ]
[ 33, 41 ]
python
en
['en', 'error', 'th']
False
register_temporarily
(hook_name_or_hooks, fn=None, *, order=0)
Register hook for ``hook_name`` temporarily. This is useful for testing hooks. Can be used as a decorator:: def my_hook(...): pass class TestMyHook(Testcase): @hooks.register_temporarily('hook_name', my_hook) def test_my_hook(self): pass ...
Register hook for ``hook_name`` temporarily. This is useful for testing hooks.
def register_temporarily(hook_name_or_hooks, fn=None, *, order=0): """ Register hook for ``hook_name`` temporarily. This is useful for testing hooks. Can be used as a decorator:: def my_hook(...): pass class TestMyHook(Testcase): @hooks.register_temporarily('hook_n...
[ "def", "register_temporarily", "(", "hook_name_or_hooks", ",", "fn", "=", "None", ",", "*", ",", "order", "=", "0", ")", ":", "if", "not", "isinstance", "(", "hook_name_or_hooks", ",", "list", ")", "and", "fn", "is", "not", "None", ":", "hooks", "=", "...
[ 52, 0 ]
[ 95, 38 ]
python
en
['en', 'error', 'th']
False
get_hooks
(hook_name)
Return the hooks function sorted by their order.
Return the hooks function sorted by their order.
def get_hooks(hook_name): """ Return the hooks function sorted by their order. """ search_for_hooks() hooks = _hooks.get(hook_name, []) hooks = sorted(hooks, key=itemgetter(1)) return [hook[0] for hook in hooks]
[ "def", "get_hooks", "(", "hook_name", ")", ":", "search_for_hooks", "(", ")", "hooks", "=", "_hooks", ".", "get", "(", "hook_name", ",", "[", "]", ")", "hooks", "=", "sorted", "(", "hooks", ",", "key", "=", "itemgetter", "(", "1", ")", ")", "return",...
[ 108, 0 ]
[ 113, 38 ]
python
en
['en', 'en', 'en']
True
remove_hipchat_notifications
(apps, schema_editor)
HipChat notifications are no longer in service, remove any that are found.
HipChat notifications are no longer in service, remove any that are found.
def remove_hipchat_notifications(apps, schema_editor): """ HipChat notifications are no longer in service, remove any that are found. """ Notification = apps.get_model('main', 'Notification') Notification.objects.filter(notification_type='hipchat').delete() NotificationTemplate = apps.get_model(...
[ "def", "remove_hipchat_notifications", "(", "apps", ",", "schema_editor", ")", ":", "Notification", "=", "apps", ".", "get_model", "(", "'main'", ",", "'Notification'", ")", "Notification", ".", "objects", ".", "filter", "(", "notification_type", "=", "'hipchat'",...
[ 5, 0 ]
[ 12, 77 ]
python
en
['en', 'error', 'th']
False
SimpleDAG.__init__
(self)
r''' Track node_obj->node index dict where key is a full workflow node object or whatever we are storing in ['node_object'] and value is an index to be used into self.nodes
r''' Track node_obj->node index dict where key is a full workflow node object or whatever we are storing in ['node_object'] and value is an index to be used into self.nodes
def __init__(self): self.nodes = [] self.root_nodes = set([]) r''' Track node_obj->node index dict where key is a full workflow node object or whatever we are storing in ['node_object'] and value is an index to be used into self.nodes ''' self.nod...
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "nodes", "=", "[", "]", "self", ".", "root_nodes", "=", "set", "(", "[", "]", ")", "self", ".", "node_obj_to_node_index", "=", "dict", "(", ")", "r'''\n Track per-node from->to edges\n\n i.e....
[ 6, 4 ]
[ 48, 44 ]
python
cy
['en', 'cy', 'hi']
False
SimpleDAG.add_edge
(self, from_obj, to_obj, label)
To node is no longer a root node
To node is no longer a root node
def add_edge(self, from_obj, to_obj, label): from_obj_ord = self.find_ord(from_obj) to_obj_ord = self.find_ord(to_obj) ''' To node is no longer a root node ''' self.root_nodes.discard(to_obj_ord) if from_obj_ord is None and to_obj_ord is None: raise ...
[ "def", "add_edge", "(", "self", ",", "from_obj", ",", "to_obj", ",", "label", ")", ":", "from_obj_ord", "=", "self", ".", "find_ord", "(", "from_obj", ")", "to_obj_ord", "=", "self", ".", "find_ord", "(", "to_obj", ")", "self", ".", "root_nodes", ".", ...
[ 112, 4 ]
[ 132, 75 ]
python
en
['en', 'error', 'th']
False
TestSendMail.test_send_html_email
(self)
Test that the kwarg 'html_message' works as expected on send_mail by creating 'alternatives' on the EmailMessage object
Test that the kwarg 'html_message' works as expected on send_mail by creating 'alternatives' on the EmailMessage object
def test_send_html_email(self): """Test that the kwarg 'html_message' works as expected on send_mail by creating 'alternatives' on the EmailMessage object""" send_mail("Test HTML subject", "TEXT content", ["has.html@email.com"], html_message="<h2>Test HTML content</h2>") send_mail("Test TEXT su...
[ "def", "test_send_html_email", "(", "self", ")", ":", "send_mail", "(", "\"Test HTML subject\"", ",", "\"TEXT content\"", ",", "[", "\"has.html@email.com\"", "]", ",", "html_message", "=", "\"<h2>Test HTML content</h2>\"", ")", "send_mail", "(", "\"Test TEXT subject\"", ...
[ 159, 4 ]
[ 180, 71 ]
python
en
['en', 'en', 'sw']
True
_execfile
(filename, globals, locals=None)
Python 3 implementation of execfile.
Python 3 implementation of execfile.
def _execfile(filename, globals, locals=None): """ Python 3 implementation of execfile. """ mode = 'rb' with open(filename, mode) as stream: script = stream.read() if locals is None: locals = globals code = compile(script, filename, 'exec') exec(code, globals, locals)
[ "def", "_execfile", "(", "filename", ",", "globals", ",", "locals", "=", "None", ")", ":", "mode", "=", "'rb'", "with", "open", "(", "filename", ",", "mode", ")", "as", "stream", ":", "script", "=", "stream", ".", "read", "(", ")", "if", "locals", ...
[ 32, 0 ]
[ 42, 31 ]
python
en
['en', 'error', 'th']
False
override_temp
(replacement)
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
def override_temp(replacement): """ Monkey-patch tempfile.tempdir with replacement, ensuring it exists """ os.makedirs(replacement, exist_ok=True) saved = tempfile.tempdir tempfile.tempdir = replacement try: yield finally: tempfile.tempdir = saved
[ "def", "override_temp", "(", "replacement", ")", ":", "os", ".", "makedirs", "(", "replacement", ",", "exist_ok", "=", "True", ")", "saved", "=", "tempfile", ".", "tempdir", "tempfile", ".", "tempdir", "=", "replacement", "try", ":", "yield", "finally", ":...
[ 66, 0 ]
[ 79, 32 ]
python
en
['en', 'error', 'th']
False
save_modules
()
Context in which imported modules are saved. Translates exceptions internal to the context into the equivalent exception outside the context.
Context in which imported modules are saved.
def save_modules(): """ Context in which imported modules are saved. Translates exceptions internal to the context into the equivalent exception outside the context. """ saved = sys.modules.copy() with ExceptionSaver() as saved_exc: yield saved sys.modules.update(saved) # r...
[ "def", "save_modules", "(", ")", ":", "saved", "=", "sys", ".", "modules", ".", "copy", "(", ")", "with", "ExceptionSaver", "(", ")", "as", "saved_exc", ":", "yield", "saved", "sys", ".", "modules", ".", "update", "(", "saved", ")", "# remove any modules...
[ 142, 0 ]
[ 163, 22 ]
python
en
['en', 'error', 'th']
False
_needs_hiding
(mod_name)
>>> _needs_hiding('setuptools') True >>> _needs_hiding('pkg_resources') True >>> _needs_hiding('setuptools_plugin') False >>> _needs_hiding('setuptools.__init__') True >>> _needs_hiding('distutils') True >>> _needs_hiding('os') False >>> _needs_hiding('Cython') T...
>>> _needs_hiding('setuptools') True >>> _needs_hiding('pkg_resources') True >>> _needs_hiding('setuptools_plugin') False >>> _needs_hiding('setuptools.__init__') True >>> _needs_hiding('distutils') True >>> _needs_hiding('os') False >>> _needs_hiding('Cython') T...
def _needs_hiding(mod_name): """ >>> _needs_hiding('setuptools') True >>> _needs_hiding('pkg_resources') True >>> _needs_hiding('setuptools_plugin') False >>> _needs_hiding('setuptools.__init__') True >>> _needs_hiding('distutils') True >>> _needs_hiding('os') False ...
[ "def", "_needs_hiding", "(", "mod_name", ")", ":", "base_module", "=", "mod_name", ".", "split", "(", "'.'", ",", "1", ")", "[", "0", "]", "return", "base_module", "in", "_MODULES_TO_HIDE" ]
[ 204, 0 ]
[ 222, 42 ]
python
en
['en', 'error', 'th']
False
hide_setuptools
()
Remove references to setuptools' modules from sys.modules to allow the invocation to import the most appropriate setuptools. This technique is necessary to avoid issues such as #315 where setuptools upgrading itself would fail to find a function declared in the metadata.
Remove references to setuptools' modules from sys.modules to allow the invocation to import the most appropriate setuptools. This technique is necessary to avoid issues such as #315 where setuptools upgrading itself would fail to find a function declared in the metadata.
def hide_setuptools(): """ Remove references to setuptools' modules from sys.modules to allow the invocation to import the most appropriate setuptools. This technique is necessary to avoid issues such as #315 where setuptools upgrading itself would fail to find a function declared in the metadata. ...
[ "def", "hide_setuptools", "(", ")", ":", "_distutils_hack", "=", "sys", ".", "modules", ".", "get", "(", "'_distutils_hack'", ",", "None", ")", "if", "_distutils_hack", "is", "not", "None", ":", "_distutils_hack", ".", "remove_shim", "(", ")", "modules", "="...
[ 225, 0 ]
[ 237, 27 ]
python
en
['en', 'error', 'th']
False
run_setup
(setup_script, args)
Run a distutils setup script, sandboxed in its directory
Run a distutils setup script, sandboxed in its directory
def run_setup(setup_script, args): """Run a distutils setup script, sandboxed in its directory""" setup_dir = os.path.abspath(os.path.dirname(setup_script)) with setup_context(setup_dir): try: sys.argv[:] = [setup_script] + list(args) sys.path.insert(0, setup_dir) ...
[ "def", "run_setup", "(", "setup_script", ",", "args", ")", ":", "setup_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "setup_script", ")", ")", "with", "setup_context", "(", "setup_dir", ")", ":", "try", ":",...
[ 240, 0 ]
[ 256, 21 ]
python
en
['en', 'lb', 'en']
True
UnpickleableException.dump
(type, exc)
Always return a dumped (pickled) type and exc. If exc can't be pickled, wrap it in UnpickleableException first.
Always return a dumped (pickled) type and exc. If exc can't be pickled, wrap it in UnpickleableException first.
def dump(type, exc): """ Always return a dumped (pickled) type and exc. If exc can't be pickled, wrap it in UnpickleableException first. """ try: return pickle.dumps(type), pickle.dumps(exc) except Exception: # get UnpickleableException inside the ...
[ "def", "dump", "(", "type", ",", "exc", ")", ":", "try", ":", "return", "pickle", ".", "dumps", "(", "type", ")", ",", "pickle", ".", "dumps", "(", "exc", ")", "except", "Exception", ":", "# get UnpickleableException inside the sandbox", "from", "setuptools"...
[ 98, 4 ]
[ 108, 48 ]
python
en
['en', 'error', 'th']
False
ExceptionSaver.resume
(self)
restore and re-raise any exception
restore and re-raise any exception
def resume(self): "restore and re-raise any exception" if '_saved' not in vars(self): return type, exc = map(pickle.loads, self._saved) raise exc.with_traceback(self._tb)
[ "def", "resume", "(", "self", ")", ":", "if", "'_saved'", "not", "in", "vars", "(", "self", ")", ":", "return", "type", ",", "exc", "=", "map", "(", "pickle", ".", "loads", ",", "self", ".", "_saved", ")", "raise", "exc", ".", "with_traceback", "("...
[ 131, 4 ]
[ 138, 42 ]
python
en
['en', 'en', 'en']
True
AbstractSandbox.run
(self, func)
Run 'func' under os sandboxing
Run 'func' under os sandboxing
def run(self, func): """Run 'func' under os sandboxing""" with self: return func()
[ "def", "run", "(", "self", ",", "func", ")", ":", "with", "self", ":", "return", "func", "(", ")" ]
[ 289, 4 ]
[ 292, 25 ]
python
es
['es', 'jv', 'pt']
False
AbstractSandbox._validate_path
(self, path)
Called to remap or validate any path, whether input or output
Called to remap or validate any path, whether input or output
def _validate_path(self, path): """Called to remap or validate any path, whether input or output""" return path
[ "def", "_validate_path", "(", "self", ",", "path", ")", ":", "return", "path" ]
[ 359, 4 ]
[ 361, 19 ]
python
en
['en', 'en', 'en']
True
AbstractSandbox._remap_input
(self, operation, path, *args, **kw)
Called for path inputs
Called for path inputs
def _remap_input(self, operation, path, *args, **kw): """Called for path inputs""" return self._validate_path(path)
[ "def", "_remap_input", "(", "self", ",", "operation", ",", "path", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "return", "self", ".", "_validate_path", "(", "path", ")" ]
[ 363, 4 ]
[ 365, 40 ]
python
en
['en', 'en', 'en']
True
AbstractSandbox._remap_output
(self, operation, path)
Called for path outputs
Called for path outputs
def _remap_output(self, operation, path): """Called for path outputs""" return self._validate_path(path)
[ "def", "_remap_output", "(", "self", ",", "operation", ",", "path", ")", ":", "return", "self", ".", "_validate_path", "(", "path", ")" ]
[ 367, 4 ]
[ 369, 40 ]
python
en
['en', 'en', 'en']
True
AbstractSandbox._remap_pair
(self, operation, src, dst, *args, **kw)
Called for path pairs like rename, link, and symlink operations
Called for path pairs like rename, link, and symlink operations
def _remap_pair(self, operation, src, dst, *args, **kw): """Called for path pairs like rename, link, and symlink operations""" return ( self._remap_input(operation + '-from', src, *args, **kw), self._remap_input(operation + '-to', dst, *args, **kw) )
[ "def", "_remap_pair", "(", "self", ",", "operation", ",", "src", ",", "dst", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "return", "(", "self", ".", "_remap_input", "(", "operation", "+", "'-from'", ",", "src", ",", "*", "args", ",", "*", "*...
[ 371, 4 ]
[ 376, 9 ]
python
en
['en', 'en', 'en']
True
DirectorySandbox._remap_input
(self, operation, path, *args, **kw)
Called for path inputs
Called for path inputs
def _remap_input(self, operation, path, *args, **kw): """Called for path inputs""" if operation in self.write_ops and not self._ok(path): self._violation(operation, os.path.realpath(path), *args, **kw) return path
[ "def", "_remap_input", "(", "self", ",", "operation", ",", "path", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "operation", "in", "self", ".", "write_ops", "and", "not", "self", ".", "_ok", "(", "path", ")", ":", "self", ".", "_violation...
[ 452, 4 ]
[ 456, 19 ]
python
en
['en', 'en', 'en']
True
DirectorySandbox._remap_pair
(self, operation, src, dst, *args, **kw)
Called for path pairs like rename, link, and symlink operations
Called for path pairs like rename, link, and symlink operations
def _remap_pair(self, operation, src, dst, *args, **kw): """Called for path pairs like rename, link, and symlink operations""" if not self._ok(src) or not self._ok(dst): self._violation(operation, src, dst, *args, **kw) return (src, dst)
[ "def", "_remap_pair", "(", "self", ",", "operation", ",", "src", ",", "dst", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "not", "self", ".", "_ok", "(", "src", ")", "or", "not", "self", ".", "_ok", "(", "dst", ")", ":", "self", "."...
[ 458, 4 ]
[ 462, 25 ]
python
en
['en', 'en', 'en']
True
DirectorySandbox.open
(self, file, flags, mode=0o777, *args, **kw)
Called for low-level os.open()
Called for low-level os.open()
def open(self, file, flags, mode=0o777, *args, **kw): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode, *args, **kw) return _os.open(file, flags, mode, *args, **kw)
[ "def", "open", "(", "self", ",", "file", ",", "flags", ",", "mode", "=", "0o777", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "flags", "&", "WRITE_FLAGS", "and", "not", "self", ".", "_ok", "(", "file", ")", ":", "self", ".", "_violat...
[ 464, 4 ]
[ 468, 55 ]
python
en
['en', 'en', 'en']
True
rgb
(r, g, b, a=255)
(Internal) Turns an RGB color into a Qt compatible color integer.
(Internal) Turns an RGB color into a Qt compatible color integer.
def rgb(r, g, b, a=255): """(Internal) Turns an RGB color into a Qt compatible color integer.""" # use qRgb to pack the colors, and then turn the resulting long # into a negative integer with the same bitpattern. return qRgba(r, g, b, a) & 0xFFFFFFFF
[ "def", "rgb", "(", "r", ",", "g", ",", "b", ",", "a", "=", "255", ")", ":", "# use qRgb to pack the colors, and then turn the resulting long", "# into a negative integer with the same bitpattern.", "return", "qRgba", "(", "r", ",", "g", ",", "b", ",", "a", ")", ...
[ 45, 0 ]
[ 49, 41 ]
python
en
['en', 'ca', 'en']
True
fromqimage
(im)
:param im: A PIL Image object, or a file name (given either as Python string or a PyQt string object)
:param im: A PIL Image object, or a file name (given either as Python string or a PyQt string object)
def fromqimage(im): """ :param im: A PIL Image object, or a file name (given either as Python string or a PyQt string object) """ buffer = QBuffer() buffer.open(QIODevice.ReadWrite) # preserve alpha channel with png # otherwise ppm is more friendly with Image.open if im.hasAlphaChann...
[ "def", "fromqimage", "(", "im", ")", ":", "buffer", "=", "QBuffer", "(", ")", "buffer", ".", "open", "(", "QIODevice", ".", "ReadWrite", ")", "# preserve alpha channel with png", "# otherwise ppm is more friendly with Image.open", "if", "im", ".", "hasAlphaChannel", ...
[ 52, 0 ]
[ 71, 24 ]
python
en
['en', 'error', 'th']
False
align8to32
(bytes, width, mode)
converts each scanline of data from 8 bit to 32 bit aligned
converts each scanline of data from 8 bit to 32 bit aligned
def align8to32(bytes, width, mode): """ converts each scanline of data from 8 bit to 32 bit aligned """ bits_per_pixel = {"1": 1, "L": 8, "P": 8}[mode] # calculate bytes per line and the extra padding if needed bits_per_line = bits_per_pixel * width full_bytes_per_line, remaining_bits_per_...
[ "def", "align8to32", "(", "bytes", ",", "width", ",", "mode", ")", ":", "bits_per_pixel", "=", "{", "\"1\"", ":", "1", ",", "\"L\"", ":", "8", ",", "\"P\"", ":", "8", "}", "[", "mode", "]", "# calculate bytes per line and the extra padding if needed", "bits_...
[ 88, 0 ]
[ 113, 29 ]
python
en
['en', 'error', 'th']
False
PyTestExecutor.install_required_tools
(self)
we need installed nose plugin
we need installed nose plugin
def install_required_tools(self): """ we need installed nose plugin """ self._check_tools([self._get_tool(TaurusPytestRunner, tool_path=self.runner_path)])
[ "def", "install_required_tools", "(", "self", ")", ":", "self", ".", "_check_tools", "(", "[", "self", ".", "_get_tool", "(", "TaurusPytestRunner", ",", "tool_path", "=", "self", ".", "runner_path", ")", "]", ")" ]
[ 56, 4 ]
[ 60, 91 ]
python
en
['en', 'error', 'th']
False
PyTestExecutor.startup
(self)
run python tests
run python tests
def startup(self): """ run python tests """ executable = self.settings.get("interpreter", sys.executable) cmdline = [executable, self.runner_path, '--report-file', self.report_file] load = self.get_load() if load.iterations: cmdline += ['-i', str(loa...
[ "def", "startup", "(", "self", ")", ":", "executable", "=", "self", ".", "settings", ".", "get", "(", "\"interpreter\"", ",", "sys", ".", "executable", ")", "cmdline", "=", "[", "executable", ",", "self", ".", "runner_path", ",", "'--report-file'", ",", ...
[ 62, 4 ]
[ 83, 88 ]
python
en
['en', 'error', 'th']
False
get_logfile_handler
(script_args)
Set up a logfile hander with a standard set of formatting options. The standard logger setup here is designed to work with a set of command line options that has been parsed with the `argparse package <http://docs.python.org/2.7/library/argparse.html>`_ passed to the routine. The parser should ha...
Set up a logfile hander with a standard set of formatting options. The standard logger setup here is designed to work with a set of command line options that has been parsed with the `argparse package <http://docs.python.org/2.7/library/argparse.html>`_ passed to the routine. The parser should ha...
def get_logfile_handler(script_args): ''' Set up a logfile hander with a standard set of formatting options. The standard logger setup here is designed to work with a set of command line options that has been parsed with the `argparse package <http://docs.python.org/2.7/library/argparse.html>`_ p...
[ "def", "get_logfile_handler", "(", "script_args", ")", ":", "# check for the correct attributes", "try", ":", "verbose", "=", "script_args", ".", "verbose", "except", "AttributeError", ":", "raise", "AttributeError", "(", "\"The args passed to standard_logger do not \"", "\...
[ 24, 0 ]
[ 63, 27 ]
python
en
['en', 'en', 'en']
True
standard_logger
(script_version, cmd_line, script_args, pos_args, kw_args, logbase=None, script_name=None, modules=None)
Set up a logger with a standard set of options and an automatic header. The standard info logged here required that a root logger has already been instantized and is designed to work with a set of command line options that has been parsed with the `argparse package <http://docs.python.org/2.7/l...
Set up a logger with a standard set of options and an automatic header. The standard info logged here required that a root logger has already been instantized and is designed to work with a set of command line options that has been parsed with the `argparse package <http://docs.python.org/2.7/l...
def standard_logger(script_version, cmd_line, script_args, pos_args, kw_args, logbase=None, script_name=None, modules=None): ''' Set up a logger with a standard set of options and an automatic header. The standard info logged here required that a root logger has already been i...
[ "def", "standard_logger", "(", "script_version", ",", "cmd_line", ",", "script_args", ",", "pos_args", ",", "kw_args", ",", "logbase", "=", "None", ",", "script_name", "=", "None", ",", "modules", "=", "None", ")", ":", "# check for the correct attributes", "try...
[ 65, 0 ]
[ 182, 22 ]
python
en
['en', 'en', 'en']
True
load_backend
(backend_name)
Return a database backend's "base" module given a fully qualified database backend name, or raise an error if it doesn't exist.
Return a database backend's "base" module given a fully qualified database backend name, or raise an error if it doesn't exist.
def load_backend(backend_name): """ Return a database backend's "base" module given a fully qualified database backend name, or raise an error if it doesn't exist. """ # This backend was renamed in Django 1.9. if backend_name == 'django.db.backends.postgresql_psycopg2': backend_name = 'd...
[ "def", "load_backend", "(", "backend_name", ")", ":", "# This backend was renamed in Django 1.9.", "if", "backend_name", "==", "'django.db.backends.postgresql_psycopg2'", ":", "backend_name", "=", "'django.db.backends.postgresql'", "try", ":", "return", "import_module", "(", ...
[ 104, 0 ]
[ 136, 17 ]
python
en
['en', 'error', 'th']
False
DatabaseErrorWrapper.__init__
(self, wrapper)
wrapper is a database wrapper. It must have a Database attribute defining PEP-249 exceptions.
wrapper is a database wrapper.
def __init__(self, wrapper): """ wrapper is a database wrapper. It must have a Database attribute defining PEP-249 exceptions. """ self.wrapper = wrapper
[ "def", "__init__", "(", "self", ",", "wrapper", ")", ":", "self", ".", "wrapper", "=", "wrapper" ]
[ 58, 4 ]
[ 64, 30 ]
python
en
['en', 'error', 'th']
False
ConnectionHandler.__init__
(self, databases=None)
databases is an optional dictionary of database definitions (structured like settings.DATABASES).
databases is an optional dictionary of database definitions (structured like settings.DATABASES).
def __init__(self, databases=None): """ databases is an optional dictionary of database definitions (structured like settings.DATABASES). """ self._databases = databases self._connections = local()
[ "def", "__init__", "(", "self", ",", "databases", "=", "None", ")", ":", "self", ".", "_databases", "=", "databases", "self", ".", "_connections", "=", "local", "(", ")" ]
[ 144, 4 ]
[ 150, 35 ]
python
en
['en', 'error', 'th']
False
ConnectionHandler.ensure_defaults
(self, alias)
Puts the defaults into the settings dictionary for a given connection where no settings is provided.
Puts the defaults into the settings dictionary for a given connection where no settings is provided.
def ensure_defaults(self, alias): """ Puts the defaults into the settings dictionary for a given connection where no settings is provided. """ try: conn = self.databases[alias] except KeyError: raise ConnectionDoesNotExist("The connection %s doesn'...
[ "def", "ensure_defaults", "(", "self", ",", "alias", ")", ":", "try", ":", "conn", "=", "self", ".", "databases", "[", "alias", "]", "except", "KeyError", ":", "raise", "ConnectionDoesNotExist", "(", "\"The connection %s doesn't exist\"", "%", "alias", ")", "c...
[ 169, 4 ]
[ 188, 40 ]
python
en
['en', 'error', 'th']
False