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
request_wrapper
(view_fn)
Wraps requests by setting the current viewing context and fetching the profile associated with that context.
Wraps requests by setting the current viewing context and fetching the profile associated with that context.
def request_wrapper(view_fn): """Wraps requests by setting the current viewing context and fetching the profile associated with that context. """ def real_view_fn(request, *args, **kwargs): try: profile = UserProfile.objects.get(username=request.user.username) ans = view_...
[ "def", "request_wrapper", "(", "view_fn", ")", ":", "def", "real_view_fn", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "profile", "=", "UserProfile", ".", "objects", ".", "get", "(", "username", "=", "request", ".",...
[ 102, 0 ]
[ 131, 23 ]
python
en
['en', 'en', 'en']
True
index
(request, profile)
The main page shows patients and entities.
The main page shows patients and entities.
def index(request, profile): """The main page shows patients and entities. """ patients = Individual.objects.all() entities = CoveredEntity.objects.all() # TODO: Filter out ones you can't see? data = {"patients": patients , "entities": entities , 'name': profile.name} r...
[ "def", "index", "(", "request", ",", "profile", ")", ":", "patients", "=", "Individual", ".", "objects", ".", "all", "(", ")", "entities", "=", "CoveredEntity", ".", "objects", ".", "all", "(", ")", "# TODO: Filter out ones you can't see?", "data", "=", "{",...
[ 136, 0 ]
[ 147, 31 ]
python
en
['en', 'en', 'en']
True
about_view
(request, user)
About the system.
About the system.
def about_view(request, user): """About the system. """ # TODO: This doesn't work. return ("about.html" , {'which_page' : "about"})
[ "def", "about_view", "(", "request", ",", "user", ")", ":", "# TODO: This doesn't work.", "return", "(", "\"about.html\"", ",", "{", "'which_page'", ":", "\"about\"", "}", ")" ]
[ 151, 0 ]
[ 156, 39 ]
python
en
['en', 'en', 'en']
True
profile_view
(request, profile)
Displaying and updating profiles.
Displaying and updating profiles.
def profile_view(request, profile): """Displaying and updating profiles. """ if profile == None: profile = UserProfile(user=request.user) if request.method == 'POST': profile.name = request.POST.get('name', '') profile.email = request.POST.get('email', '') profile.save()...
[ "def", "profile_view", "(", "request", ",", "profile", ")", ":", "if", "profile", "==", "None", ":", "profile", "=", "UserProfile", "(", "user", "=", "request", ".", "user", ")", "if", "request", ".", "method", "==", "'POST'", ":", "profile", ".", "nam...
[ 161, 0 ]
[ 174, 35 ]
python
en
['en', 'en', 'en']
True
users_view
(request, profile)
Viewing all users.
Viewing all users.
def users_view(request, profile): """Viewing all users. """ # TODO: Have a better mechanism than this for letting someone know they # can't see something. if profile.profiletype != 3: return ("redirect", "/index") user_profiles = UserProfile.objects.all() if request.method == 'POST...
[ "def", "users_view", "(", "request", ",", "profile", ")", ":", "# TODO: Have a better mechanism than this for letting someone know they", "# can't see something.", "if", "profile", ".", "profiletype", "!=", "3", ":", "return", "(", "\"redirect\"", ",", "\"/index\"", ")", ...
[ 179, 0 ]
[ 200, 6 ]
python
en
['en', 'en', 'en']
True
treatments_view
(request, profile, patient)
Treatments.
Treatments.
def treatments_view(request, profile, patient): """Treatments. """ p = Individual.objects.get(jeeves_id=patient) treatments = Treatment.objects.filter(Patient=p) return ("treatments.html" , {"first_name" : p.FirstName , "last_name" : p.LastName , "treatments" : treatments})
[ "def", "treatments_view", "(", "request", ",", "profile", ",", "patient", ")", ":", "p", "=", "Individual", ".", "objects", ".", "get", "(", "jeeves_id", "=", "patient", ")", "treatments", "=", "Treatment", ".", "objects", ".", "filter", "(", "Patient", ...
[ 205, 0 ]
[ 213, 38 ]
python
en
['en', 'hu', 'en']
False
diagnoses_view
(request, profile, patient)
Diagnoses.
Diagnoses.
def diagnoses_view(request, profile, patient): """Diagnoses. """ p = Individual.objects.get(jeeves_id=patient) newDiagnoses = Diagnosis.objects.filter(Patient=p) diagnoses = [ {"Manifestation" : "A38.8" , "DateRecognized" : date(2012, 10, 17) , "RecognizingEntity" : {"Name" ...
[ "def", "diagnoses_view", "(", "request", ",", "profile", ",", "patient", ")", ":", "p", "=", "Individual", ".", "objects", ".", "get", "(", "jeeves_id", "=", "patient", ")", "newDiagnoses", "=", "Diagnosis", ".", "objects", ".", "filter", "(", "Patient", ...
[ 218, 0 ]
[ 244, 43 ]
python
en
['en', 'it', 'en']
False
info_view
(request, profile, patient)
Viewing information about an individual.
Viewing information about an individual.
def info_view(request, profile, patient): """Viewing information about an individual. """ p = Individual.objects.get(jeeves_id=patient) dataset = [] dataset.append(("Sex", p.Sex, False)) #print "HI" #dataset.append(("Address",p.Address.String(), False)) #dataset.append(("Social Security ...
[ "def", "info_view", "(", "request", ",", "profile", ",", "patient", ")", ":", "p", "=", "Individual", ".", "objects", ".", "get", "(", "jeeves_id", "=", "patient", ")", "dataset", "=", "[", "]", "dataset", ".", "append", "(", "(", "\"Sex\"", ",", "p"...
[ 249, 0 ]
[ 260, 35 ]
python
en
['en', 'en', 'en']
True
directory_view
(request, profile, entity)
Viewing covered entities.
Viewing covered entities.
def directory_view(request, profile, entity): """Viewing covered entities. """ entity = CoveredEntity.objects.get(EIN=entity) visits = entity.Patients.filter(DateReleased=None) oldVisits = [ {"Patient" : {"Name" : "Joe McGray", "ID" : 5} , "DateAdmitted" : date(2014, 5, 25) ...
[ "def", "directory_view", "(", "request", ",", "profile", ",", "entity", ")", ":", "entity", "=", "CoveredEntity", ".", "objects", ".", "get", "(", "EIN", "=", "entity", ")", "visits", "=", "entity", ".", "Patients", ".", "filter", "(", "DateReleased", "=...
[ 265, 0 ]
[ 293, 49 ]
python
en
['en', 'en', 'en']
True
transactions_view
(request, profile, entity)
Viewing transactions.
Viewing transactions.
def transactions_view(request, profile, entity): """ Viewing transactions. """ entity = CoveredEntity.objects.get(EIN=entity) transactions = Transaction.objects.filter(FirstParty=entity) other_transactions = Transaction.objects.filter(SecondParty=entity) return ("transactions.html" ...
[ "def", "transactions_view", "(", "request", ",", "profile", ",", "entity", ")", ":", "entity", "=", "CoveredEntity", ".", "objects", ".", "get", "(", "EIN", "=", "entity", ")", "transactions", "=", "Transaction", ".", "objects", ".", "filter", "(", "FirstP...
[ 298, 0 ]
[ 308, 57 ]
python
en
['en', 'error', 'th']
False
BulkUsersTest.test_client_gravatar_option
(self)
The main purpose of this test is to make sure we return None for avatar_url when client_gravatar is set to True. And we do a sanity check for when it's False, but we leave it to other tests to validate the specific URL.
The main purpose of this test is to make sure we return None for avatar_url when client_gravatar is set to True. And we do a sanity check for when it's False, but we leave it to other tests to validate the specific URL.
def test_client_gravatar_option(self) -> None: reset_emails_in_zulip_realm() self.login("cordelia") hamlet = self.example_user("hamlet") def get_hamlet_avatar(client_gravatar: bool) -> Optional[str]: data = dict(client_gravatar=orjson.dumps(client_gravatar).decode()) ...
[ "def", "test_client_gravatar_option", "(", "self", ")", "->", "None", ":", "reset_emails_in_zulip_realm", "(", ")", "self", ".", "login", "(", "\"cordelia\"", ")", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "def", "get_hamlet_avatar", "(...
[ 1707, 4 ]
[ 1736, 9 ]
python
en
['en', 'error', 'th']
False
GetProfileTest.test_cache_behavior
(self)
Tests whether fetching a user object the normal way, with `get_user`, makes 1 cache query and 1 database query.
Tests whether fetching a user object the normal way, with `get_user`, makes 1 cache query and 1 database query.
def test_cache_behavior(self) -> None: """Tests whether fetching a user object the normal way, with `get_user`, makes 1 cache query and 1 database query. """ realm = get_realm("zulip") email = self.example_user("hamlet").email with queries_captured() as queries: ...
[ "def", "test_cache_behavior", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "email", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", ".", "email", "with", "queries_captured", "(", ")", "as", "queries", ":"...
[ 1740, 4 ]
[ 1752, 51 ]
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
ParseDateNode.render
(self, datestring)
Parses a date-like string into a timezone aware Python datetime.
Parses a date-like string into a timezone aware Python datetime.
def render(self, datestring): """Parses a date-like string into a timezone aware Python datetime.""" formats = ["%Y-%m-%dT%H:%M:%S.%f", "%Y-%m-%d %H:%M:%S.%f", "%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M:%S"] if datestring: for format in formats: try: ...
[ "def", "render", "(", "self", ",", "datestring", ")", ":", "formats", "=", "[", "\"%Y-%m-%dT%H:%M:%S.%f\"", ",", "\"%Y-%m-%d %H:%M:%S.%f\"", ",", "\"%Y-%m-%dT%H:%M:%S\"", ",", "\"%Y-%m-%d %H:%M:%S\"", "]", "if", "datestring", ":", "for", "format", "in", "formats", ...
[ 32, 4 ]
[ 45, 19 ]
python
en
['en', 'en', 'en']
True
test_wrapper_func_transformer
(test_func)
Testing if WrapperFunctionTransformer still has functionality of an underlying FunctionTransformer.
Testing if WrapperFunctionTransformer still has functionality of an underlying FunctionTransformer.
def test_wrapper_func_transformer(test_func): """Testing if WrapperFunctionTransformer still has functionality of an underlying FunctionTransformer.""" test_arr = np.array([1, 1, 1, 2, 3, 4, 5]).reshape(-1, 1) tr = FunctionTransformer(func=test_func) wrap_tr = WrapperFunctionTransformer("test", clone(t...
[ "def", "test_wrapper_func_transformer", "(", "test_func", ")", ":", "test_arr", "=", "np", ".", "array", "(", "[", "1", ",", "1", ",", "1", ",", "2", ",", "3", ",", "4", ",", "5", "]", ")", ".", "reshape", "(", "-", "1", ",", "1", ")", "tr", ...
[ 21, 0 ]
[ 32, 34 ]
python
en
['en', 'en', 'en']
True
test_wrapper_func_transformer_str
(test_text)
Testing if str() function of WrapperFunctionTransformer returns text provided as an argument.
Testing if str() function of WrapperFunctionTransformer returns text provided as an argument.
def test_wrapper_func_transformer_str(test_text): """Testing if str() function of WrapperFunctionTransformer returns text provided as an argument.""" wrap_tr = WrapperFunctionTransformer(test_text, FunctionTransformer()) assert str(wrap_tr) == test_text
[ "def", "test_wrapper_func_transformer_str", "(", "test_text", ")", ":", "wrap_tr", "=", "WrapperFunctionTransformer", "(", "test_text", ",", "FunctionTransformer", "(", ")", ")", "assert", "str", "(", "wrap_tr", ")", "==", "test_text" ]
[ 44, 0 ]
[ 47, 36 ]
python
en
['en', 'en', 'en']
True
test_transformer_create_preprocessor_X
(categorical_features, numerical_features)
Testing if X preprocessor correctly assigns steps to columns depending on their type.
Testing if X preprocessor correctly assigns steps to columns depending on their type.
def test_transformer_create_preprocessor_X(categorical_features, numerical_features): """Testing if X preprocessor correctly assigns steps to columns depending on their type.""" categorical_features.remove("Target") tr = Transformer(categorical_features, numerical_features, "Categorical") preprocessor =...
[ "def", "test_transformer_create_preprocessor_X", "(", "categorical_features", ",", "numerical_features", ")", ":", "categorical_features", ".", "remove", "(", "\"Target\"", ")", "tr", "=", "Transformer", "(", "categorical_features", ",", "numerical_features", ",", "\"Cate...
[ 50, 0 ]
[ 62, 51 ]
python
en
['en', 'en', 'en']
True
test_transformer_create_preprocessor_y
(categorical_features, numerical_features, target_type, expected_function)
Testing if y preprocessor is created correctly.
Testing if y preprocessor is created correctly.
def test_transformer_create_preprocessor_y(categorical_features, numerical_features, target_type, expected_function): """Testing if y preprocessor is created correctly.""" tr = Transformer(categorical_features, numerical_features, target_type) preprocessor = tr._create_default_transformer_y() assert ty...
[ "def", "test_transformer_create_preprocessor_y", "(", "categorical_features", ",", "numerical_features", ",", "target_type", ",", "expected_function", ")", ":", "tr", "=", "Transformer", "(", "categorical_features", ",", "numerical_features", ",", "target_type", ")", "pre...
[ 72, 0 ]
[ 77, 74 ]
python
en
['en', 'en', 'en']
True
test_transformer_preprocessor_X_remainder
( categorical_features, numerical_features, data_classification_balanced, expected_raw_mapping, transformed_feature )
Testing if feature not declared in either categorical or numerical features passes through unchanged.
Testing if feature not declared in either categorical or numerical features passes through unchanged.
def test_transformer_preprocessor_X_remainder( categorical_features, numerical_features, data_classification_balanced, expected_raw_mapping, transformed_feature ): """Testing if feature not declared in either categorical or numerical features passes through unchanged.""" categorical_features.rem...
[ "def", "test_transformer_preprocessor_X_remainder", "(", "categorical_features", ",", "numerical_features", ",", "data_classification_balanced", ",", "expected_raw_mapping", ",", "transformed_feature", ")", ":", "categorical_features", ".", "remove", "(", "\"Target\"", ")", "...
[ 88, 0 ]
[ 114, 70 ]
python
en
['en', 'en', 'en']
True
test_transformer_preprocessor_X_remainder_order
( categorical_features, numerical_features, data_classification_balanced, expected_raw_mapping, transformed_features )
Testing if remainder portion of ColumnTransformer returns the columns in the expected (alphabetical) order.
Testing if remainder portion of ColumnTransformer returns the columns in the expected (alphabetical) order.
def test_transformer_preprocessor_X_remainder_order( categorical_features, numerical_features, data_classification_balanced, expected_raw_mapping, transformed_features ): """Testing if remainder portion of ColumnTransformer returns the columns in the expected (alphabetical) order.""" categorical...
[ "def", "test_transformer_preprocessor_X_remainder_order", "(", "categorical_features", ",", "numerical_features", ",", "data_classification_balanced", ",", "expected_raw_mapping", ",", "transformed_features", ")", ":", "categorical_features", ".", "remove", "(", "\"Target\"", "...
[ 124, 0 ]
[ 147, 92 ]
python
en
['en', 'en', 'en']
True
test_transformer_create_preprocessor_y_invalid_target_type
(categorical_features, numerical_features, target_type)
Testing if ._create_preprocessor_y raises an Exception when invalid target_type is provided
Testing if ._create_preprocessor_y raises an Exception when invalid target_type is provided
def test_transformer_create_preprocessor_y_invalid_target_type(categorical_features, numerical_features, target_type): """Testing if ._create_preprocessor_y raises an Exception when invalid target_type is provided""" tr = Transformer(categorical_features, numerical_features, "Categorical") # initiating with pr...
[ "def", "test_transformer_create_preprocessor_y_invalid_target_type", "(", "categorical_features", ",", "numerical_features", ",", "target_type", ")", ":", "tr", "=", "Transformer", "(", "categorical_features", ",", "numerical_features", ",", "\"Categorical\"", ")", "# initiat...
[ 161, 0 ]
[ 167, 69 ]
python
en
['en', 'en', 'en']
True
test_transformer_transform_y_categorical
( data_classification_balanced, categorical_features, numerical_features, expected_raw_mapping, feature_name )
Testing if fit_y() and transform_y() are changing provided y correctly (when y is categorical)
Testing if fit_y() and transform_y() are changing provided y correctly (when y is categorical)
def test_transformer_transform_y_categorical( data_classification_balanced, categorical_features, numerical_features, expected_raw_mapping, feature_name ): """Testing if fit_y() and transform_y() are changing provided y correctly (when y is categorical)""" df = pd.concat([data_classification_balanced[0]...
[ "def", "test_transformer_transform_y_categorical", "(", "data_classification_balanced", ",", "categorical_features", ",", "numerical_features", ",", "expected_raw_mapping", ",", "feature_name", ")", ":", "df", "=", "pd", ".", "concat", "(", "[", "data_classification_balance...
[ 180, 0 ]
[ 194, 57 ]
python
en
['en', 'en', 'en']
True
test_transformer_transform_y_numerical
( data_classification_balanced, categorical_features, numerical_features, feature_name )
Testing if fit_y() and transform_y() are changing provided y correctly (when y is numerical)
Testing if fit_y() and transform_y() are changing provided y correctly (when y is numerical)
def test_transformer_transform_y_numerical( data_classification_balanced, categorical_features, numerical_features, feature_name ): """Testing if fit_y() and transform_y() are changing provided y correctly (when y is numerical)""" df = pd.concat([data_classification_balanced[0], data_classification_bala...
[ "def", "test_transformer_transform_y_numerical", "(", "data_classification_balanced", ",", "categorical_features", ",", "numerical_features", ",", "feature_name", ")", ":", "df", "=", "pd", ".", "concat", "(", "[", "data_classification_balanced", "[", "0", "]", ",", "...
[ 204, 0 ]
[ 215, 70 ]
python
en
['en', 'en', 'en']
True
test_transformer_transform_y_classification_pos_label
( data_classification_balanced, categorical_features, numerical_features, feature, classification_pos_label, )
Testing if transformer correctly changes mappings of y when explicit classification_pos_label is provided.
Testing if transformer correctly changes mappings of y when explicit classification_pos_label is provided.
def test_transformer_transform_y_classification_pos_label( data_classification_balanced, categorical_features, numerical_features, feature, classification_pos_label, ): """Testing if transformer correctly changes mappings of y when explicit classification_pos_label is provided.""" df = pd.concat([data_c...
[ "def", "test_transformer_transform_y_classification_pos_label", "(", "data_classification_balanced", ",", "categorical_features", ",", "numerical_features", ",", "feature", ",", "classification_pos_label", ",", ")", ":", "df", "=", "pd", ".", "concat", "(", "[", "data_cla...
[ 228, 0 ]
[ 238, 57 ]
python
en
['en', 'en', 'en']
True
test_transformer_transform_y_classification_pos_label_multiclass
( data_multiclass, categorical_features, numerical_features, classification_pos_label, )
Testing if transformer correctly changes mappings of y when explicit classification_pos_label is provided for multiclass problem (so the mapping changes it to classification problem).
Testing if transformer correctly changes mappings of y when explicit classification_pos_label is provided for multiclass problem (so the mapping changes it to classification problem).
def test_transformer_transform_y_classification_pos_label_multiclass( data_multiclass, categorical_features, numerical_features, classification_pos_label, ): """Testing if transformer correctly changes mappings of y when explicit classification_pos_label is provided for multiclass problem (so the mappin...
[ "def", "test_transformer_transform_y_classification_pos_label_multiclass", "(", "data_multiclass", ",", "categorical_features", ",", "numerical_features", ",", "classification_pos_label", ",", ")", ":", "y", "=", "data_multiclass", "[", "1", "]", "mapping", "=", "{", "\"F...
[ 249, 0 ]
[ 266, 57 ]
python
en
['en', 'en', 'en']
True
test_transformer_transform_X_categorical
(data_classification_balanced, feature_name, csr_matrix_flag)
Testing if every categorical column from a test data is transformed correctly.
Testing if every categorical column from a test data is transformed correctly.
def test_transformer_transform_X_categorical(data_classification_balanced, feature_name, csr_matrix_flag): """Testing if every categorical column from a test data is transformed correctly.""" df = pd.concat([data_classification_balanced[0], data_classification_balanced[1]], axis=1) # replacing for SimpleImp...
[ "def", "test_transformer_transform_X_categorical", "(", "data_classification_balanced", ",", "feature_name", ",", "csr_matrix_flag", ")", ":", "df", "=", "pd", ".", "concat", "(", "[", "data_classification_balanced", "[", "0", "]", ",", "data_classification_balanced", "...
[ 279, 0 ]
[ 296, 76 ]
python
en
['en', 'en', 'en']
True
test_transformer_transform_X_numerical
(data_classification_balanced, feature_name)
Testing if every numerical column from a test data is transformed correctly.
Testing if every numerical column from a test data is transformed correctly.
def test_transformer_transform_X_numerical(data_classification_balanced, feature_name): """Testing if every numerical column from a test data is transformed correctly.""" random_state = 1 df = pd.concat([data_classification_balanced[0], data_classification_balanced[1]], axis=1) feature = df[feature_name...
[ "def", "test_transformer_transform_X_numerical", "(", "data_classification_balanced", ",", "feature_name", ")", ":", "random_state", "=", "1", "df", "=", "pd", ".", "concat", "(", "[", "data_classification_balanced", "[", "0", "]", ",", "data_classification_balanced", ...
[ 306, 0 ]
[ 321, 54 ]
python
en
['en', 'en', 'en']
True
test_transformer_y_classes_classification
( data_classification_balanced, categorical_features, numerical_features, y_column, expected_result, seed )
Testing if classification transformer returns correct classes from y.
Testing if classification transformer returns correct classes from y.
def test_transformer_y_classes_classification( data_classification_balanced, categorical_features, numerical_features, y_column, expected_result, seed ): """Testing if classification transformer returns correct classes from y.""" df = pd.concat([data_classification_balanced[0], data_classification_balan...
[ "def", "test_transformer_y_classes_classification", "(", "data_classification_balanced", ",", "categorical_features", ",", "numerical_features", ",", "y_column", ",", "expected_result", ",", "seed", ")", ":", "df", "=", "pd", ".", "concat", "(", "[", "data_classificatio...
[ 335, 0 ]
[ 346, 43 ]
python
en
['en', 'en', 'en']
True
test_transformer_y_classes_regression_error
(categorical_features, numerical_features, seed)
Testing if y_classes raises an Error when target_type is provided as Numerical.
Testing if y_classes raises an Error when target_type is provided as Numerical.
def test_transformer_y_classes_regression_error(categorical_features, numerical_features, seed): """Testing if y_classes raises an Error when target_type is provided as Numerical.""" tr = Transformer(categorical_features, numerical_features, "Numerical", seed) with pytest.raises(ValueError): _ = tr....
[ "def", "test_transformer_y_classes_regression_error", "(", "categorical_features", ",", "numerical_features", ",", "seed", ")", ":", "tr", "=", "Transformer", "(", "categorical_features", ",", "numerical_features", ",", "\"Numerical\"", ",", "seed", ")", "with", "pytest...
[ 349, 0 ]
[ 353, 26 ]
python
en
['en', 'en', 'en']
True
test_transformer_transformers
(transformer_classification_fitted, feature, category, seed)
Testing if correct transformers are returned when provided with a feature name.
Testing if correct transformers are returned when provided with a feature name.
def test_transformer_transformers(transformer_classification_fitted, feature, category, seed): """Testing if correct transformers are returned when provided with a feature name.""" if category == "Categorical": expected_result = ["SimpleImputer(strategy='most_frequent')", "OneHotEncoder(handle_unknown='...
[ "def", "test_transformer_transformers", "(", "transformer_classification_fitted", ",", "feature", ",", "category", ",", "seed", ")", ":", "if", "category", "==", "\"Categorical\"", ":", "expected_result", "=", "[", "\"SimpleImputer(strategy='most_frequent')\"", ",", "\"On...
[ 365, 0 ]
[ 380, 43 ]
python
en
['en', 'en', 'en']
True
test_transformer_custom_transformers
(categorical_features, numerical_features, seed)
Testing if setting custom transformers in Transformer object works correctly.
Testing if setting custom transformers in Transformer object works correctly.
def test_transformer_custom_transformers(categorical_features, numerical_features, seed): """Testing if setting custom transformers in Transformer object works correctly.""" categorical_tr = [SimpleImputer(strategy="most_frequent"), OrdinalEncoder()] numerical_tr = [SimpleImputer(), PowerTransformer()] ...
[ "def", "test_transformer_custom_transformers", "(", "categorical_features", ",", "numerical_features", ",", "seed", ")", ":", "categorical_tr", "=", "[", "SimpleImputer", "(", "strategy", "=", "\"most_frequent\"", ")", ",", "OrdinalEncoder", "(", ")", "]", "numerical_...
[ 383, 0 ]
[ 395, 44 ]
python
en
['en', 'en', 'en']
True
test_transformer_custom_transformer_none_transformers
( categorical_features, numerical_features, seed, custom_transformers, tr_type )
Testing if setting custom transformers with only one type of transformers provided works correctly.
Testing if setting custom transformers with only one type of transformers provided works correctly.
def test_transformer_custom_transformer_none_transformers( categorical_features, numerical_features, seed, custom_transformers, tr_type ): """Testing if setting custom transformers with only one type of transformers provided works correctly.""" tr = Transformer(categorical_features, numerical_features, ...
[ "def", "test_transformer_custom_transformer_none_transformers", "(", "categorical_features", ",", "numerical_features", ",", "seed", ",", "custom_transformers", ",", "tr_type", ")", ":", "tr", "=", "Transformer", "(", "categorical_features", ",", "numerical_features", ",", ...
[ 405, 0 ]
[ 423, 58 ]
python
en
['en', 'en', 'en']
True
test_transformer_transformers_untransformed_feature
(transformer_classification_fitted, feature)
Testing if no transformers are returned from transformations() function when unused feature is provided.
Testing if no transformers are returned from transformations() function when unused feature is provided.
def test_transformer_transformers_untransformed_feature(transformer_classification_fitted, feature): """Testing if no transformers are returned from transformations() function when unused feature is provided.""" expected_result = None actual_result = transformer_classification_fitted.transformers(feature) ...
[ "def", "test_transformer_transformers_untransformed_feature", "(", "transformer_classification_fitted", ",", "feature", ")", ":", "expected_result", "=", "None", "actual_result", "=", "transformer_classification_fitted", ".", "transformers", "(", "feature", ")", "assert", "ac...
[ 433, 0 ]
[ 438, 43 ]
python
en
['en', 'en', 'en']
True
test_transformer_transformed_columns_names
(transformer_classification_fitted)
Testing if transformed_columns() returns correct combination of transformed column names.
Testing if transformed_columns() returns correct combination of transformed column names.
def test_transformer_transformed_columns_names(transformer_classification_fitted): """Testing if transformed_columns() returns correct combination of transformed column names.""" categorical_columns = [ "AgeGroup_18", "AgeGroup_23", "AgeGroup_28", "AgeGroup_33", "AgeGroup...
[ "def", "test_transformer_transformed_columns_names", "(", "transformer_classification_fitted", ")", ":", "categorical_columns", "=", "[", "\"AgeGroup_18\"", ",", "\"AgeGroup_23\"", ",", "\"AgeGroup_28\"", ",", "\"AgeGroup_33\"", ",", "\"AgeGroup_38\"", ",", "\"AgeGroup_43\"", ...
[ 441, 0 ]
[ 472, 43 ]
python
en
['en', 'en', 'en']
True
test_transformer_transformed_columns_categorical_encoding
( transformer_classification_fitted, data_classification_balanced, feature )
Testing if transformed_columns() returns transformed column names in correct order (OneHotEncoding).
Testing if transformed_columns() returns transformed column names in correct order (OneHotEncoding).
def test_transformer_transformed_columns_categorical_encoding( transformer_classification_fitted, data_classification_balanced, feature ): """Testing if transformed_columns() returns transformed column names in correct order (OneHotEncoding).""" categorical_columns = [ "AgeGroup_18", "Ag...
[ "def", "test_transformer_transformed_columns_categorical_encoding", "(", "transformer_classification_fitted", ",", "data_classification_balanced", ",", "feature", ")", ":", "categorical_columns", "=", "[", "\"AgeGroup_18\"", ",", "\"AgeGroup_23\"", ",", "\"AgeGroup_28\"", ",", ...
[ 484, 0 ]
[ 531, 57 ]
python
en
['en', 'en', 'en']
True
test_transformer_transformed_columns_no_one_hot_encoder
( transformer_classification_fitted, data_classification_balanced )
Testing if columns from transformed_columns() are correctly calculated when there is no OneHotEncoder present in the preprocessor.
Testing if columns from transformed_columns() are correctly calculated when there is no OneHotEncoder present in the preprocessor.
def test_transformer_transformed_columns_no_one_hot_encoder( transformer_classification_fitted, data_classification_balanced ): """Testing if columns from transformed_columns() are correctly calculated when there is no OneHotEncoder present in the preprocessor.""" transformer_classification_fitted.s...
[ "def", "test_transformer_transformed_columns_no_one_hot_encoder", "(", "transformer_classification_fitted", ",", "data_classification_balanced", ")", ":", "transformer_classification_fitted", ".", "set_custom_preprocessor_X", "(", "categorical_transformers", "=", "[", "SimpleImputer", ...
[ 534, 0 ]
[ 547, 45 ]
python
en
['en', 'en', 'en']
True
test_transformer_normal_transformations
( transformer_classification_fitted, data_classification_balanced, feature, seed )
Testing if normal_transformations() method returns correct 'normal' transformations for a given feature.
Testing if normal_transformations() method returns correct 'normal' transformations for a given feature.
def test_transformer_normal_transformations( transformer_classification_fitted, data_classification_balanced, feature, seed ): """Testing if normal_transformations() method returns correct 'normal' transformations for a given feature.""" expected_transformers = [QuantileTransformer, PowerTransformer] ...
[ "def", "test_transformer_normal_transformations", "(", "transformer_classification_fitted", ",", "data_classification_balanced", ",", "feature", ",", "seed", ")", ":", "expected_transformers", "=", "[", "QuantileTransformer", ",", "PowerTransformer", "]", "X", "=", "data_cl...
[ 591, 0 ]
[ 607, 61 ]
python
en
['en', 'en', 'en']
True
test_transformer_normal_transformations_negative_input
( transformer_classification_fitted, input_train_array, input_test_array, expected_transformers_len, seed )
Testing if normal_transformations are returned correctly when input has negative values.
Testing if normal_transformations are returned correctly when input has negative values.
def test_transformer_normal_transformations_negative_input( transformer_classification_fitted, input_train_array, input_test_array, expected_transformers_len, seed ): """Testing if normal_transformations are returned correctly when input has negative values.""" expected_transformers = { "Quantil...
[ "def", "test_transformer_normal_transformations_negative_input", "(", "transformer_classification_fitted", ",", "input_train_array", ",", "input_test_array", ",", "expected_transformers_len", ",", "seed", ")", ":", "expected_transformers", "=", "{", "\"QuantileTransformer(output_di...
[ 622, 0 ]
[ 637, 60 ]
python
en
['en', 'en', 'en']
True
test_transformer_normal_transformations_histogram
( transformer_classification_fitted, data_classification_balanced, numerical_features, seed )
Testing if histogram data is calculated for expected features and normal transformers.
Testing if histogram data is calculated for expected features and normal transformers.
def test_transformer_normal_transformations_histogram( transformer_classification_fitted, data_classification_balanced, numerical_features, seed ): """Testing if histogram data is calculated for expected features and normal transformers.""" expected_keys = {"Price", "Height"} X, y = data_classificat...
[ "def", "test_transformer_normal_transformations_histogram", "(", "transformer_classification_fitted", ",", "data_classification_balanced", ",", "numerical_features", ",", "seed", ")", ":", "expected_keys", "=", "{", "\"Price\"", ",", "\"Height\"", "}", "X", ",", "y", "=",...
[ 640, 0 ]
[ 654, 29 ]
python
en
['en', 'en', 'en']
True
BaseHelper.cache
(self)
Возвращает кеш помощника
Возвращает кеш помощника
def cache(self): """ Возвращает кеш помощника """ return self._cache
[ "def", "cache", "(", "self", ")", ":", "return", "self", ".", "_cache" ]
[ 29, 4 ]
[ 33, 26 ]
python
en
['en', 'error', 'th']
False
BaseHelper._prepare_cache_class
(self)
Возвращает класс кеша помощника
Возвращает класс кеша помощника
def _prepare_cache_class(self) -> Union[Optional[Type[BaseCache]], Optional[Type[CacheStorage]]]: """ Возвращает класс кеша помощника """ return BaseCache
[ "def", "_prepare_cache_class", "(", "self", ")", "->", "Union", "[", "Optional", "[", "Type", "[", "BaseCache", "]", "]", ",", "Optional", "[", "Type", "[", "CacheStorage", "]", "]", "]", ":", "return", "BaseCache" ]
[ 35, 4 ]
[ 39, 24 ]
python
en
['en', 'error', 'th']
False
BaseHelper._prepare_cache
(self, *args, **kwargs)
Метод создания кеша. Кеш хранится в публичном свойстве cache. По умолчанию добавлена заглушка.
Метод создания кеша.
def _prepare_cache(self, *args, **kwargs): """ Метод создания кеша. Кеш хранится в публичном свойстве cache. По умолчанию добавлена заглушка. """ if issubclass(self._cache_class, (BaseCache, CacheStorage)): self._cache = self._cache_class(*args, **kwargs) ...
[ "def", "_prepare_cache", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "issubclass", "(", "self", ".", "_cache_class", ",", "(", "BaseCache", ",", "CacheStorage", ")", ")", ":", "self", ".", "_cache", "=", "self", ".", "_cac...
[ 41, 4 ]
[ 51, 52 ]
python
en
['en', 'error', 'th']
False
CompletionCommand.run
(self, options, args)
Prints the completion code of the given shell
Prints the completion code of the given shell
def run(self, options, args): # type: (Values, List[str]) -> int """Prints the completion code of the given shell""" shells = COMPLETION_SCRIPTS.keys() shell_options = ['--' + shell for shell in sorted(shells)] if options.shell in shells: script = textwrap.dedent( ...
[ "def", "run", "(", "self", ",", "options", ",", "args", ")", ":", "# type: (Values, List[str]) -> int", "shells", "=", "COMPLETION_SCRIPTS", ".", "keys", "(", ")", "shell_options", "=", "[", "'--'", "+", "shell", "for", "shell", "in", "sorted", "(", "shells...
[ 81, 4 ]
[ 97, 26 ]
python
en
['en', 'en', 'en']
True
PushNotificationConsumer.notify
(self, event)
Handler for calls like:: channel_layer.group_send(group_name, { 'type': 'notify', # This routes it to this handler. 'content': { 'type': str (will map to frontend Redux event), 'payload': { 'originatin...
Handler for calls like::
async def notify(self, event): """ Handler for calls like:: channel_layer.group_send(group_name, { 'type': 'notify', # This routes it to this handler. 'content': { 'type': str (will map to frontend Redux event), 'paylo...
[ "async", "def", "notify", "(", "self", ",", "event", ")", ":", "# Take lock out of redis for this message:", "await", "clear_message_semaphore", "(", "self", ".", "channel_layer", ",", "event", ")", "if", "\"content\"", "in", "event", ":", "message", "=", "await",...
[ 34, 4 ]
[ 56, 18 ]
python
en
['en', 'error', 'th']
False
MappingFilterAction.filter
(self, table, mappings, filter_string)
Naive case-insensitive search.
Naive case-insensitive search.
def filter(self, table, mappings, filter_string): """Naive case-insensitive search.""" q = filter_string.lower() return [mapping for mapping in mappings if q in mapping.ud.lower()]
[ "def", "filter", "(", "self", ",", "table", ",", "mappings", ",", "filter_string", ")", ":", "q", "=", "filter_string", ".", "lower", "(", ")", "return", "[", "mapping", "for", "mapping", "in", "mappings", "if", "q", "in", "mapping", ".", "ud", ".", ...
[ 65, 4 ]
[ 69, 43 ]
python
en
['en', 'it', 'en']
True
initial_password
(email: str)
Given an email address, returns the initial password for that account, as created by populate_db.
Given an email address, returns the initial password for that account, as created by populate_db.
def initial_password(email: str) -> Optional[str]: """Given an email address, returns the initial password for that account, as created by populate_db.""" if settings.INITIAL_PASSWORD_SALT is not None: encoded_key = (settings.INITIAL_PASSWORD_SALT + email).encode("utf-8") digest = hashlib.s...
[ "def", "initial_password", "(", "email", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "if", "settings", ".", "INITIAL_PASSWORD_SALT", "is", "not", "None", ":", "encoded_key", "=", "(", "settings", ".", "INITIAL_PASSWORD_SALT", "+", "email", ")", ...
[ 7, 0 ]
[ 17, 19 ]
python
en
['en', 'en', 'en']
True
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", ")", "...
[ 306, 0 ]
[ 323, 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", ...
[ 371, 0 ]
[ 390, 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", ...
[ 393, 0 ]
[ 403, 12 ]
python
en
['en', 'error', 'th']
False
Command.get_new_strings
( self, old_strings: Mapping[str, str], translation_strings: List[str], locale: str )
Missing strings are removed, new strings are added and already translated strings are not touched.
Missing strings are removed, new strings are added and already translated strings are not touched.
def get_new_strings( self, old_strings: Mapping[str, str], translation_strings: List[str], locale: str ) -> Dict[str, str]: """ Missing strings are removed, new strings are added and already translated strings are not touched. """ new_strings = {} # Dict[str, str] ...
[ "def", "get_new_strings", "(", "self", ",", "old_strings", ":", "Mapping", "[", "str", ",", "str", "]", ",", "translation_strings", ":", "List", "[", "str", "]", ",", "locale", ":", "str", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "new_str...
[ 249, 4 ]
[ 264, 26 ]
python
en
['en', 'error', 'th']
False
Encoded.cast
(self, content)
Cast the I{untyped} list items found in content I{value}. Each items contained in the list is checked for XSD type information. Items (values) that are I{untyped}, are replaced with suds objects and type I{metadata} is added. @param content: The content holding the collection. ...
Cast the I{untyped} list items found in content I{value}. Each items contained in the list is checked for XSD type information. Items (values) that are I{untyped}, are replaced with suds objects and type I{metadata} is added.
def cast(self, content): """ Cast the I{untyped} list items found in content I{value}. Each items contained in the list is checked for XSD type information. Items (values) that are I{untyped}, are replaced with suds objects and type I{metadata} is added. @param content: T...
[ "def", "cast", "(", "self", ",", "content", ")", ":", "aty", "=", "content", ".", "aty", "[", "1", "]", "resolved", "=", "content", ".", "type", ".", "resolve", "(", ")", "array", "=", "Factory", ".", "object", "(", "resolved", ".", "name", ")", ...
[ 93, 4 ]
[ 132, 19 ]
python
en
['en', 'error', 'th']
False
pkg_resources_distribution_for_wheel
(wheel_zip, name, location)
Get a pkg_resources distribution given a wheel. :raises UnsupportedWheel: on any errors
Get a pkg_resources distribution given a wheel.
def pkg_resources_distribution_for_wheel(wheel_zip, name, location): # type: (ZipFile, str, str) -> Distribution """Get a pkg_resources distribution given a wheel. :raises UnsupportedWheel: on any errors """ info_dir, _ = parse_wheel(wheel_zip, name) metadata_files = [ p for p in wheel...
[ "def", "pkg_resources_distribution_for_wheel", "(", "wheel_zip", ",", "name", ",", "location", ")", ":", "# type: (ZipFile, str, str) -> Distribution", "info_dir", ",", "_", "=", "parse_wheel", "(", "wheel_zip", ",", "name", ")", "metadata_files", "=", "[", "p", "fo...
[ 57, 0 ]
[ 91, 5 ]
python
en
['en', 'en', 'en']
True
parse_wheel
(wheel_zip, name)
Extract information from the provided wheel, ensuring it meets basic standards. Returns the name of the .dist-info directory and the parsed WHEEL metadata.
Extract information from the provided wheel, ensuring it meets basic standards.
def parse_wheel(wheel_zip, name): # type: (ZipFile, str) -> Tuple[str, Message] """Extract information from the provided wheel, ensuring it meets basic standards. Returns the name of the .dist-info directory and the parsed WHEEL metadata. """ try: info_dir = wheel_dist_info_dir(wheel_zi...
[ "def", "parse_wheel", "(", "wheel_zip", ",", "name", ")", ":", "# type: (ZipFile, str) -> Tuple[str, Message]", "try", ":", "info_dir", "=", "wheel_dist_info_dir", "(", "wheel_zip", ",", "name", ")", "metadata", "=", "wheel_metadata", "(", "wheel_zip", ",", "info_di...
[ 94, 0 ]
[ 112, 29 ]
python
en
['en', 'en', 'en']
True
wheel_dist_info_dir
(source, name)
Returns the name of the contained .dist-info directory. Raises AssertionError or UnsupportedWheel if not found, >1 found, or it doesn't match the provided name.
Returns the name of the contained .dist-info directory.
def wheel_dist_info_dir(source, name): # type: (ZipFile, str) -> str """Returns the name of the contained .dist-info directory. Raises AssertionError or UnsupportedWheel if not found, >1 found, or it doesn't match the provided name. """ # Zip file path separators must be / subdirs = set(p.s...
[ "def", "wheel_dist_info_dir", "(", "source", ",", "name", ")", ":", "# type: (ZipFile, str) -> str", "# Zip file path separators must be /", "subdirs", "=", "set", "(", "p", ".", "split", "(", "\"/\"", ",", "1", ")", "[", "0", "]", "for", "p", "in", "source", ...
[ 115, 0 ]
[ 150, 31 ]
python
en
['en', 'en', 'en']
True
wheel_metadata
(source, dist_info_dir)
Return the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel.
Return the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel.
def wheel_metadata(source, dist_info_dir): # type: (ZipFile, str) -> Message """Return the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel. """ path = "{}/WHEEL".format(dist_info_dir) # Zip file path separators must be / wheel_contents = read_wheel_metada...
[ "def", "wheel_metadata", "(", "source", ",", "dist_info_dir", ")", ":", "# type: (ZipFile, str) -> Message", "path", "=", "\"{}/WHEEL\"", ".", "format", "(", "dist_info_dir", ")", "# Zip file path separators must be /", "wheel_contents", "=", "read_wheel_metadata_file", "("...
[ 165, 0 ]
[ 182, 40 ]
python
en
['en', 'en', 'en']
True
wheel_version
(wheel_data)
Given WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel.
Given WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel.
def wheel_version(wheel_data): # type: (Message) -> Tuple[int, ...] """Given WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel. """ version_text = wheel_data["Wheel-Version"] if version_text is None: raise UnsupportedWheel("WHEEL is missing Wheel-Version"...
[ "def", "wheel_version", "(", "wheel_data", ")", ":", "# type: (Message) -> Tuple[int, ...]", "version_text", "=", "wheel_data", "[", "\"Wheel-Version\"", "]", "if", "version_text", "is", "None", ":", "raise", "UnsupportedWheel", "(", "\"WHEEL is missing Wheel-Version\"", ...
[ 185, 0 ]
[ 199, 77 ]
python
en
['en', 'de', 'en']
True
check_compatibility
(version, name)
Raises errors or warns if called with an incompatible Wheel-Version. pip should refuse to install a Wheel-Version that's a major series ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when installing a version only minor version ahead (e.g 1.2 > 1.1). version: a 2-tuple representing a Whe...
Raises errors or warns if called with an incompatible Wheel-Version.
def check_compatibility(version, name): # type: (Tuple[int, ...], str) -> None """Raises errors or warns if called with an incompatible Wheel-Version. pip should refuse to install a Wheel-Version that's a major series ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when installing a ve...
[ "def", "check_compatibility", "(", "version", ",", "name", ")", ":", "# type: (Tuple[int, ...], str) -> None", "if", "version", "[", "0", "]", ">", "VERSION_COMPATIBLE", "[", "0", "]", ":", "raise", "UnsupportedWheel", "(", "\"{}'s Wheel-Version ({}) is not compatible w...
[ 202, 0 ]
[ 224, 9 ]
python
en
['en', 'en', 'en']
True
glob
(pathname, recursive=False)
Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns. If recursive is true, the pattern '**' will match any files ...
Return a list of paths matching a pathname pattern.
def glob(pathname, recursive=False): """Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns. If recursive is ...
[ "def", "glob", "(", "pathname", ",", "recursive", "=", "False", ")", ":", "return", "list", "(", "iglob", "(", "pathname", ",", "recursive", "=", "recursive", ")", ")" ]
[ 15, 0 ]
[ 26, 53 ]
python
en
['en', 'en', 'en']
True
iglob
(pathname, recursive=False)
Return an iterator which yields the paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns. If recursive is true, the pattern '**' wi...
Return an iterator which yields the paths matching a pathname pattern.
def iglob(pathname, recursive=False): """Return an iterator which yields the paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns. ...
[ "def", "iglob", "(", "pathname", ",", "recursive", "=", "False", ")", ":", "it", "=", "_iglob", "(", "pathname", ",", "recursive", ")", "if", "recursive", "and", "_isrecursive", "(", "pathname", ")", ":", "s", "=", "next", "(", "it", ")", "# skip empty...
[ 29, 0 ]
[ 44, 13 ]
python
en
['en', 'en', 'en']
True
escape
(pathname)
Escape all special characters.
Escape all special characters.
def escape(pathname): """Escape all special characters. """ # Escaping is done by wrapping any of "*?[" between square brackets. # Metacharacters do not work in the drive part and shouldn't be escaped. drive, pathname = os.path.splitdrive(pathname) if isinstance(pathname, bytes): pathnam...
[ "def", "escape", "(", "pathname", ")", ":", "# Escaping is done by wrapping any of \"*?[\" between square brackets.", "# Metacharacters do not work in the drive part and shouldn't be escaped.", "drive", ",", "pathname", "=", "os", ".", "path", ".", "splitdrive", "(", "pathname", ...
[ 163, 0 ]
[ 173, 27 ]
python
en
['en', 'en', 'en']
True
Element.buildPath
(self, parent, path)
Build the specifed pat as a/b/c where missing intermediate nodes are built automatically. @param parent: A parent element on which the path is built. @type parent: I{Element} @param path: A simple path separated by (/). @type path: basestring @return: The leaf no...
Build the specifed pat as a/b/c where missing intermediate nodes are built automatically.
def buildPath(self, parent, path): """ Build the specifed pat as a/b/c where missing intermediate nodes are built automatically. @param parent: A parent element on which the path is built. @type parent: I{Element} @param path: A simple path separated by (/). @type...
[ "def", "buildPath", "(", "self", ",", "parent", ",", "path", ")", ":", "for", "tag", "in", "path", ".", "split", "(", "'/'", ")", ":", "child", "=", "parent", ".", "getChild", "(", "tag", ")", "if", "child", "is", "None", ":", "child", "=", "Elem...
[ 66, 4 ]
[ 82, 20 ]
python
en
['en', 'error', 'th']
False
Element.__init__
(self, name, parent=None, ns=None)
@param name: The element's (tag) name. May cotain a prefix. @type name: basestring @param parent: An optional parent element. @type parent: I{Element} @param ns: An optional namespace @type ns: (I{prefix}, I{name})
def __init__(self, name, parent=None, ns=None): """ @param name: The element's (tag) name. May cotain a prefix. @type name: basestring @param parent: An optional parent element. @type parent: I{Element} @param ns: An optional namespace @type ns: (I{prefix}, I{nam...
[ "def", "__init__", "(", "self", ",", "name", ",", "parent", "=", "None", ",", "ns", "=", "None", ")", ":", "self", ".", "rename", "(", "name", ")", "self", ".", "expns", "=", "None", "self", ".", "nsprefixes", "=", "{", "}", "self", ".", "attribu...
[ 84, 4 ]
[ 107, 24 ]
python
en
['en', 'error', 'th']
False
Element.rename
(self, name)
Rename the element. @param name: A new name for the element. @type name: basestring
Rename the element.
def rename(self, name): """ Rename the element. @param name: A new name for the element. @type name: basestring """ if name is None: raise Exception('name (%s) not-valid' % name) else: self.prefix, self.name = splitPrefix(name)
[ "def", "rename", "(", "self", ",", "name", ")", ":", "if", "name", "is", "None", ":", "raise", "Exception", "(", "'name (%s) not-valid'", "%", "name", ")", "else", ":", "self", ".", "prefix", ",", "self", ".", "name", "=", "splitPrefix", "(", "name", ...
[ 109, 4 ]
[ 118, 54 ]
python
en
['en', 'error', 'th']
False
Element.setPrefix
(self, p, u=None)
Set the element namespace prefix. @param p: A new prefix for the element. @type p: basestring @param u: A namespace URI to be mapped to the prefix. @type u: basestring @return: self @rtype: L{Element}
Set the element namespace prefix.
def setPrefix(self, p, u=None): """ Set the element namespace prefix. @param p: A new prefix for the element. @type p: basestring @param u: A namespace URI to be mapped to the prefix. @type u: basestring @return: self @rtype: L{Element} """ ...
[ "def", "setPrefix", "(", "self", ",", "p", ",", "u", "=", "None", ")", ":", "self", ".", "prefix", "=", "p", "if", "p", "is", "not", "None", "and", "u", "is", "not", "None", ":", "self", ".", "addPrefix", "(", "p", ",", "u", ")", "return", "s...
[ 120, 4 ]
[ 133, 19 ]
python
en
['en', 'error', 'th']
False
Element.qname
(self)
Get the B{fully} qualified name of this element @return: The fully qualified name. @rtype: basestring
Get the B{fully} qualified name of this element
def qname(self): """ Get the B{fully} qualified name of this element @return: The fully qualified name. @rtype: basestring """ if self.prefix is None: return self.name else: return '%s:%s' % (self.prefix, self.name)
[ "def", "qname", "(", "self", ")", ":", "if", "self", ".", "prefix", "is", "None", ":", "return", "self", ".", "name", "else", ":", "return", "'%s:%s'", "%", "(", "self", ".", "prefix", ",", "self", ".", "name", ")" ]
[ 135, 4 ]
[ 144, 53 ]
python
en
['en', 'error', 'th']
False
Element.getRoot
(self)
Get the root (top) node of the tree. @return: The I{top} node of this tree. @rtype: I{Element}
Get the root (top) node of the tree.
def getRoot(self): """ Get the root (top) node of the tree. @return: The I{top} node of this tree. @rtype: I{Element} """ if self.parent is None: return self else: return self.parent.getRoot()
[ "def", "getRoot", "(", "self", ")", ":", "if", "self", ".", "parent", "is", "None", ":", "return", "self", "else", ":", "return", "self", ".", "parent", ".", "getRoot", "(", ")" ]
[ 146, 4 ]
[ 155, 40 ]
python
en
['en', 'error', 'th']
False
Element.clone
(self, parent=None)
Deep clone of this element and children. @param parent: An optional parent for the copied fragment. @type parent: I{Element} @return: A deep copy parented by I{parent} @rtype: I{Element}
Deep clone of this element and children.
def clone(self, parent=None): """ Deep clone of this element and children. @param parent: An optional parent for the copied fragment. @type parent: I{Element} @return: A deep copy parented by I{parent} @rtype: I{Element} """ root = Element(self.qname(), pa...
[ "def", "clone", "(", "self", ",", "parent", "=", "None", ")", ":", "root", "=", "Element", "(", "self", ".", "qname", "(", ")", ",", "parent", ",", "self", ".", "namespace", "(", ")", ")", "for", "a", "in", "self", ".", "attributes", ":", "root",...
[ 157, 4 ]
[ 172, 19 ]
python
en
['en', 'error', 'th']
False
Element.detach
(self)
Detach from parent. @return: This element removed from its parent's child list and I{parent}=I{None} @rtype: L{Element}
Detach from parent.
def detach(self): """ Detach from parent. @return: This element removed from its parent's child list and I{parent}=I{None} @rtype: L{Element} """ if self.parent is not None: if self in self.parent.children: self.parent.children.remo...
[ "def", "detach", "(", "self", ")", ":", "if", "self", ".", "parent", "is", "not", "None", ":", "if", "self", "in", "self", ".", "parent", ".", "children", ":", "self", ".", "parent", ".", "children", ".", "remove", "(", "self", ")", "self", ".", ...
[ 174, 4 ]
[ 185, 19 ]
python
en
['en', 'error', 'th']
False
Element.set
(self, name, value)
Set an attribute's value. @param name: The name of the attribute. @type name: basestring @param value: The attribute value. @type value: basestring @see: __setitem__()
Set an attribute's value.
def set(self, name, value): """ Set an attribute's value. @param name: The name of the attribute. @type name: basestring @param value: The attribute value. @type value: basestring @see: __setitem__() """ attr = self.getAttribute(name) if at...
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "attr", "=", "self", ".", "getAttribute", "(", "name", ")", "if", "attr", "is", "None", ":", "attr", "=", "Attribute", "(", "name", ",", "value", ")", "self", ".", "append", "(", "at...
[ 187, 4 ]
[ 201, 32 ]
python
en
['en', 'error', 'th']
False
Element.unset
(self, name)
Unset (remove) an attribute. @param name: The attribute name. @type name: str @return: self @rtype: L{Element}
Unset (remove) an attribute.
def unset(self, name): """ Unset (remove) an attribute. @param name: The attribute name. @type name: str @return: self @rtype: L{Element} """ try: attr = self.getAttribute(name) self.attributes.remove(attr) except: ...
[ "def", "unset", "(", "self", ",", "name", ")", ":", "try", ":", "attr", "=", "self", ".", "getAttribute", "(", "name", ")", "self", ".", "attributes", ".", "remove", "(", "attr", ")", "except", ":", "pass", "return", "self" ]
[ 203, 4 ]
[ 216, 19 ]
python
en
['en', 'error', 'th']
False
Element.get
(self, name, ns=None, default=None)
Get the value of an attribute by name. @param name: The name of the attribute. @type name: basestring @param ns: The optional attribute's namespace. @type ns: (I{prefix}, I{name}) @param default: An optional value to be returned when either the attribute does...
Get the value of an attribute by name.
def get(self, name, ns=None, default=None): """ Get the value of an attribute by name. @param name: The name of the attribute. @type name: basestring @param ns: The optional attribute's namespace. @type ns: (I{prefix}, I{name}) @param default: An optional value to...
[ "def", "get", "(", "self", ",", "name", ",", "ns", "=", "None", ",", "default", "=", "None", ")", ":", "attr", "=", "self", ".", "getAttribute", "(", "name", ",", "ns", ")", "if", "attr", "is", "None", "or", "attr", ".", "value", "is", "None", ...
[ 219, 4 ]
[ 237, 34 ]
python
en
['en', 'error', 'th']
False
Element.setText
(self, value)
Set the element's L{Text} content. @param value: The element's text value. @type value: basestring @return: self @rtype: I{Element}
Set the element's L{Text} content.
def setText(self, value): """ Set the element's L{Text} content. @param value: The element's text value. @type value: basestring @return: self @rtype: I{Element} """ if isinstance(value, Text): self.text = value else: self.t...
[ "def", "setText", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Text", ")", ":", "self", ".", "text", "=", "value", "else", ":", "self", ".", "text", "=", "Text", "(", "value", ")", "return", "self" ]
[ 239, 4 ]
[ 251, 19 ]
python
en
['en', 'error', 'th']
False
Element.getText
(self, default=None)
Get the element's L{Text} content with optional default @param default: A value to be returned when no text content exists. @type default: basestring @return: The text content, or I{default} @rtype: L{Text}
Get the element's L{Text} content with optional default
def getText(self, default=None): """ Get the element's L{Text} content with optional default @param default: A value to be returned when no text content exists. @type default: basestring @return: The text content, or I{default} @rtype: L{Text} """ if self....
[ "def", "getText", "(", "self", ",", "default", "=", "None", ")", ":", "if", "self", ".", "hasText", "(", ")", ":", "return", "self", ".", "text", "else", ":", "return", "default" ]
[ 253, 4 ]
[ 264, 26 ]
python
en
['en', 'error', 'th']
False
Element.trim
(self)
Trim leading and trailing whitespace. @return: self @rtype: L{Element}
Trim leading and trailing whitespace.
def trim(self): """ Trim leading and trailing whitespace. @return: self @rtype: L{Element} """ if self.hasText(): self.text = self.text.trim() return self
[ "def", "trim", "(", "self", ")", ":", "if", "self", ".", "hasText", "(", ")", ":", "self", ".", "text", "=", "self", ".", "text", ".", "trim", "(", ")", "return", "self" ]
[ 266, 4 ]
[ 274, 19 ]
python
en
['en', 'error', 'th']
False
Element.hasText
(self)
Get whether the element has I{text} and that it is not an empty (zero length) string. @return: True when has I{text}. @rtype: boolean
Get whether the element has I{text} and that it is not an empty (zero length) string.
def hasText(self): """ Get whether the element has I{text} and that it is not an empty (zero length) string. @return: True when has I{text}. @rtype: boolean """ return ( self.text is not None and len(self.text) )
[ "def", "hasText", "(", "self", ")", ":", "return", "(", "self", ".", "text", "is", "not", "None", "and", "len", "(", "self", ".", "text", ")", ")" ]
[ 276, 4 ]
[ 283, 59 ]
python
en
['en', 'error', 'th']
False
Element.namespace
(self)
Get the element's namespace. @return: The element's namespace by resolving the prefix, the explicit namespace or the inherited namespace. @rtype: (I{prefix}, I{name})
Get the element's namespace.
def namespace(self): """ Get the element's namespace. @return: The element's namespace by resolving the prefix, the explicit namespace or the inherited namespace. @rtype: (I{prefix}, I{name}) """ if self.prefix is None: return self.defaultNamespac...
[ "def", "namespace", "(", "self", ")", ":", "if", "self", ".", "prefix", "is", "None", ":", "return", "self", ".", "defaultNamespace", "(", ")", "else", ":", "return", "self", ".", "resolvePrefix", "(", "self", ".", "prefix", ")" ]
[ 285, 4 ]
[ 295, 50 ]
python
en
['en', 'error', 'th']
False
Element.defaultNamespace
(self)
Get the default (unqualified namespace). This is the expns of the first node (looking up the tree) that has it set. @return: The namespace of a node when not qualified. @rtype: (I{prefix}, I{name})
Get the default (unqualified namespace). This is the expns of the first node (looking up the tree) that has it set.
def defaultNamespace(self): """ Get the default (unqualified namespace). This is the expns of the first node (looking up the tree) that has it set. @return: The namespace of a node when not qualified. @rtype: (I{prefix}, I{name}) """ p = self whi...
[ "def", "defaultNamespace", "(", "self", ")", ":", "p", "=", "self", "while", "p", "is", "not", "None", ":", "if", "p", ".", "expns", "is", "not", "None", ":", "return", "(", "None", ",", "p", ".", "expns", ")", "else", ":", "p", "=", "p", ".", ...
[ 297, 4 ]
[ 311, 32 ]
python
en
['en', 'error', 'th']
False
Element.append
(self, objects)
Append the specified child based on whether it is an element or an attrbuite. @param objects: A (single|collection) of attribute(s) or element(s) to be added as children. @type objects: (L{Element}|L{Attribute}) @return: self @rtype: L{Element}
Append the specified child based on whether it is an element or an attrbuite.
def append(self, objects): """ Append the specified child based on whether it is an element or an attrbuite. @param objects: A (single|collection) of attribute(s) or element(s) to be added as children. @type objects: (L{Element}|L{Attribute}) @return: self ...
[ "def", "append", "(", "self", ",", "objects", ")", ":", "if", "not", "isinstance", "(", "objects", ",", "(", "list", ",", "tuple", ")", ")", ":", "objects", "=", "(", "objects", ",", ")", "for", "child", "in", "objects", ":", "if", "isinstance", "(...
[ 313, 4 ]
[ 335, 19 ]
python
en
['en', 'error', 'th']
False
Element.insert
(self, objects, index=0)
Insert an L{Element} content at the specified index. @param objects: A (single|collection) of attribute(s) or element(s) to be added as children. @type objects: (L{Element}|L{Attribute}) @param index: The position in the list of children to insert. @type index: int ...
Insert an L{Element} content at the specified index.
def insert(self, objects, index=0): """ Insert an L{Element} content at the specified index. @param objects: A (single|collection) of attribute(s) or element(s) to be added as children. @type objects: (L{Element}|L{Attribute}) @param index: The position in the list of...
[ "def", "insert", "(", "self", ",", "objects", ",", "index", "=", "0", ")", ":", "objects", "=", "(", "objects", ",", ")", "for", "child", "in", "objects", ":", "if", "isinstance", "(", "child", ",", "Element", ")", ":", "self", ".", "children", "."...
[ 337, 4 ]
[ 355, 19 ]
python
en
['en', 'error', 'th']
False
Element.remove
(self, child)
Remove the specified child element or attribute. @param child: A child to remove. @type child: L{Element}|L{Attribute} @return: The detached I{child} when I{child} is an element, else None. @rtype: L{Element}|None
Remove the specified child element or attribute.
def remove(self, child): """ Remove the specified child element or attribute. @param child: A child to remove. @type child: L{Element}|L{Attribute} @return: The detached I{child} when I{child} is an element, else None. @rtype: L{Element}|None """ if isinst...
[ "def", "remove", "(", "self", ",", "child", ")", ":", "if", "isinstance", "(", "child", ",", "Element", ")", ":", "return", "child", ".", "detach", "(", ")", "if", "isinstance", "(", "child", ",", "Attribute", ")", ":", "self", ".", "attributes", "."...
[ 357, 4 ]
[ 369, 19 ]
python
en
['en', 'error', 'th']
False
Element.replaceChild
(self, child, content)
Replace I{child} with the specified I{content}. @param child: A child element. @type child: L{Element} @param content: An element or collection of elements. @type content: L{Element} or [L{Element},]
Replace I{child} with the specified I{content}.
def replaceChild(self, child, content): """ Replace I{child} with the specified I{content}. @param child: A child element. @type child: L{Element} @param content: An element or collection of elements. @type content: L{Element} or [L{Element},] """ if child...
[ "def", "replaceChild", "(", "self", ",", "child", ",", "content", ")", ":", "if", "child", "not", "in", "self", ".", "children", ":", "raise", "Exception", "(", "'child not-found'", ")", "index", "=", "self", ".", "children", ".", "index", "(", "child", ...
[ 371, 4 ]
[ 388, 22 ]
python
en
['en', 'error', 'th']
False