Helpers
Selector
Hint
Member function call applied on the selector will apply to item(s) returned.
select_all(conf.Proxies, False, name="a").delete(globally=True)
# is equivalent to
for i in select_all(conf.Proxies, False, name="a"):
i.delete(globally=True)
SmartMixin.select
Selects the first element from an iterable that matches specified conditions. The conditions are provided as keyword arguments where the key is the attribute name and the value is the expected attribute value. If the key starts with "re_", a regular expression search is performed on the attribute value.
If no element matches the conditions, an EmptySelector is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__iterable |
Iterable
|
The iterable from which to select elements. |
required |
reverse |
bool
|
If True, the first element that does not meet |
False
|
Returns:
Type | Description |
---|---|
EmptySelector | object
|
Union[EmptySelector, object]: The first element that matches the conditions |
EmptySelector | object
|
or an EmptySelector if no element matches the conditions. |
Source code in SmartMixin/helpers.py
SmartMixin.select_all
Selects elements from an iterable based on specified conditions. The conditions are provided as keyword arguments where the key is the attribute name and the value is the expected attribute value. If the key starts with "re_", a regular expression search is performed on the attribute value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__iterable |
Iterable
|
The iterable from which to select elements. |
required |
reverse |
bool
|
If True, elements that do not meet the conditions |
False
|
Returns:
Name | Type | Description |
---|---|---|
MultiSelector |
MultiSelector
|
A MultiSelector object containing the selected elements. |
Source code in SmartMixin/helpers.py
Container Helper
SmartMixin.extend_back
Extends a list by appending all the items from an iterable at the end. The iterable must be a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
li |
list
|
The list to be extended. |
required |
__iterable |
Iterable
|
The iterable with items to append to the list. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the iterable is not a list. |
Source code in SmartMixin/helpers.py
SmartMixin.extend_front
Extends a list by inserting all the items from an iterable at the beginning. The iterable must be a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
li |
list
|
The list to be extended. |
required |
__iterable |
Iterable
|
The iterable with items to insert at the beginning of the list. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the iterable is not a list. |
Source code in SmartMixin/helpers.py
SmartMixin.append_back
Appends an object to the end of a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
li |
list
|
The list where the object will be appended. |
required |
__object |
The object to be appended to the end of the list. |
required |
Source code in SmartMixin/helpers.py
SmartMixin.insert_front
Inserts an object at the beginning of a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
li |
list
|
The list where the object will be inserted. |
required |
__object |
The object to be inserted at the beginning of the list. |
required |