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
iri_to_uri
(iri)
Convert an Internationalized Resource Identifier (IRI) portion to a URI portion that is suitable for inclusion in a URL. This is the algorithm from section 3.1 of RFC 3987. However, since we are assuming input is either UTF-8 or unicode already, we can simplify things a little from the full metho...
Convert an Internationalized Resource Identifier (IRI) portion to a URI portion that is suitable for inclusion in a URL.
def iri_to_uri(iri): """ Convert an Internationalized Resource Identifier (IRI) portion to a URI portion that is suitable for inclusion in a URL. This is the algorithm from section 3.1 of RFC 3987. However, since we are assuming input is either UTF-8 or unicode already, we can simplify things a ...
[ "def", "iri_to_uri", "(", "iri", ")", ":", "# The list of safe characters here is constructed from the \"reserved\" and", "# \"unreserved\" characters specified in sections 2.2 and 2.3 of RFC 3986:", "# reserved = gen-delims / sub-delims", "# gen-delims = \":\" / \"/\" / \"?\" / \"#\" ...
[ 169, 0 ]
[ 196, 64 ]
python
en
['en', 'error', 'th']
False
uri_to_iri
(uri)
Converts a Uniform Resource Identifier(URI) into an Internationalized Resource Identifier(IRI). This is the algorithm from section 3.2 of RFC 3987. Takes an URI in ASCII bytes (e.g. '/I%20%E2%99%A5%20Django/') and returns unicode containing the encoded result (e.g. '/I \xe2\x99\xa5 Django/'). ...
Converts a Uniform Resource Identifier(URI) into an Internationalized Resource Identifier(IRI).
def uri_to_iri(uri): """ Converts a Uniform Resource Identifier(URI) into an Internationalized Resource Identifier(IRI). This is the algorithm from section 3.2 of RFC 3987. Takes an URI in ASCII bytes (e.g. '/I%20%E2%99%A5%20Django/') and returns unicode containing the encoded result (e.g. '/I...
[ "def", "uri_to_iri", "(", "uri", ")", ":", "if", "uri", "is", "None", ":", "return", "uri", "uri", "=", "force_bytes", "(", "uri", ")", "iri", "=", "unquote_to_bytes", "(", "uri", ")", "if", "six", ".", "PY3", "else", "unquote", "(", "uri", ")", "r...
[ 199, 0 ]
[ 213, 56 ]
python
en
['en', 'error', 'th']
False
escape_uri_path
(path)
Escape the unsafe characters from the path portion of a Uniform Resource Identifier (URI).
Escape the unsafe characters from the path portion of a Uniform Resource Identifier (URI).
def escape_uri_path(path): """ Escape the unsafe characters from the path portion of a Uniform Resource Identifier (URI). """ # These are the "reserved" and "unreserved" characters specified in # sections 2.2 and 2.3 of RFC 2396: # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+...
[ "def", "escape_uri_path", "(", "path", ")", ":", "# These are the \"reserved\" and \"unreserved\" characters specified in", "# sections 2.2 and 2.3 of RFC 2396:", "# reserved = \";\" | \"/\" | \"?\" | \":\" | \"@\" | \"&\" | \"=\" | \"+\" | \"$\" | \",\"", "# unreserved = alphanum | mark",...
[ 216, 0 ]
[ 230, 61 ]
python
en
['en', 'error', 'th']
False
repercent_broken_unicode
(path)
As per section 3.2 of RFC 3987, step three of converting a URI into an IRI, we need to re-percent-encode any octet produced that is not part of a strictly legal UTF-8 octet sequence.
As per section 3.2 of RFC 3987, step three of converting a URI into an IRI, we need to re-percent-encode any octet produced that is not part of a strictly legal UTF-8 octet sequence.
def repercent_broken_unicode(path): """ As per section 3.2 of RFC 3987, step three of converting a URI into an IRI, we need to re-percent-encode any octet produced that is not part of a strictly legal UTF-8 octet sequence. """ try: path.decode('utf-8') except UnicodeDecodeError as e:...
[ "def", "repercent_broken_unicode", "(", "path", ")", ":", "try", ":", "path", ".", "decode", "(", "'utf-8'", ")", "except", "UnicodeDecodeError", "as", "e", ":", "repercent", "=", "quote", "(", "path", "[", "e", ".", "start", ":", "e", ".", "end", "]",...
[ 233, 0 ]
[ 245, 15 ]
python
en
['en', 'error', 'th']
False
filepath_to_uri
(path)
Convert a file system path to a URI portion that is suitable for inclusion in a URL. We are assuming input is either UTF-8 or unicode already. This method will encode certain chars that would normally be recognized as special chars for URIs. Note that this method does not encode the ' character, ...
Convert a file system path to a URI portion that is suitable for inclusion in a URL.
def filepath_to_uri(path): """Convert a file system path to a URI portion that is suitable for inclusion in a URL. We are assuming input is either UTF-8 or unicode already. This method will encode certain chars that would normally be recognized as special chars for URIs. Note that this method doe...
[ "def", "filepath_to_uri", "(", "path", ")", ":", "if", "path", "is", "None", ":", "return", "path", "# I know about `os.sep` and `os.altsep` but I want to leave", "# some flexibility for hardcoding separators.", "return", "quote", "(", "force_bytes", "(", "path", ")", "."...
[ 248, 0 ]
[ 265, 73 ]
python
en
['en', 'en', 'en']
True
get_system_encoding
()
The encoding of the default system locale but falls back to the given fallback encoding if the encoding is unsupported by python or could not be determined. See tickets #10335 and #5846
The encoding of the default system locale but falls back to the given fallback encoding if the encoding is unsupported by python or could not be determined. See tickets #10335 and #5846
def get_system_encoding(): """ The encoding of the default system locale but falls back to the given fallback encoding if the encoding is unsupported by python or could not be determined. See tickets #10335 and #5846 """ try: encoding = locale.getdefaultlocale()[1] or 'ascii' co...
[ "def", "get_system_encoding", "(", ")", ":", "try", ":", "encoding", "=", "locale", ".", "getdefaultlocale", "(", ")", "[", "1", "]", "or", "'ascii'", "codecs", ".", "lookup", "(", "encoding", ")", "except", "Exception", ":", "encoding", "=", "'ascii'", ...
[ 268, 0 ]
[ 279, 19 ]
python
en
['en', 'error', 'th']
False
_get
(d, expected_type, key, default=None)
Get value from dictionary and verify expected type.
Get value from dictionary and verify expected type.
def _get(d, expected_type, key, default=None): # type: (Dict[str, Any], Type[T], str, Optional[T]) -> Optional[T] """Get value from dictionary and verify expected type.""" if key not in d: return default value = d[key] if six.PY2 and expected_type is str: expected_type = six.string_t...
[ "def", "_get", "(", "d", ",", "expected_type", ",", "key", ",", "default", "=", "None", ")", ":", "# type: (Dict[str, Any], Type[T], str, Optional[T]) -> Optional[T]", "if", "key", "not", "in", "d", ":", "return", "default", "value", "=", "d", "[", "key", "]",...
[ 31, 0 ]
[ 45, 16 ]
python
en
['en', 'en', 'en']
True
_filter_none
(**kwargs)
Make dict excluding None values.
Make dict excluding None values.
def _filter_none(**kwargs): # type: (Any) -> Dict[str, Any] """Make dict excluding None values.""" return {k: v for k, v in kwargs.items() if v is not None}
[ "def", "_filter_none", "(", "*", "*", "kwargs", ")", ":", "# type: (Any) -> Dict[str, Any]", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", "if", "v", "is", "not", "None", "}" ]
[ 71, 0 ]
[ 74, 61 ]
python
en
['en', 'en', 'en']
True
DirectUrl.redacted_url
(self)
url with user:password part removed unless it is formed with environment variables as specified in PEP 610, or it is ``git`` in the case of a git URL.
url with user:password part removed unless it is formed with environment variables as specified in PEP 610, or it is ``git`` in the case of a git URL.
def redacted_url(self): # type: () -> str """url with user:password part removed unless it is formed with environment variables as specified in PEP 610, or it is ``git`` in the case of a git URL. """ purl = urllib_parse.urlsplit(self.url) netloc = self._remove_aut...
[ "def", "redacted_url", "(", "self", ")", ":", "# type: () -> str", "purl", "=", "urllib_parse", ".", "urlsplit", "(", "self", ".", "url", ")", "netloc", "=", "self", ".", "_remove_auth_from_netloc", "(", "purl", ".", "netloc", ")", "surl", "=", "urllib_parse...
[ 194, 4 ]
[ 205, 19 ]
python
en
['en', 'en', 'en']
True
sequencer
()
Use like this: NEXT_ID = sequencer() message_id = NEXT_ID('message')
Use like this:
def sequencer() -> Callable[[str], int]: """ Use like this: NEXT_ID = sequencer() message_id = NEXT_ID('message') """ seq_dict: Dict[str, Callable[[], int]] = {} def next_one(name: str) -> int: if name not in seq_dict: seq_dict[name] = _seq() seq = seq_dict[name...
[ "def", "sequencer", "(", ")", "->", "Callable", "[", "[", "str", "]", ",", "int", "]", ":", "seq_dict", ":", "Dict", "[", "str", ",", "Callable", "[", "[", "]", ",", "int", "]", "]", "=", "{", "}", "def", "next_one", "(", "name", ":", "str", ...
[ 25, 0 ]
[ 40, 19 ]
python
en
['en', 'error', 'th']
False
indent_log
(num=2)
A context manager which will cause the log output to be indented for any log messages emitted inside it.
A context manager which will cause the log output to be indented for any log messages emitted inside it.
def indent_log(num=2): """ A context manager which will cause the log output to be indented for any log messages emitted inside it. """ # For thread-safety _log_state.indentation = get_indentation() _log_state.indentation += num try: yield finally: _log_state.indentat...
[ "def", "indent_log", "(", "num", "=", "2", ")", ":", "# For thread-safety", "_log_state", ".", "indentation", "=", "get_indentation", "(", ")", "_log_state", ".", "indentation", "+=", "num", "try", ":", "yield", "finally", ":", "_log_state", ".", "indentation"...
[ 100, 0 ]
[ 111, 37 ]
python
en
['en', 'error', 'th']
False
setup_logging
(verbosity, no_color, user_log_file)
Configures and sets up all of the logging Returns the requested logging level, as its integer value.
Configures and sets up all of the logging
def setup_logging(verbosity, no_color, user_log_file): """Configures and sets up all of the logging Returns the requested logging level, as its integer value. """ # Determine the level to be logging at. if verbosity >= 1: level = "DEBUG" elif verbosity == -1: level = "WARNING" ...
[ "def", "setup_logging", "(", "verbosity", ",", "no_color", ",", "user_log_file", ")", ":", "# Determine the level to be logging at.", "if", "verbosity", ">=", "1", ":", "level", "=", "\"DEBUG\"", "elif", "verbosity", "==", "-", "1", ":", "level", "=", "\"WARNING...
[ 277, 0 ]
[ 398, 23 ]
python
en
['en', 'en', 'en']
True
IndentingFormatter.__init__
(self, *args, **kwargs)
A logging.Formatter that obeys the indent_log() context manager. :param add_timestamp: A bool indicating output lines should be prefixed with their record's timestamp.
A logging.Formatter that obeys the indent_log() context manager.
def __init__(self, *args, **kwargs): """ A logging.Formatter that obeys the indent_log() context manager. :param add_timestamp: A bool indicating output lines should be prefixed with their record's timestamp. """ self.add_timestamp = kwargs.pop("add_timestamp", False...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "add_timestamp", "=", "kwargs", ".", "pop", "(", "\"add_timestamp\"", ",", "False", ")", "super", "(", "IndentingFormatter", ",", "self", ")", ".", "__ini...
[ 120, 4 ]
[ 128, 65 ]
python
en
['en', 'error', 'th']
False
IndentingFormatter.get_message_start
(self, formatted, levelno)
Return the start of the formatted log message (not counting the prefix to add to each line).
Return the start of the formatted log message (not counting the prefix to add to each line).
def get_message_start(self, formatted, levelno): """ Return the start of the formatted log message (not counting the prefix to add to each line). """ if levelno < logging.WARNING: return '' if formatted.startswith(DEPRECATION_MSG_PREFIX): # Then th...
[ "def", "get_message_start", "(", "self", ",", "formatted", ",", "levelno", ")", ":", "if", "levelno", "<", "logging", ".", "WARNING", ":", "return", "''", "if", "formatted", ".", "startswith", "(", "DEPRECATION_MSG_PREFIX", ")", ":", "# Then the message already ...
[ 130, 4 ]
[ 144, 24 ]
python
en
['en', 'error', 'th']
False
IndentingFormatter.format
(self, record)
Calls the standard formatter, but will indent all of the log message lines by our current indentation level.
Calls the standard formatter, but will indent all of the log message lines by our current indentation level.
def format(self, record): """ Calls the standard formatter, but will indent all of the log message lines by our current indentation level. """ formatted = super(IndentingFormatter, self).format(record) message_start = self.get_message_start(formatted, record.levelno) ...
[ "def", "format", "(", "self", ",", "record", ")", ":", "formatted", "=", "super", "(", "IndentingFormatter", ",", "self", ")", ".", "format", "(", "record", ")", "message_start", "=", "self", ".", "get_message_start", "(", "formatted", ",", "record", ".", ...
[ 146, 4 ]
[ 165, 24 ]
python
en
['en', 'error', 'th']
False
ColorizedStreamHandler._using_stdout
(self)
Return whether the handler is using sys.stdout.
Return whether the handler is using sys.stdout.
def _using_stdout(self): """ Return whether the handler is using sys.stdout. """ if WINDOWS and colorama: # Then self.stream is an AnsiToWin32 object. return self.stream.wrapped is sys.stdout return self.stream is sys.stdout
[ "def", "_using_stdout", "(", "self", ")", ":", "if", "WINDOWS", "and", "colorama", ":", "# Then self.stream is an AnsiToWin32 object.", "return", "self", ".", "stream", ".", "wrapped", "is", "sys", ".", "stdout", "return", "self", ".", "stream", "is", "sys", "...
[ 193, 4 ]
[ 201, 40 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_project_update_successful_message
(self)
Tests if ansibletower project update successful notification is handled correctly
Tests if ansibletower project update successful notification is handled correctly
def test_ansibletower_project_update_successful_message(self) -> None: """ Tests if ansibletower project update successful notification is handled correctly """ expected_topic = "AWX - Project Update" expected_message = ( "Project Update: [#2677 AWX - Project Update]"...
[ "def", "test_ansibletower_project_update_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"AWX - Project Update\"", "expected_message", "=", "(", "\"Project Update: [#2677 AWX - Project Update]\"", "\"(http://awx.example.co.uk/#/jobs/project/2677) was ...
[ 8, 4 ]
[ 18, 89 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_project_update_failed_message
(self)
Tests if ansibletower project update failed notification is handled correctly
Tests if ansibletower project update failed notification is handled correctly
def test_ansibletower_project_update_failed_message(self) -> None: """ Tests if ansibletower project update failed notification is handled correctly """ expected_topic = "AWX - Project Update" expected_message = ( "Project Update: [#2678 AWX - Project Update]" ...
[ "def", "test_ansibletower_project_update_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"AWX - Project Update\"", "expected_message", "=", "(", "\"Project Update: [#2678 AWX - Project Update]\"", "\"(http://awx.example.co.uk/#/jobs/project/2678) failed.\...
[ 20, 4 ]
[ 30, 85 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_job_successful_multiple_hosts_message
(self)
Tests if ansibletower job successful multiple hosts notification is handled correctly
Tests if ansibletower job successful multiple hosts notification is handled correctly
def test_ansibletower_job_successful_multiple_hosts_message(self) -> None: """ Tests if ansibletower job successful multiple hosts notification is handled correctly """ expected_topic = "System - Deploy - Zabbix Agent" expected_message = """ Job: [#2674 System - Deploy - Zabbix A...
[ "def", "test_ansibletower_job_successful_multiple_hosts_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"System - Deploy - Zabbix Agent\"", "expected_message", "=", "\"\"\"\nJob: [#2674 System - Deploy - Zabbix Agent](http://awx.example.co.uk/#/jobs/playbook/2674) w...
[ 32, 4 ]
[ 46, 93 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_job_successful_message
(self)
Tests if ansibletower job successful notification is handled correctly
Tests if ansibletower job successful notification is handled correctly
def test_ansibletower_job_successful_message(self) -> None: """ Tests if ansibletower job successful notification is handled correctly """ expected_topic = "System - Deploy - Zabbix Agent" expected_message = """ Job: [#2674 System - Deploy - Zabbix Agent](http://awx.example.co.uk...
[ "def", "test_ansibletower_job_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"System - Deploy - Zabbix Agent\"", "expected_message", "=", "\"\"\"\nJob: [#2674 System - Deploy - Zabbix Agent](http://awx.example.co.uk/#/jobs/playbook/2674) was successful:\...
[ 48, 4 ]
[ 58, 78 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_nine_job_successful_message
(self)
Test to see if awx/ansibletower 9.x.x job successful notifications are handled just as successfully as prior to 9.x.x.
Test to see if awx/ansibletower 9.x.x job successful notifications are handled just as successfully as prior to 9.x.x.
def test_ansibletower_nine_job_successful_message(self) -> None: """ Test to see if awx/ansibletower 9.x.x job successful notifications are handled just as successfully as prior to 9.x.x. """ expected_topic = "Demo Job Template" expected_message = """ Job: [#1 Demo Job Te...
[ "def", "test_ansibletower_nine_job_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Demo Job Template\"", "expected_message", "=", "\"\"\"\nJob: [#1 Demo Job Template](https://towerhost/#/jobs/playbook/1) was successful:\n* localhost: Success\n\"\"\"", ...
[ 60, 4 ]
[ 71, 97 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_job_failed_message
(self)
Tests if ansibletower job failed notification is handled correctly
Tests if ansibletower job failed notification is handled correctly
def test_ansibletower_job_failed_message(self) -> None: """ Tests if ansibletower job failed notification is handled correctly """ expected_topic = "System - Updates - Ubuntu" expected_message = """ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/2...
[ "def", "test_ansibletower_job_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"System - Updates - Ubuntu\"", "expected_message", "=", "\"\"\"\nJob: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/2722) failed:\n* chat.example.co.uk:...
[ 73, 4 ]
[ 83, 74 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_job_failed_multiple_hosts_message
(self)
Tests if ansibletower job failed notification is handled correctly
Tests if ansibletower job failed notification is handled correctly
def test_ansibletower_job_failed_multiple_hosts_message(self) -> None: """ Tests if ansibletower job failed notification is handled correctly """ expected_topic = "System - Updates - Ubuntu" expected_message = """ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/...
[ "def", "test_ansibletower_job_failed_multiple_hosts_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"System - Updates - Ubuntu\"", "expected_message", "=", "\"\"\"\nJob: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/2722) failed:\n* chat...
[ 85, 4 ]
[ 99, 89 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_inventory_update_successful_message
(self)
Tests if ansibletower inventory update successful notification is handled correctly
Tests if ansibletower inventory update successful notification is handled correctly
def test_ansibletower_inventory_update_successful_message(self) -> None: """ Tests if ansibletower inventory update successful notification is handled correctly """ expected_topic = "AWX - Inventory Update" expected_message = ( "Inventory Update: [#2724 AWX - Inventor...
[ "def", "test_ansibletower_inventory_update_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"AWX - Inventory Update\"", "expected_message", "=", "(", "\"Inventory Update: [#2724 AWX - Inventory Update]\"", "\"(http://awx.example.co.uk/#/jobs/inventory/...
[ 101, 4 ]
[ 111, 91 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_inventory_update_failed_message
(self)
Tests if ansibletower inventory update failed notification is handled correctly
Tests if ansibletower inventory update failed notification is handled correctly
def test_ansibletower_inventory_update_failed_message(self) -> None: """ Tests if ansibletower inventory update failed notification is handled correctly """ expected_topic = "AWX - Inventory Update" expected_message = ( "Inventory Update: [#2724 AWX - Inventory Update...
[ "def", "test_ansibletower_inventory_update_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"AWX - Inventory Update\"", "expected_message", "=", "(", "\"Inventory Update: [#2724 AWX - Inventory Update]\"", "\"(http://awx.example.co.uk/#/jobs/inventory/2724...
[ 113, 4 ]
[ 123, 87 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_adhoc_command_successful_message
(self)
Tests if ansibletower adhoc command successful notification is handled correctly
Tests if ansibletower adhoc command successful notification is handled correctly
def test_ansibletower_adhoc_command_successful_message(self) -> None: """ Tests if ansibletower adhoc command successful notification is handled correctly """ expected_topic = "shell: uname -r" expected_message = ( "AdHoc Command: [#2726 shell: uname -r]" ...
[ "def", "test_ansibletower_adhoc_command_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"shell: uname -r\"", "expected_message", "=", "(", "\"AdHoc Command: [#2726 shell: uname -r]\"", "\"(http://awx.example.co.uk/#/jobs/command/2726) was successful.\...
[ 125, 4 ]
[ 135, 88 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_adhoc_command_failed_message
(self)
Tests if ansibletower adhoc command failed notification is handled correctly
Tests if ansibletower adhoc command failed notification is handled correctly
def test_ansibletower_adhoc_command_failed_message(self) -> None: """ Tests if ansibletower adhoc command failed notification is handled correctly """ expected_topic = "shell: uname -r" expected_message = ( "AdHoc Command: [#2726 shell: uname -r]" "(http:/...
[ "def", "test_ansibletower_adhoc_command_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"shell: uname -r\"", "expected_message", "=", "(", "\"AdHoc Command: [#2726 shell: uname -r]\"", "\"(http://awx.example.co.uk/#/jobs/command/2726) failed.\"", ")", ...
[ 137, 4 ]
[ 147, 84 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_system_job_successful_message
(self)
Tests if ansibletower system job successful notification is handled correctly
Tests if ansibletower system job successful notification is handled correctly
def test_ansibletower_system_job_successful_message(self) -> None: """ Tests if ansibletower system job successful notification is handled correctly """ expected_topic = "Cleanup Job Details" expected_message = ( "System Job: [#2721 Cleanup Job Details]" "...
[ "def", "test_ansibletower_system_job_successful_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Cleanup Job Details\"", "expected_message", "=", "(", "\"System Job: [#2721 Cleanup Job Details]\"", "\"(http://awx.example.co.uk/#/jobs/system/2721) was successful....
[ 149, 4 ]
[ 159, 85 ]
python
en
['en', 'error', 'th']
False
AnsibletowerHookTests.test_ansibletower_system_job_failed_message
(self)
Tests if ansibletower system job failed notification is handled correctly
Tests if ansibletower system job failed notification is handled correctly
def test_ansibletower_system_job_failed_message(self) -> None: """ Tests if ansibletower system job failed notification is handled correctly """ expected_topic = "Cleanup Job Details" expected_message = ( "System Job: [#2721 Cleanup Job Details]" "(http://...
[ "def", "test_ansibletower_system_job_failed_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Cleanup Job Details\"", "expected_message", "=", "(", "\"System Job: [#2721 Cleanup Job Details]\"", "\"(http://awx.example.co.uk/#/jobs/system/2721) failed.\"", ")", ...
[ 161, 4 ]
[ 171, 81 ]
python
en
['en', 'error', 'th']
False
Redirect.add_redirect
(old_path, redirect_to=None, is_permanent=True)
Create and save a Redirect instance with a single method. :param old_path: the path you wish to redirect :param redirect_to: a Page (instance) or path (string) where the redirect should point :param is_permanent: whether the redirect should be indicated as permanent (i.e. 301 redirect)...
Create and save a Redirect instance with a single method.
def add_redirect(old_path, redirect_to=None, is_permanent=True): """ Create and save a Redirect instance with a single method. :param old_path: the path you wish to redirect :param redirect_to: a Page (instance) or path (string) where the redirect should point :param is_permanen...
[ "def", "add_redirect", "(", "old_path", ",", "redirect_to", "=", "None", ",", "is_permanent", "=", "True", ")", ":", "redirect", "=", "Redirect", "(", ")", "# Set redirect properties from input parameters", "redirect", ".", "old_path", "=", "Redirect", ".", "norma...
[ 57, 4 ]
[ 83, 23 ]
python
en
['en', 'error', 'th']
False
Statsd.__init__
(self, cfg)
host, port: statsD server
host, port: statsD server
def __init__(self, cfg): """host, port: statsD server """ Logger.__init__(self, cfg) self.prefix = sub(r"^(.+[^.]+)\.*$", "\\g<1>.", cfg.statsd_prefix) try: host, port = cfg.statsd_host self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ...
[ "def", "__init__", "(", "self", ",", "cfg", ")", ":", "Logger", ".", "__init__", "(", "self", ",", "cfg", ")", "self", ".", "prefix", "=", "sub", "(", "r\"^(.+[^.]+)\\.*$\"", ",", "\"\\\\g<1>.\"", ",", "cfg", ".", "statsd_prefix", ")", "try", ":", "hos...
[ 24, 4 ]
[ 36, 48 ]
python
en
['es', 'no', 'en']
False
Statsd.log
(self, lvl, msg, *args, **kwargs)
Log a given statistic if metric, value and type are present
Log a given statistic if metric, value and type are present
def log(self, lvl, msg, *args, **kwargs): """Log a given statistic if metric, value and type are present """ try: extra = kwargs.get("extra", None) if extra is not None: metric = extra.get(METRIC_VAR, None) value = extra.get(VALUE_VAR, None...
[ "def", "log", "(", "self", ",", "lvl", ",", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "extra", "=", "kwargs", ".", "get", "(", "\"extra\"", ",", "None", ")", "if", "extra", "is", "not", "None", ":", "metric", "=", ...
[ 63, 4 ]
[ 86, 74 ]
python
en
['en', 'en', 'en']
True
Statsd.access
(self, resp, req, environ, request_time)
Measure request duration request_time is a datetime.timedelta
Measure request duration request_time is a datetime.timedelta
def access(self, resp, req, environ, request_time): """Measure request duration request_time is a datetime.timedelta """ Logger.access(self, resp, req, environ, request_time) duration_in_ms = request_time.seconds * 1000 + float(request_time.microseconds) / 10 ** 3 status ...
[ "def", "access", "(", "self", ",", "resp", ",", "req", ",", "environ", ",", "request_time", ")", ":", "Logger", ".", "access", "(", "self", ",", "resp", ",", "req", ",", "environ", ",", "request_time", ")", "duration_in_ms", "=", "request_time", ".", "...
[ 89, 4 ]
[ 100, 64 ]
python
en
['en', 'fr', 'en']
True
main
()
Main execution
Main execution
def main(): """Main execution""" AzureRMCosmosDBAccount()
[ "def", "main", "(", ")", ":", "AzureRMCosmosDBAccount", "(", ")" ]
[ 587, 0 ]
[ 589, 28 ]
python
en
['nl', 'su', 'en']
False
AzureRMCosmosDBAccount.exec_module
(self, **kwargs)
Main module execution method
Main module execution method
def exec_module(self, **kwargs): """Main module execution method""" for key in list(self.module_arg_spec.keys()) + ['tags']: if hasattr(self, key): setattr(self, key, kwargs[key]) elif kwargs[key] is not None: self.parameters[key] = kwargs[key] ...
[ "def", "exec_module", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "key", "in", "list", "(", "self", ".", "module_arg_spec", ".", "keys", "(", ")", ")", "+", "[", "'tags'", "]", ":", "if", "hasattr", "(", "self", ",", "key", ")", ":", ...
[ 324, 4 ]
[ 417, 27 ]
python
en
['nl', 'sm', 'en']
False
AzureRMCosmosDBAccount.create_update_databaseaccount
(self)
Creates or updates Database Account with the specified configuration. :return: deserialized Database Account instance state dictionary
Creates or updates Database Account with the specified configuration.
def create_update_databaseaccount(self): ''' Creates or updates Database Account with the specified configuration. :return: deserialized Database Account instance state dictionary ''' self.log("Creating / Updating the Database Account instance {0}".format(self.name)) tr...
[ "def", "create_update_databaseaccount", "(", "self", ")", ":", "self", ".", "log", "(", "\"Creating / Updating the Database Account instance {0}\"", ".", "format", "(", "self", ".", "name", ")", ")", "try", ":", "response", "=", "self", ".", "mgmt_client", ".", ...
[ 419, 4 ]
[ 437, 33 ]
python
en
['en', 'error', 'th']
False
AzureRMCosmosDBAccount.delete_databaseaccount
(self)
Deletes specified Database Account instance in the specified subscription and resource group. :return: True
Deletes specified Database Account instance in the specified subscription and resource group.
def delete_databaseaccount(self): ''' Deletes specified Database Account instance in the specified subscription and resource group. :return: True ''' self.log("Deleting the Database Account instance {0}".format(self.name)) try: response = self.mgmt_client.dat...
[ "def", "delete_databaseaccount", "(", "self", ")", ":", "self", ".", "log", "(", "\"Deleting the Database Account instance {0}\"", ".", "format", "(", "self", ".", "name", ")", ")", "try", ":", "response", "=", "self", ".", "mgmt_client", ".", "database_accounts...
[ 439, 4 ]
[ 457, 19 ]
python
en
['en', 'error', 'th']
False
AzureRMCosmosDBAccount.get_databaseaccount
(self)
Gets the properties of the specified Database Account. :return: deserialized Database Account instance state dictionary
Gets the properties of the specified Database Account.
def get_databaseaccount(self): ''' Gets the properties of the specified Database Account. :return: deserialized Database Account instance state dictionary ''' self.log("Checking if the Database Account instance {0} is present".format(self.name)) found = False try...
[ "def", "get_databaseaccount", "(", "self", ")", ":", "self", ".", "log", "(", "\"Checking if the Database Account instance {0} is present\"", ".", "format", "(", "self", ".", "name", ")", ")", "found", "=", "False", "try", ":", "response", "=", "self", ".", "m...
[ 459, 4 ]
[ 478, 20 ]
python
en
['en', 'error', 'th']
False
TestValidation.test_can_create
(self)
Check that basic page creation works
Check that basic page creation works
def test_can_create(self): """ Check that basic page creation works """ homepage = Page.objects.get(url_path='/home/') hello_page = SimplePage(title="Hello world", slug='hello-world', content="hello") homepage.add_child(instance=hello_page) # check that hello_pag...
[ "def", "test_can_create", "(", "self", ")", ":", "homepage", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/'", ")", "hello_page", "=", "SimplePage", "(", "title", "=", "\"Hello world\"", ",", "slug", "=", "'hello-world'", ",", "con...
[ 42, 4 ]
[ 52, 61 ]
python
en
['en', 'error', 'th']
False
TestCopyPage.test_copy_page_copies_parental_relations
(self)
Test that a page will be copied with parental many to many relations intact.
Test that a page will be copied with parental many to many relations intact.
def test_copy_page_copies_parental_relations(self): """Test that a page will be copied with parental many to many relations intact.""" christmas_event = EventPage.objects.get(url_path='/home/events/christmas/') summer_category = EventCategory.objects.create(name='Summer') holiday_categor...
[ "def", "test_copy_page_copies_parental_relations", "(", "self", ")", ":", "christmas_event", "=", "EventPage", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/events/christmas/'", ")", "summer_category", "=", "EventCategory", ".", "objects", ".", "create", ...
[ 1114, 4 ]
[ 1147, 9 ]
python
en
['en', 'en', 'en']
True
TestCopyPage.test_copy_page_with_excluded_parental_and_child_relations
(self)
Test that a page will be copied with parental and child relations removed if excluded.
Test that a page will be copied with parental and child relations removed if excluded.
def test_copy_page_with_excluded_parental_and_child_relations(self): """Test that a page will be copied with parental and child relations removed if excluded.""" try: # modify excluded fields for this test EventPage.exclude_fields_in_copy = ['advert_placements', 'categories', 's...
[ "def", "test_copy_page_with_excluded_parental_and_child_relations", "(", "self", ")", ":", "try", ":", "# modify excluded fields for this test", "EventPage", ".", "exclude_fields_in_copy", "=", "[", "'advert_placements'", ",", "'categories'", ",", "'signup_link'", "]", "# set...
[ 1633, 4 ]
[ 1691, 49 ]
python
en
['en', 'en', 'en']
True
TestCopyPage.test_copy_unsaved_page
(self)
Test that unsaved page will not be copied.
Test that unsaved page will not be copied.
def test_copy_unsaved_page(self): """Test that unsaved page will not be copied.""" new_page = SimplePage(slug='testpurp', title='testpurpose') with self.assertRaises(RuntimeError): new_page.copy()
[ "def", "test_copy_unsaved_page", "(", "self", ")", ":", "new_page", "=", "SimplePage", "(", "slug", "=", "'testpurp'", ",", "title", "=", "'testpurpose'", ")", "with", "self", ".", "assertRaises", "(", "RuntimeError", ")", ":", "new_page", ".", "copy", "(", ...
[ 1693, 4 ]
[ 1697, 27 ]
python
en
['en', 'en', 'en']
True
TestCopyPage.test_copy_published_emits_signal
(self)
Test that copying of a published page emits a page_published signal.
Test that copying of a published page emits a page_published signal.
def test_copy_published_emits_signal(self): """Test that copying of a published page emits a page_published signal.""" christmas_page = EventPage.objects.get(url_path='/home/events/christmas/') signal_fired = False signal_page = None def page_published_handler(sender, instance,...
[ "def", "test_copy_published_emits_signal", "(", "self", ")", ":", "christmas_page", "=", "EventPage", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/events/christmas/'", ")", "signal_fired", "=", "False", "signal_page", "=", "None", "def", "page_published...
[ 1699, 4 ]
[ 1718, 48 ]
python
en
['en', 'en', 'en']
True
TestCopyPage.test_copy_unpublished_not_emits_signal
(self)
Test that copying of an unpublished page not emits a page_published signal.
Test that copying of an unpublished page not emits a page_published signal.
def test_copy_unpublished_not_emits_signal(self): """Test that copying of an unpublished page not emits a page_published signal.""" homepage = Page.objects.get(url_path='/home/') homepage.live = False homepage.save() signal_fired = False def page_published_handler(sende...
[ "def", "test_copy_unpublished_not_emits_signal", "(", "self", ")", ":", "homepage", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/'", ")", "homepage", ".", "live", "=", "False", "homepage", ".", "save", "(", ")", "signal_fired", "=",...
[ 1720, 4 ]
[ 1734, 38 ]
python
en
['en', 'en', 'en']
True
TestCopyPage.test_copy_keep_live_false_not_emits_signal
(self)
Test that copying of a live page with keep_live=False not emits a page_published signal.
Test that copying of a live page with keep_live=False not emits a page_published signal.
def test_copy_keep_live_false_not_emits_signal(self): """Test that copying of a live page with keep_live=False not emits a page_published signal.""" homepage = Page.objects.get(url_path='/home/') signal_fired = False def page_published_handler(sender, instance, **kwargs): no...
[ "def", "test_copy_keep_live_false_not_emits_signal", "(", "self", ")", ":", "homepage", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/'", ")", "signal_fired", "=", "False", "def", "page_published_handler", "(", "sender", ",", "instance", ...
[ 1736, 4 ]
[ 1750, 38 ]
python
en
['en', 'en', 'en']
True
TestCreateAlias.test_create_alias_copies_parental_relations
(self)
Test that a page will be copied with parental many to many relations intact.
Test that a page will be copied with parental many to many relations intact.
def test_create_alias_copies_parental_relations(self): """Test that a page will be copied with parental many to many relations intact.""" christmas_event = EventPage.objects.get(url_path='/home/events/christmas/') summer_category = EventCategory.objects.create(name='Summer') holiday_cate...
[ "def", "test_create_alias_copies_parental_relations", "(", "self", ")", ":", "christmas_event", "=", "EventPage", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/events/christmas/'", ")", "summer_category", "=", "EventCategory", ".", "objects", ".", "create"...
[ 1822, 4 ]
[ 1853, 9 ]
python
en
['en', 'en', 'en']
True
TestCreateAlias.test_create_alias_with_excluded_parental_and_child_relations
(self)
Test that a page will be copied with parental and child relations removed if excluded.
Test that a page will be copied with parental and child relations removed if excluded.
def test_create_alias_with_excluded_parental_and_child_relations(self): """Test that a page will be copied with parental and child relations removed if excluded.""" try: # modify excluded fields for this test EventPage.exclude_fields_in_copy = ['advert_placements', 'categories',...
[ "def", "test_create_alias_with_excluded_parental_and_child_relations", "(", "self", ")", ":", "try", ":", "# modify excluded fields for this test", "EventPage", ".", "exclude_fields_in_copy", "=", "[", "'advert_placements'", ",", "'categories'", ",", "'signup_link'", "]", "# ...
[ 2060, 4 ]
[ 2116, 49 ]
python
en
['en', 'en', 'en']
True
escape
(text)
Returns the given text with ampersands, quotes and angle brackets encoded for use in HTML. This function always escapes its input, even if it's already escaped and marked as such. This may result in double-escaping. If this is a concern, use conditional_escape() instead.
Returns the given text with ampersands, quotes and angle brackets encoded for use in HTML.
def escape(text): """ Returns the given text with ampersands, quotes and angle brackets encoded for use in HTML. This function always escapes its input, even if it's already escaped and marked as such. This may result in double-escaping. If this is a concern, use conditional_escape() instead. ...
[ "def", "escape", "(", "text", ")", ":", "return", "mark_safe", "(", "force_text", "(", "text", ")", ".", "replace", "(", "'&'", ",", "'&amp;'", ")", ".", "replace", "(", "'<'", ",", "'&lt;'", ")", ".", "replace", "(", "'>'", ",", "'&gt;'", ")", "."...
[ 38, 0 ]
[ 50, 5 ]
python
en
['en', 'error', 'th']
False
escapejs
(value)
Hex encodes characters for use in JavaScript strings.
Hex encodes characters for use in JavaScript strings.
def escapejs(value): """Hex encodes characters for use in JavaScript strings.""" return mark_safe(force_text(value).translate(_js_escapes))
[ "def", "escapejs", "(", "value", ")", ":", "return", "mark_safe", "(", "force_text", "(", "value", ")", ".", "translate", "(", "_js_escapes", ")", ")" ]
[ 73, 0 ]
[ 75, 62 ]
python
en
['en', 'en', 'en']
True
conditional_escape
(text)
Similar to escape(), except that it doesn't operate on pre-escaped strings. This function relies on the __html__ convention used both by Django's SafeData class and by third-party libraries like markupsafe.
Similar to escape(), except that it doesn't operate on pre-escaped strings.
def conditional_escape(text): """ Similar to escape(), except that it doesn't operate on pre-escaped strings. This function relies on the __html__ convention used both by Django's SafeData class and by third-party libraries like markupsafe. """ if hasattr(text, '__html__'): return text....
[ "def", "conditional_escape", "(", "text", ")", ":", "if", "hasattr", "(", "text", ",", "'__html__'", ")", ":", "return", "text", ".", "__html__", "(", ")", "else", ":", "return", "escape", "(", "text", ")" ]
[ 78, 0 ]
[ 88, 27 ]
python
en
['en', 'error', 'th']
False
format_html
(format_string, *args, **kwargs)
Similar to str.format, but passes all arguments through conditional_escape, and calls 'mark_safe' on the result. This function should be used instead of str.format or % interpolation to build up small HTML fragments.
Similar to str.format, but passes all arguments through conditional_escape, and calls 'mark_safe' on the result. This function should be used instead of str.format or % interpolation to build up small HTML fragments.
def format_html(format_string, *args, **kwargs): """ Similar to str.format, but passes all arguments through conditional_escape, and calls 'mark_safe' on the result. This function should be used instead of str.format or % interpolation to build up small HTML fragments. """ args_safe = map(condit...
[ "def", "format_html", "(", "format_string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "args_safe", "=", "map", "(", "conditional_escape", ",", "args", ")", "kwargs_safe", "=", "{", "k", ":", "conditional_escape", "(", "v", ")", "for", "(", "...
[ 91, 0 ]
[ 99, 69 ]
python
en
['en', 'error', 'th']
False
format_html_join
(sep, format_string, args_generator)
A wrapper of format_html, for the common case of a group of arguments that need to be formatted using the same format string, and then joined using 'sep'. 'sep' is also passed through conditional_escape. 'args_generator' should be an iterator that returns the sequence of 'args' that will be passed...
A wrapper of format_html, for the common case of a group of arguments that need to be formatted using the same format string, and then joined using 'sep'. 'sep' is also passed through conditional_escape.
def format_html_join(sep, format_string, args_generator): """ A wrapper of format_html, for the common case of a group of arguments that need to be formatted using the same format string, and then joined using 'sep'. 'sep' is also passed through conditional_escape. 'args_generator' should be an ite...
[ "def", "format_html_join", "(", "sep", ",", "format_string", ",", "args_generator", ")", ":", "return", "mark_safe", "(", "conditional_escape", "(", "sep", ")", ".", "join", "(", "format_html", "(", "format_string", ",", "*", "tuple", "(", "args", ")", ")", ...
[ 102, 0 ]
[ 118, 36 ]
python
en
['en', 'error', 'th']
False
linebreaks
(value, autoescape=False)
Converts newlines into <p> and <br />s.
Converts newlines into <p> and <br />s.
def linebreaks(value, autoescape=False): """Converts newlines into <p> and <br />s.""" value = normalize_newlines(force_text(value)) paras = re.split('\n{2,}', value) if autoescape: paras = ['<p>%s</p>' % escape(p).replace('\n', '<br />') for p in paras] else: paras = ['<p>%s</p>' % ...
[ "def", "linebreaks", "(", "value", ",", "autoescape", "=", "False", ")", ":", "value", "=", "normalize_newlines", "(", "force_text", "(", "value", ")", ")", "paras", "=", "re", ".", "split", "(", "'\\n{2,}'", ",", "value", ")", "if", "autoescape", ":", ...
[ 122, 0 ]
[ 130, 29 ]
python
en
['en', 'en', 'en']
True
_strip_once
(value)
Internal tag stripping utility used by strip_tags.
Internal tag stripping utility used by strip_tags.
def _strip_once(value): """ Internal tag stripping utility used by strip_tags. """ s = MLStripper() try: s.feed(value) except HTMLParseError: return value try: s.close() except HTMLParseError: return s.get_data() + s.rawdata else: return s.get_...
[ "def", "_strip_once", "(", "value", ")", ":", "s", "=", "MLStripper", "(", ")", "try", ":", "s", ".", "feed", "(", "value", ")", "except", "HTMLParseError", ":", "return", "value", "try", ":", "s", ".", "close", "(", ")", "except", "HTMLParseError", ...
[ 152, 0 ]
[ 166, 27 ]
python
en
['en', 'error', 'th']
False
strip_tags
(value)
Returns the given HTML with all tags stripped.
Returns the given HTML with all tags stripped.
def strip_tags(value): """Returns the given HTML with all tags stripped.""" # Note: in typical case this loop executes _strip_once once. Loop condition # is redundant, but helps to reduce number of executions of _strip_once. value = force_text(value) while '<' in value and '>' in value: new_...
[ "def", "strip_tags", "(", "value", ")", ":", "# Note: in typical case this loop executes _strip_once once. Loop condition", "# is redundant, but helps to reduce number of executions of _strip_once.", "value", "=", "force_text", "(", "value", ")", "while", "'<'", "in", "value", "a...
[ 170, 0 ]
[ 183, 16 ]
python
en
['en', 'en', 'en']
True
strip_spaces_between_tags
(value)
Returns the given HTML with spaces between tags removed.
Returns the given HTML with spaces between tags removed.
def strip_spaces_between_tags(value): """Returns the given HTML with spaces between tags removed.""" return re.sub(r'>\s+<', '><', force_text(value))
[ "def", "strip_spaces_between_tags", "(", "value", ")", ":", "return", "re", ".", "sub", "(", "r'>\\s+<'", ",", "'><'", ",", "force_text", "(", "value", ")", ")" ]
[ 187, 0 ]
[ 189, 52 ]
python
en
['en', 'en', 'en']
True
smart_urlquote
(url)
Quotes a URL if it isn't already quoted.
Quotes a URL if it isn't already quoted.
def smart_urlquote(url): "Quotes a URL if it isn't already quoted." def unquote_quote(segment): segment = unquote(force_str(segment)) # Tilde is part of RFC3986 Unreserved Characters # http://tools.ietf.org/html/rfc3986#section-2.3 # See also http://bugs.python.org/issue16285 ...
[ "def", "smart_urlquote", "(", "url", ")", ":", "def", "unquote_quote", "(", "segment", ")", ":", "segment", "=", "unquote", "(", "force_str", "(", "segment", ")", ")", "# Tilde is part of RFC3986 Unreserved Characters", "# http://tools.ietf.org/html/rfc3986#section-2.3", ...
[ 192, 0 ]
[ 225, 62 ]
python
en
['en', 'en', 'en']
True
urlize
(text, trim_url_limit=None, nofollow=False, autoescape=False)
Converts any URLs in text into clickable links. Works on http://, https://, www. links, and also on links ending in one of the original seven gTLDs (.com, .edu, .gov, .int, .mil, .net, and .org). Links can have trailing punctuation (periods, commas, close-parens) and leading punctuation (opening p...
Converts any URLs in text into clickable links.
def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False): """ Converts any URLs in text into clickable links. Works on http://, https://, www. links, and also on links ending in one of the original seven gTLDs (.com, .edu, .gov, .int, .mil, .net, and .org). Links can have trailing pu...
[ "def", "urlize", "(", "text", ",", "trim_url_limit", "=", "None", ",", "nofollow", "=", "False", ",", "autoescape", "=", "False", ")", ":", "safe_input", "=", "isinstance", "(", "text", ",", "SafeData", ")", "def", "trim_url", "(", "x", ",", "limit", "...
[ 229, 0 ]
[ 347, 25 ]
python
en
['en', 'error', 'th']
False
avoid_wrapping
(value)
Avoid text wrapping in the middle of a phrase by adding non-breaking spaces where there previously were normal spaces.
Avoid text wrapping in the middle of a phrase by adding non-breaking spaces where there previously were normal spaces.
def avoid_wrapping(value): """ Avoid text wrapping in the middle of a phrase by adding non-breaking spaces where there previously were normal spaces. """ return value.replace(" ", "\xa0")
[ "def", "avoid_wrapping", "(", "value", ")", ":", "return", "value", ".", "replace", "(", "\" \"", ",", "\"\\xa0\"", ")" ]
[ 350, 0 ]
[ 355, 37 ]
python
en
['en', 'error', 'th']
False
html_safe
(klass)
A decorator that defines the __html__ method. This helps non-Django templates to detect classes whose __str__ methods return SafeText.
A decorator that defines the __html__ method. This helps non-Django templates to detect classes whose __str__ methods return SafeText.
def html_safe(klass): """ A decorator that defines the __html__ method. This helps non-Django templates to detect classes whose __str__ methods return SafeText. """ if '__html__' in klass.__dict__: raise ValueError( "can't apply @html_safe to %s because it defines " "...
[ "def", "html_safe", "(", "klass", ")", ":", "if", "'__html__'", "in", "klass", ".", "__dict__", ":", "raise", "ValueError", "(", "\"can't apply @html_safe to %s because it defines \"", "\"__html__().\"", "%", "klass", ".", "__name__", ")", "if", "six", ".", "PY2",...
[ 358, 0 ]
[ 386, 16 ]
python
en
['en', 'error', 'th']
False
CallbackErrorTestCase.crappy_callback
(self, conn)
green callback failing after `self.to_error` time it is called
green callback failing after `self.to_error` time it is called
def crappy_callback(self, conn): """green callback failing after `self.to_error` time it is called""" import select from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE while 1: if self.to_error is not None: self.to_error -= 1 if sel...
[ "def", "crappy_callback", "(", "self", ",", "conn", ")", ":", "import", "select", "from", "psycopg2", ".", "extensions", "import", "POLL_OK", ",", "POLL_READ", ",", "POLL_WRITE", "while", "1", ":", "if", "self", ".", "to_error", "is", "not", "None", ":", ...
[ 125, 4 ]
[ 148, 24 ]
python
en
['en', 'en', 'en']
True
SQLCompiler.as_sql
(self, with_limits=True, with_col_aliases=False)
Creates the SQL for this query. Returns the SQL string and list of parameters. This is overridden from the original Query class to handle the additional SQL Oracle requires to emulate LIMIT and OFFSET. If 'with_limits' is False, any limit/offset information is not incl...
Creates the SQL for this query. Returns the SQL string and list of parameters. This is overridden from the original Query class to handle the additional SQL Oracle requires to emulate LIMIT and OFFSET.
def as_sql(self, with_limits=True, with_col_aliases=False): """ Creates the SQL for this query. Returns the SQL string and list of parameters. This is overridden from the original Query class to handle the additional SQL Oracle requires to emulate LIMIT and OFFSET. If '...
[ "def", "as_sql", "(", "self", ",", "with_limits", "=", "True", ",", "with_col_aliases", "=", "False", ")", ":", "# The `do_offset` flag indicates whether we need to construct", "# the SQL needed to use limit/offset with Oracle.", "do_offset", "=", "with_limits", "and", "(", ...
[ 4, 4 ]
[ 45, 26 ]
python
en
['en', 'error', 'th']
False
_ctit_db_wrapper
(trans_safe=False)
Wrapper to avoid undesired actions by Django ORM when managing settings if only getting a setting, can use trans_safe=True, which will avoid throwing errors if the prior context was a broken transaction. Any database errors will be logged, but exception will be suppressed.
Wrapper to avoid undesired actions by Django ORM when managing settings if only getting a setting, can use trans_safe=True, which will avoid throwing errors if the prior context was a broken transaction. Any database errors will be logged, but exception will be suppressed.
def _ctit_db_wrapper(trans_safe=False): """ Wrapper to avoid undesired actions by Django ORM when managing settings if only getting a setting, can use trans_safe=True, which will avoid throwing errors if the prior context was a broken transaction. Any database errors will be logged, but exception wi...
[ "def", "_ctit_db_wrapper", "(", "trans_safe", "=", "False", ")", ":", "rollback_set", "=", "None", "is_atomic", "=", "None", "try", ":", "if", "trans_safe", ":", "is_atomic", "=", "connection", ".", "in_atomic_block", "if", "is_atomic", ":", "rollback_set", "=...
[ 63, 0 ]
[ 98, 50 ]
python
en
['en', 'error', 'th']
False
get_cache_value
(value)
Returns the proper special cache setting for a value based on instance type.
Returns the proper special cache setting for a value based on instance type.
def get_cache_value(value): """Returns the proper special cache setting for a value based on instance type. """ if value is None: value = SETTING_CACHE_NONE elif isinstance(value, (list, tuple)) and len(value) == 0: value = SETTING_CACHE_EMPTY_LIST elif isinstance(value, (dict,))...
[ "def", "get_cache_value", "(", "value", ")", ":", "if", "value", "is", "None", ":", "value", "=", "SETTING_CACHE_NONE", "elif", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ")", ")", "and", "len", "(", "value", ")", "==", "0", ":", "va...
[ 191, 0 ]
[ 201, 16 ]
python
en
['en', 'en', 'en']
True
EncryptedCacheProxy.__init__
(self, cache, registry, encrypter=None, decrypter=None)
This proxy wraps a Django cache backend and overwrites the `get`/`set`/`set_many` methods to handle field encryption/decryption for sensitive values. :param cache: the Django cache backend to proxy to :param registry: the settings registry instance used to determine if ...
This proxy wraps a Django cache backend and overwrites the `get`/`set`/`set_many` methods to handle field encryption/decryption for sensitive values.
def __init__(self, cache, registry, encrypter=None, decrypter=None): """ This proxy wraps a Django cache backend and overwrites the `get`/`set`/`set_many` methods to handle field encryption/decryption for sensitive values. :param cache: the Django cache backend to proxy to ...
[ "def", "__init__", "(", "self", ",", "cache", ",", "registry", ",", "encrypter", "=", "None", ",", "decrypter", "=", "None", ")", ":", "# These values have to be stored via self.__dict__ in this way to get", "# around the magic __setattr__ method on this class.", "self", "....
[ 117, 4 ]
[ 137, 63 ]
python
en
['en', 'error', 'th']
False
SettingsWrapper.initialize
(cls, cache=None, registry=None)
Used to initialize and wrap the Django settings context. :param cache: the Django cache backend to use for caching setting values. ``django.core.cache`` is used by default. :param registry: the settings registry instance used. The global ``awx.conf.settings_registry`` is used...
Used to initialize and wrap the Django settings context.
def initialize(cls, cache=None, registry=None): """ Used to initialize and wrap the Django settings context. :param cache: the Django cache backend to use for caching setting values. ``django.core.cache`` is used by default. :param registry: the settings registry instance used....
[ "def", "initialize", "(", "cls", ",", "cache", "=", "None", ",", "registry", "=", "None", ")", ":", "if", "not", "getattr", "(", "settings", ",", "'_awx_conf_settings'", ",", "False", ")", ":", "settings_wrapper", "=", "cls", "(", "settings", ".", "_wrap...
[ 206, 4 ]
[ 217, 48 ]
python
en
['en', 'error', 'th']
False
SettingsWrapper.__init__
(self, default_settings, cache, registry)
This constructor is generally not called directly, but by ``SettingsWrapper.initialize`` at app startup time when settings are parsed.
This constructor is generally not called directly, but by ``SettingsWrapper.initialize`` at app startup time when settings are parsed.
def __init__(self, default_settings, cache, registry): """ This constructor is generally not called directly, but by ``SettingsWrapper.initialize`` at app startup time when settings are parsed. """ # These values have to be stored via self.__dict__ in this way to get ...
[ "def", "__init__", "(", "self", ",", "default_settings", ",", "cache", ",", "registry", ")", ":", "# These values have to be stored via self.__dict__ in this way to get", "# around the magic __setattr__ method on this class (which is used to", "# store API-assigned settings in the databa...
[ 219, 4 ]
[ 240, 42 ]
python
en
['en', 'error', 'th']
False
BaseUserManager.normalize_email
(cls, email)
Normalize the email address by lowercasing the domain part of it.
Normalize the email address by lowercasing the domain part of it.
def normalize_email(cls, email): """ Normalize the email address by lowercasing the domain part of it. """ email = email or '' try: email_name, domain_part = email.strip().rsplit('@', 1) except ValueError: pass else: email = '@'...
[ "def", "normalize_email", "(", "cls", ",", "email", ")", ":", "email", "=", "email", "or", "''", "try", ":", "email_name", ",", "domain_part", "=", "email", ".", "strip", "(", ")", ".", "rsplit", "(", "'@'", ",", "1", ")", "except", "ValueError", ":"...
[ 22, 4 ]
[ 33, 20 ]
python
en
['en', 'error', 'th']
False
BaseUserManager.make_random_password
(self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789')
Generate a random password with the given length and given allowed_chars. The default value of allowed_chars does not have "I" or "O" or letters and digits that look similar -- just to avoid confusion.
Generate a random password with the given length and given allowed_chars. The default value of allowed_chars does not have "I" or "O" or letters and digits that look similar -- just to avoid confusion.
def make_random_password(self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789'): """ Generate a random password with the given length and given ...
[ "def", "make_random_password", "(", "self", ",", "length", "=", "10", ",", "allowed_chars", "=", "'abcdefghjkmnpqrstuvwxyz'", "'ABCDEFGHJKLMNPQRSTUVWXYZ'", "'23456789'", ")", ":", "return", "get_random_string", "(", "length", ",", "allowed_chars", ")" ]
[ 35, 4 ]
[ 44, 55 ]
python
en
['en', 'error', 'th']
False
MeshTestApp.build_mesh
(self)
returns a Mesh of a rough circle.
returns a Mesh of a rough circle.
def build_mesh(self): """ returns a Mesh of a rough circle. """ vertices = [] indices = [] step = 10 istep = (pi * 2) / float(step) for i in range(step): x = 300 + cos(istep * i) * 100 y = 300 + sin(istep * i) * 100 vertices.extend([x, ...
[ "def", "build_mesh", "(", "self", ")", ":", "vertices", "=", "[", "]", "indices", "=", "[", "]", "step", "=", "10", "istep", "=", "(", "pi", "*", "2", ")", "/", "float", "(", "step", ")", "for", "i", "in", "range", "(", "step", ")", ":", "x",...
[ 23, 4 ]
[ 34, 55 ]
python
en
['en', 'gd', 'en']
True
BaseApplication.do_load_config
(self)
Loads the configuration
Loads the configuration
def do_load_config(self): """ Loads the configuration """ try: self.load_default_config() self.load_config() except Exception as e: print("\nError: %s" % str(e), file=sys.stderr) sys.stderr.flush() sys.exit(1)
[ "def", "do_load_config", "(", "self", ")", ":", "try", ":", "self", ".", "load_default_config", "(", ")", "self", ".", "load_config", "(", ")", "except", "Exception", "as", "e", ":", "print", "(", "\"\\nError: %s\"", "%", "str", "(", "e", ")", ",", "fi...
[ 29, 4 ]
[ 39, 23 ]
python
en
['en', 'error', 'th']
False
BaseApplication.load_config
(self)
This method is used to load the configuration from one or several input(s). Custom Command line, configuration file. You have to override this method in your class.
This method is used to load the configuration from one or several input(s). Custom Command line, configuration file. You have to override this method in your class.
def load_config(self): """ This method is used to load the configuration from one or several input(s). Custom Command line, configuration file. You have to override this method in your class. """ raise NotImplementedError
[ "def", "load_config", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 51, 4 ]
[ 57, 33 ]
python
en
['en', 'error', 'th']
False
Application.load_config_from_module_name_or_filename
(self, location)
Loads the configuration file: the file is a python file, otherwise raise an RuntimeError Exception or stop the process if the configuration file contains a syntax error.
Loads the configuration file: the file is a python file, otherwise raise an RuntimeError Exception or stop the process if the configuration file contains a syntax error.
def load_config_from_module_name_or_filename(self, location): """ Loads the configuration file: the file is a python file, otherwise raise an RuntimeError Exception or stop the process if the configuration file contains a syntax error. """ if location.startswith("python:"): ...
[ "def", "load_config_from_module_name_or_filename", "(", "self", ",", "location", ")", ":", "if", "location", ".", "startswith", "(", "\"python:\"", ")", ":", "module_name", "=", "location", "[", "len", "(", "\"python:\"", ")", ":", "]", "cfg", "=", "self", "...
[ 122, 4 ]
[ 149, 18 ]
python
en
['en', 'error', 'th']
False
document_link_entity
(props)
Helper to construct elements of the form <a id="1" linktype="document">document link</a> when converting from contentstate data
Helper to construct elements of the form <a id="1" linktype="document">document link</a> when converting from contentstate data
def document_link_entity(props): """ Helper to construct elements of the form <a id="1" linktype="document">document link</a> when converting from contentstate data """ return DOM.create_element('a', { 'linktype': 'document', 'id': props.get('id'), }, props['children'])
[ "def", "document_link_entity", "(", "props", ")", ":", "return", "DOM", ".", "create_element", "(", "'a'", ",", "{", "'linktype'", ":", "'document'", ",", "'id'", ":", "props", ".", "get", "(", "'id'", ")", ",", "}", ",", "props", "[", "'children'", "]...
[ 9, 0 ]
[ 19, 25 ]
python
en
['en', 'error', 'th']
False
create_genesis_puzzle_or_zero_coin_checker
(genesis_puzzle_hash: bytes32)
Given a specific genesis coin id, create a `genesis_coin_mod` that allows both that coin id to issue a cc, or anyone to create a cc with amount 0.
Given a specific genesis coin id, create a `genesis_coin_mod` that allows both that coin id to issue a cc, or anyone to create a cc with amount 0.
def create_genesis_puzzle_or_zero_coin_checker(genesis_puzzle_hash: bytes32) -> Program: """ Given a specific genesis coin id, create a `genesis_coin_mod` that allows both that coin id to issue a cc, or anyone to create a cc with amount 0. """ genesis_coin_mod = MOD return genesis_coin_mod.curry...
[ "def", "create_genesis_puzzle_or_zero_coin_checker", "(", "genesis_puzzle_hash", ":", "bytes32", ")", "->", "Program", ":", "genesis_coin_mod", "=", "MOD", "return", "genesis_coin_mod", ".", "curry", "(", "genesis_puzzle_hash", ")" ]
[ 10, 0 ]
[ 16, 54 ]
python
en
['en', 'error', 'th']
False
genesis_puzzle_hash_for_genesis_coin_checker
( genesis_coin_checker: Program, )
Given a `genesis_coin_checker` program, pull out the genesis puzzle hash.
Given a `genesis_coin_checker` program, pull out the genesis puzzle hash.
def genesis_puzzle_hash_for_genesis_coin_checker( genesis_coin_checker: Program, ) -> Optional[bytes32]: """ Given a `genesis_coin_checker` program, pull out the genesis puzzle hash. """ r = genesis_coin_checker.uncurry() if r is None: return r f, args = r if f != MOD: re...
[ "def", "genesis_puzzle_hash_for_genesis_coin_checker", "(", "genesis_coin_checker", ":", "Program", ",", ")", "->", "Optional", "[", "bytes32", "]", ":", "r", "=", "genesis_coin_checker", ".", "uncurry", "(", ")", "if", "r", "is", "None", ":", "return", "r", "...
[ 19, 0 ]
[ 31, 33 ]
python
en
['en', 'error', 'th']
False
TestPageEditHandlers.test_get_edit_handler
(self)
Forms for pages should have a base class of WagtailAdminPageForm.
Forms for pages should have a base class of WagtailAdminPageForm.
def test_get_edit_handler(self): """ Forms for pages should have a base class of WagtailAdminPageForm. """ edit_handler = EventPage.get_edit_handler() EventPageForm = edit_handler.get_form_class() # The generated form should inherit from WagtailAdminPageForm self...
[ "def", "test_get_edit_handler", "(", "self", ")", ":", "edit_handler", "=", "EventPage", ".", "get_edit_handler", "(", ")", "EventPageForm", "=", "edit_handler", ".", "get_form_class", "(", ")", "# The generated form should inherit from WagtailAdminPageForm", "self", ".",...
[ 168, 4 ]
[ 176, 72 ]
python
en
['en', 'error', 'th']
False
TestPageEditHandlers.test_get_form_for_page_with_custom_base
(self)
ValidatedPage sets a custom base_form_class. This should be used as the base class when constructing a form for ValidatedPages
ValidatedPage sets a custom base_form_class. This should be used as the base class when constructing a form for ValidatedPages
def test_get_form_for_page_with_custom_base(self): """ ValidatedPage sets a custom base_form_class. This should be used as the base class when constructing a form for ValidatedPages """ edit_handler = ValidatedPage.get_edit_handler() GeneratedValidatedPageForm = edit_hand...
[ "def", "test_get_form_for_page_with_custom_base", "(", "self", ")", ":", "edit_handler", "=", "ValidatedPage", ".", "get_edit_handler", "(", ")", "GeneratedValidatedPageForm", "=", "edit_handler", ".", "get_form_class", "(", ")", "# The generated form should inherit from Vali...
[ 179, 4 ]
[ 189, 82 ]
python
en
['en', 'error', 'th']
False
TestPageEditHandlers.test_check_invalid_streamfield_edit_handler
(self)
Set the edit handler for body (a StreamField) to be a FieldPanel instead of a StreamFieldPanel. Check that the correct warning is raised.
Set the edit handler for body (a StreamField) to be a FieldPanel instead of a StreamFieldPanel. Check that the correct warning is raised.
def test_check_invalid_streamfield_edit_handler(self): """ Set the edit handler for body (a StreamField) to be a FieldPanel instead of a StreamFieldPanel. Check that the correct warning is raised. """ invalid_edit_handler = checks.Warning( "DefaultStreamPage....
[ "def", "test_check_invalid_streamfield_edit_handler", "(", "self", ")", ":", "invalid_edit_handler", "=", "checks", ".", "Warning", "(", "\"DefaultStreamPage.body is a StreamField, but uses FieldPanel\"", ",", "hint", "=", "\"Ensure that it uses a StreamFieldPanel, or change the fiel...
[ 220, 4 ]
[ 239, 61 ]
python
en
['en', 'error', 'th']
False
TestPageEditHandlers.test_custom_edit_handler_form_class
(self)
Set a custom edit handler on a Page class, but dont customise ValidatedPage.base_form_class, or provide a custom form class for the edit handler. Check the generated form class is of the correct type.
Set a custom edit handler on a Page class, but dont customise ValidatedPage.base_form_class, or provide a custom form class for the edit handler. Check the generated form class is of the correct type.
def test_custom_edit_handler_form_class(self): """ Set a custom edit handler on a Page class, but dont customise ValidatedPage.base_form_class, or provide a custom form class for the edit handler. Check the generated form class is of the correct type. """ ValidatedPage.ed...
[ "def", "test_custom_edit_handler_form_class", "(", "self", ")", ":", "ValidatedPage", ".", "edit_handler", "=", "TabbedInterface", "(", ")", "with", "mock", ".", "patch", ".", "object", "(", "ValidatedPage", ",", "'edit_handler'", ",", "new", "=", "TabbedInterface...
[ 242, 4 ]
[ 253, 40 ]
python
en
['en', 'error', 'th']
False
TestInlinePanel.test_render
(self)
Check that the inline panel renders the panels set on the model when no 'panels' parameter is passed in the InlinePanel definition
Check that the inline panel renders the panels set on the model when no 'panels' parameter is passed in the InlinePanel definition
def test_render(self): """ Check that the inline panel renders the panels set on the model when no 'panels' parameter is passed in the InlinePanel definition """ speaker_object_list = ObjectList([ InlinePanel('speakers', label="Speakers", classname="classname-for-spea...
[ "def", "test_render", "(", "self", ")", ":", "speaker_object_list", "=", "ObjectList", "(", "[", "InlinePanel", "(", "'speakers'", ",", "label", "=", "\"Speakers\"", ",", "classname", "=", "\"classname-for-speakers\"", ")", "]", ")", ".", "bind_to", "(", "mode...
[ 851, 4 ]
[ 899, 58 ]
python
en
['en', 'error', 'th']
False
TestInlinePanel.test_render_with_panel_overrides
(self)
Check that inline panel renders the panels listed in the InlinePanel definition where one is specified
Check that inline panel renders the panels listed in the InlinePanel definition where one is specified
def test_render_with_panel_overrides(self): """ Check that inline panel renders the panels listed in the InlinePanel definition where one is specified """ speaker_object_list = ObjectList([ InlinePanel('speakers', label="Speakers", panels=[ FieldPanel(...
[ "def", "test_render_with_panel_overrides", "(", "self", ")", ":", "speaker_object_list", "=", "ObjectList", "(", "[", "InlinePanel", "(", "'speakers'", ",", "label", "=", "\"Speakers\"", ",", "panels", "=", "[", "FieldPanel", "(", "'first_name'", ",", "widget", ...
[ 901, 4 ]
[ 957, 74 ]
python
en
['en', 'error', 'th']
False
TestInlinePanel.test_no_thousand_separators_in_js
(self)
Test that the USE_THOUSAND_SEPARATOR setting does not screw up the rendering of numbers (specifically maxForms=1000) in the JS initializer: https://github.com/wagtail/wagtail/pull/2699 https://github.com/wagtail/wagtail/issues/3227
Test that the USE_THOUSAND_SEPARATOR setting does not screw up the rendering of numbers (specifically maxForms=1000) in the JS initializer: https://github.com/wagtail/wagtail/pull/2699 https://github.com/wagtail/wagtail/issues/3227
def test_no_thousand_separators_in_js(self): """ Test that the USE_THOUSAND_SEPARATOR setting does not screw up the rendering of numbers (specifically maxForms=1000) in the JS initializer: https://github.com/wagtail/wagtail/pull/2699 https://github.com/wagtail/wagtail/issues/3227...
[ "def", "test_no_thousand_separators_in_js", "(", "self", ")", ":", "speaker_object_list", "=", "ObjectList", "(", "[", "InlinePanel", "(", "'speakers'", ",", "label", "=", "\"Speakers\"", ",", "panels", "=", "[", "FieldPanel", "(", "'first_name'", ",", "widget", ...
[ 960, 4 ]
[ 979, 63 ]
python
en
['en', 'error', 'th']
False
TestInlinePanelRelatedModelPanelConfigChecks.test_page_with_inline_model_with_tabbed_panel_only
(self)
Test that checks will warn against setting single tabbed panel on InlinePanel model
Test that checks will warn against setting single tabbed panel on InlinePanel model
def test_page_with_inline_model_with_tabbed_panel_only(self): """Test that checks will warn against setting single tabbed panel on InlinePanel model""" EventPageSpeaker.settings_panels = [FieldPanel('first_name'), FieldPanel('last_name')] warning = checks.Warning( "EventPageSpeaker...
[ "def", "test_page_with_inline_model_with_tabbed_panel_only", "(", "self", ")", ":", "EventPageSpeaker", ".", "settings_panels", "=", "[", "FieldPanel", "(", "'first_name'", ")", ",", "FieldPanel", "(", "'last_name'", ")", "]", "warning", "=", "checks", ".", "Warning...
[ 1004, 4 ]
[ 1021, 52 ]
python
en
['en', 'en', 'en']
True
TestInlinePanelRelatedModelPanelConfigChecks.test_page_with_inline_model_with_two_tabbed_panels
(self)
Test that checks will warn against multiple tabbed panels on InlinePanel models
Test that checks will warn against multiple tabbed panels on InlinePanel models
def test_page_with_inline_model_with_two_tabbed_panels(self): """Test that checks will warn against multiple tabbed panels on InlinePanel models""" EventPageSpeaker.content_panels = [FieldPanel('first_name')] EventPageSpeaker.promote_panels = [FieldPanel('last_name')] warning_1 = check...
[ "def", "test_page_with_inline_model_with_two_tabbed_panels", "(", "self", ")", ":", "EventPageSpeaker", ".", "content_panels", "=", "[", "FieldPanel", "(", "'first_name'", ")", "]", "EventPageSpeaker", ".", "promote_panels", "=", "[", "FieldPanel", "(", "'last_name'", ...
[ 1023, 4 ]
[ 1050, 51 ]
python
en
['en', 'en', 'en']
True
TestInlinePanelRelatedModelPanelConfigChecks.test_page_with_inline_model_with_edit_handler
(self)
Checks should NOT warn if InlinePanel models use tabbed panels AND edit_handler
Checks should NOT warn if InlinePanel models use tabbed panels AND edit_handler
def test_page_with_inline_model_with_edit_handler(self): """Checks should NOT warn if InlinePanel models use tabbed panels AND edit_handler""" EventPageSpeaker.content_panels = [FieldPanel('first_name')] EventPageSpeaker.edit_handler = TabbedInterface([ ObjectList([FieldPanel('last_...
[ "def", "test_page_with_inline_model_with_edit_handler", "(", "self", ")", ":", "EventPageSpeaker", ".", "content_panels", "=", "[", "FieldPanel", "(", "'first_name'", ")", "]", "EventPageSpeaker", ".", "edit_handler", "=", "TabbedInterface", "(", "[", "ObjectList", "(...
[ 1052, 4 ]
[ 1065, 51 ]
python
en
['en', 'fil', 'en']
True
TestCommentPanel.test_comments_toggle_enabled
(self)
Test that the comments toggle is enabled for a TabbedInterface containing CommentPanel, and disabled otherwise
Test that the comments toggle is enabled for a TabbedInterface containing CommentPanel, and disabled otherwise
def test_comments_toggle_enabled(self): """ Test that the comments toggle is enabled for a TabbedInterface containing CommentPanel, and disabled otherwise """ self.assertTrue(self.tabbed_interface.show_comments_toggle) self.assertFalse(TabbedInterface([ObjectList(self.event_page....
[ "def", "test_comments_toggle_enabled", "(", "self", ")", ":", "self", ".", "assertTrue", "(", "self", ".", "tabbed_interface", ".", "show_comments_toggle", ")", "self", ".", "assertFalse", "(", "TabbedInterface", "(", "[", "ObjectList", "(", "self", ".", "event_...
[ 1086, 4 ]
[ 1091, 108 ]
python
en
['en', 'error', 'th']
False
TestCommentPanel.test_comments_disabled_setting
(self)
Test that the comment panel is missing if WAGTAILADMIN_COMMENTS_ENABLED=False
Test that the comment panel is missing if WAGTAILADMIN_COMMENTS_ENABLED=False
def test_comments_disabled_setting(self): """ Test that the comment panel is missing if WAGTAILADMIN_COMMENTS_ENABLED=False """ self.assertFalse(any(isinstance(panel, CommentPanel) for panel in Page.settings_panels)) self.assertFalse(Page.get_edit_handler().show_comments_toggle)
[ "def", "test_comments_disabled_setting", "(", "self", ")", ":", "self", ".", "assertFalse", "(", "any", "(", "isinstance", "(", "panel", ",", "CommentPanel", ")", "for", "panel", "in", "Page", ".", "settings_panels", ")", ")", "self", ".", "assertFalse", "("...
[ 1094, 4 ]
[ 1099, 70 ]
python
en
['en', 'error', 'th']
False
TestCommentPanel.test_comments_enabled_setting
(self)
Test that the comment panel is present by default
Test that the comment panel is present by default
def test_comments_enabled_setting(self): """ Test that the comment panel is present by default """ self.assertTrue(any(isinstance(panel, CommentPanel) for panel in Page.settings_panels)) self.assertTrue(Page.get_edit_handler().show_comments_toggle)
[ "def", "test_comments_enabled_setting", "(", "self", ")", ":", "self", ".", "assertTrue", "(", "any", "(", "isinstance", "(", "panel", ",", "CommentPanel", ")", "for", "panel", "in", "Page", ".", "settings_panels", ")", ")", "self", ".", "assertTrue", "(", ...
[ 1101, 4 ]
[ 1106, 69 ]
python
en
['en', 'error', 'th']
False
TestCommentPanel.test_context
(self)
Test that the context contains the data about existing comments necessary to initialize the commenting app
Test that the context contains the data about existing comments necessary to initialize the commenting app
def test_context(self): """ Test that the context contains the data about existing comments necessary to initialize the commenting app """ form = self.EventPageForm(instance=self.event_page) panel = self.object_list.bind_to(instance=self.event_page, form=form).children[0] ...
[ "def", "test_context", "(", "self", ")", ":", "form", "=", "self", ".", "EventPageForm", "(", "instance", "=", "self", ".", "event_page", ")", "panel", "=", "self", ".", "object_list", ".", "bind_to", "(", "instance", "=", "self", ".", "event_page", ",",...
[ 1108, 4 ]
[ 1131, 129 ]
python
en
['en', 'error', 'th']
False
TestCommentPanel.test_form
(self)
Check that the form has the comments/replies formsets, and that the user has been set on each CommentForm/CommentReplyForm subclass
Check that the form has the comments/replies formsets, and that the user has been set on each CommentForm/CommentReplyForm subclass
def test_form(self): """ Check that the form has the comments/replies formsets, and that the user has been set on each CommentForm/CommentReplyForm subclass """ form = self.EventPageForm(instance=self.event_page) self.assertIn('comments', form.formsets) comments...
[ "def", "test_form", "(", "self", ")", ":", "form", "=", "self", ".", "EventPageForm", "(", "instance", "=", "self", ".", "event_page", ")", "self", ".", "assertIn", "(", "'comments'", ",", "form", ".", "formsets", ")", "comments_formset", "=", "form", "....
[ 1133, 4 ]
[ 1148, 77 ]
python
en
['en', 'error', 'th']
False
LocustIOExecutor.get_widget
(self)
Add progress widget to console screen sidebar :rtype: ExecutorWidget
Add progress widget to console screen sidebar
def get_widget(self): """ Add progress widget to console screen sidebar :rtype: ExecutorWidget """ if not self.widget: label = "%s" % self self.widget = ExecutorWidget(self, "Locust.io: " + label.split('/')[1]) return self.widget
[ "def", "get_widget", "(", "self", ")", ":", "if", "not", "self", ".", "widget", ":", "label", "=", "\"%s\"", "%", "self", "self", ".", "widget", "=", "ExecutorWidget", "(", "self", ",", "\"Locust.io: \"", "+", "label", ".", "split", "(", "'/'", ")", ...
[ 119, 4 ]
[ 128, 26 ]
python
en
['en', 'error', 'th']
False
WorkersReader.__init__
(self, filename, num_workers, parent_logger)
:type filename: str :type num_workers: int :type parent_logger: logging.Logger
:type filename: str :type num_workers: int :type parent_logger: logging.Logger
def __init__(self, filename, num_workers, parent_logger): """ :type filename: str :type num_workers: int :type parent_logger: logging.Logger """ super(WorkersReader, self).__init__() self.log = parent_logger.getChild(self.__class__.__name__) self.join_buff...
[ "def", "__init__", "(", "self", ",", "filename", ",", "num_workers", ",", "parent_logger", ")", ":", "super", "(", "WorkersReader", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "log", "=", "parent_logger", ".", "getChild", "(", "self", ".", ...
[ 214, 4 ]
[ 225, 29 ]
python
en
['en', 'error', 'th']
False
WorkersReader.point_from_locust
(timestamp, sid, data)
:type timestamp: str :type sid: str :type data: dict :rtype: DataPoint
:type timestamp: str :type sid: str :type data: dict :rtype: DataPoint
def point_from_locust(timestamp, sid, data): """ :type timestamp: str :type sid: str :type data: dict :rtype: DataPoint """ point = DataPoint(int(timestamp)) point[DataPoint.SOURCE_ID] = sid overall = KPISet() for item in data['stats']: ...
[ "def", "point_from_locust", "(", "timestamp", ",", "sid", ",", "data", ")", ":", "point", "=", "DataPoint", "(", "int", "(", "timestamp", ")", ")", "point", "[", "DataPoint", ".", "SOURCE_ID", "]", "=", "sid", "overall", "=", "KPISet", "(", ")", "for",...
[ 272, 4 ]
[ 307, 20 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_initial
(self)
Returns the initial data to use for forms on this view.
Returns the initial data to use for forms on this view.
def get_initial(self): """ Returns the initial data to use for forms on this view. """ return self.initial.copy()
[ "def", "get_initial", "(", "self", ")", ":", "return", "self", ".", "initial", ".", "copy", "(", ")" ]
[ 20, 4 ]
[ 24, 34 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_prefix
(self)
Returns the prefix to use for forms on this view
Returns the prefix to use for forms on this view
def get_prefix(self): """ Returns the prefix to use for forms on this view """ return self.prefix
[ "def", "get_prefix", "(", "self", ")", ":", "return", "self", ".", "prefix" ]
[ 26, 4 ]
[ 30, 26 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_form_class
(self)
Returns the form class to use in this view
Returns the form class to use in this view
def get_form_class(self): """ Returns the form class to use in this view """ return self.form_class
[ "def", "get_form_class", "(", "self", ")", ":", "return", "self", ".", "form_class" ]
[ 32, 4 ]
[ 36, 30 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_form
(self, form_class=None)
Returns an instance of the form to be used in this view.
Returns an instance of the form to be used in this view.
def get_form(self, form_class=None): """ Returns an instance of the form to be used in this view. """ if form_class is None: form_class = self.get_form_class() return form_class(**self.get_form_kwargs())
[ "def", "get_form", "(", "self", ",", "form_class", "=", "None", ")", ":", "if", "form_class", "is", "None", ":", "form_class", "=", "self", ".", "get_form_class", "(", ")", "return", "form_class", "(", "*", "*", "self", ".", "get_form_kwargs", "(", ")", ...
[ 38, 4 ]
[ 44, 51 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_form_kwargs
(self)
Returns the keyword arguments for instantiating the form.
Returns the keyword arguments for instantiating the form.
def get_form_kwargs(self): """ Returns the keyword arguments for instantiating the form. """ kwargs = { 'initial': self.get_initial(), 'prefix': self.get_prefix(), } if self.request.method in ('POST', 'PUT'): kwargs.update({ ...
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "{", "'initial'", ":", "self", ".", "get_initial", "(", ")", ",", "'prefix'", ":", "self", ".", "get_prefix", "(", ")", ",", "}", "if", "self", ".", "request", ".", "method", "in", "(", ...
[ 46, 4 ]
[ 60, 21 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_success_url
(self)
Returns the supplied success URL.
Returns the supplied success URL.
def get_success_url(self): """ Returns the supplied success URL. """ if self.success_url: # Forcing possible reverse_lazy evaluation url = force_text(self.success_url) else: raise ImproperlyConfigured( "No URL to redirect to. Pr...
[ "def", "get_success_url", "(", "self", ")", ":", "if", "self", ".", "success_url", ":", "# Forcing possible reverse_lazy evaluation", "url", "=", "force_text", "(", "self", ".", "success_url", ")", "else", ":", "raise", "ImproperlyConfigured", "(", "\"No URL to redi...
[ 62, 4 ]
[ 72, 18 ]
python
en
['en', 'error', 'th']
False