API

Packages

Unify-package

library - Unify collections of items.

Module library.unify

library.unify.main()[source]
library.unify.run_module()[source]

Runs the module.

Parameters:
  • items (list) – List of items to add to unified collection.
  • titles (list) – Names of collections to load from files or URLs.
  • expand (bool) – Load items from paths/URL or use plain path/URL.
Returns:

Unified list of items.

Return type:

list

library.unify.unify_collection(collection, unified=[], titles=[], expand=False)[source]

Unify a collection into a single unified collection.

Parameters:
  • collection (dict) – Collection to add to the unified collection.
  • unified (dict) – Current unified collection.
  • titles (dict) – List of items to search on files or URLs.
  • expand (bool) – Load or not the items on files and URLs.
Returns:

Unified plus the passed collection.

Return type:

dict

library.unify.unify_item(item, unified=[], titles=[], expand=False)[source]

Unify an item into a single unified collection.

Parameters:
  • item (str) – Value to add to the unified collection.
  • unified (dict) – Current unified collection.
  • titles (dict) – List of items to search on files or URLs.
  • expand (bool) – Load or not the items on files and URLs.
Returns:

Current collection plus the current item.

Return type:

dict

library.unify.variable_boolean(value)[source]

Verifies if a variable is boolean or not.

Parameters:value (str) – Variable to test.
Returns:True if variable is of type boolean, false otherwise.
Return type:bool
library.unify.variable_boolean_value(value)[source]

Get the boolean value of a variable.

The values accepted as boolean true are:
  • true
  • True
  • yes
The values accepted as boolean false are:
  • false
  • False
  • no
Parameters:value (str) – Variable to test.
Returns:True if variable is a true boolean value, False otherwise.
Return type:bool
library.unify.variable_collection(value)[source]

Verifies if a variable is a collection or not.

To this function, an empty variable is not considered a collection.

Parameters:value (str) – Variable to test.
Returns:True if variable is a non-empty collection, False otherwise.
Return type:bool
library.unify.variable_empty(value)[source]

Verifies if a variable is empty or not.

Parameters:value (str) – Variable to test.
Returns:True if the variable is a non-empty, False otherwise.
Return type:bool
library.unify.variable_path(value)[source]

Verifies if a variable is an existing file or not.

Parameters:value (str) – Variable to test.
Returns:True if variable is an existing file path, False otherwise.
Return type:bool
library.unify.variable_url(value)[source]

Verifies if a variable is a valid URL.

Parameters:value (str) – Variable to test.
Returns:True if variable is a valid URL, False otherwise.
Return type:bool
library.unify.variable_url_existent(value)[source]

Verifies if a variable is an existent URL.

Is recommended to use URL pointing to single files, not index or main.

Parameters:value (str) – Variable to test.
Returns:True if variable is an existent URL, False otherwise.
Return type:bool

Utils

test_plugins - Validations and variable handling utilities.

Mod test_plugins.utils

Validations and variable handling utilities.

class test_plugins.utils.TestModule[source]

Bases: object

Test filters for validations and variable handling.

tests()[source]

Define available test filters.

Returns:Collection of available tests filters.
Return type:dict
user_root(username=None)[source]

Verifies if an user can become sudo or not.

If the username is not defined or empty, False will be returned.

Parameters:username (str) – Username to check.
Returns:True if the user can become sudo, False otherwise.
Return type:bool
variable_boolean(value)[source]

Verifies if a variable is boolean or not.

Parameters:value (str) – Variable to test.
Returns:True if variable is of type boolean, false otherwise.
Return type:bool
variable_boolean_true(value)[source]

Verifies if a variable is boolean and its value is True.

Parameters:value (str) – Variable to test.
Returns:
True if variable is of type boolean and its value is True,
false otherwise.
Return type:bool
variable_collection(value)[source]

Verifies if a variable is a collection or not.

To this function, an empty variable is not considered a collection.

Parameters:value (str) – Variable to test.
Returns:True if variable is a non-empty collection, False otherwise.
Return type:bool
variable_empty(value)[source]

Verifies if a variable is empty or not.

Parameters:value (str) – Variable to test.
Returns:True if the variable is a non-empty, False otherwise.
Return type:bool
variable_path(value)[source]

Verifies if a variable is an existing file or not.

Parameters:value (str) – Variable to test.
Returns:True if variable is an existing file path, False otherwise.
Return type:bool
variable_url(value)[source]

Verifies if a variable is a valid URL.

Parameters:value (str) – Variable to test.
Returns:True if variable is a valid URL, False otherwise.
Return type:bool
variable_url_existent(value)[source]

Verifies if a variable is an existent URL.

Is recommended to use URL pointing to single files, not index or main.

Parameters:value (str) – Variable to test.
Returns:True if variable is an existent URL, False otherwise.
Return type:bool