Utils#

This module contain a collection of utilities. It needs to be refactored into submodules based on their purpose. The state of this module is a mix of legacy code that needs to be properly sorted or removed.

class odoo_tools.utils.ConfigParser(*args, **kwargs)[source]#
get(section, option, *, raw=False, vars=None, fallback=<object object>)[source]#

Gets a value from a section.

set(section, option, value=None)[source]#

Set an option.

set_defaults(defaults)[source]#
class odoo_tools.utils.ProtectedDict(protected_values)[source]#
odoo_tools.utils.convert_env_value(name, value)[source]#
odoo_tools.utils.filter_excluded_paths(paths, excluded_paths)[source]#
odoo_tools.utils.from_bool(value)[source]#

Convert a bool into a string value.

Parameters:

value (bool) – A boolean like value.

Returns:

A text representation of a boolean value.

Return type:

bool

odoo_tools.utils.is_subdir_of(path1, path2)[source]#
odoo_tools.utils.obj_set(delimiter=', ', container=<class 'list'>, item_type=<class 'str'>)[source]#

Convert a CSV value into a set of values.

Parameters:
  • delimiter (str) – the delimiter of the CSV value.

  • container (callable) – The type of the container of the set. Defaults to list.

  • item_type (callable) – The type of the value to be mapped to. Defaults to str.

Returns:

The mapped value of the csv.

Return type:

container<item_type>

odoo_tools.utils.random_string(stringLength=10)[source]#

Generate a random string of fixed length.

Parameters:

stringLength (int) – The length of the string to be generated. Defaults to 10.

odoo_tools.utils.to_bool(value)[source]#

Convert a string into a bool value.

The value will be true if its a text representation that is a caseless version of ‘true’.

Any other value will be False.

Parameters:

value (str) – A text representation of a boolean. The value must be true to be true. Any other value will be interpreted as False.

Returns:

A True or False representation of the text input.

Return type:

bool

odoo_tools.utils.to_csv(delimiter=',')[source]#

Convert a iterable of items into a csv of their string representation.

Parameters:

delimiter (str) – A string to be used as a value delimiter.

Returns:

A callable returning a csv value from an iterable.

Return type:

Fn(Iter<Any>)

odoo_tools.utils.to_path_list(paths)[source]#