tools.helpers.models package¶
Submodules¶
tools.helpers.models.dict_models module¶
Dictionary-like classes
-
class
tools.helpers.models.dict_models.BaseDict(*args, **kwargs)¶ Bases:
objectBase class of ordered-dictionary-like objects where keys have a specified format.
-
TO_KEY_FUNC(x)¶
-
clear()¶
-
copy()¶
-
deepcopy()¶
-
classmethod
from_dict(dico)¶
-
classmethod
fromkeys(*args, **kwargs)¶
-
get(item, default=None)¶
-
items()¶
-
keys()¶
-
move_to_end(key)¶
-
pop(item, default=None)¶
-
popitem(item)¶
-
setdefault(k, default=None)¶
-
update(other)¶
-
values()¶
-
-
class
tools.helpers.models.dict_models.IdentityDict(*args, **kwargs)¶ Bases:
collections.UserDictDict which returns the key if key not in dict when getting item. If ‘func’ arg is set, the function ‘func’ is applied to key before return
tools.helpers.models.metaclasses module¶
Metaclasses
The syntax to use a metaclass in Python 3 is as follows:
- class MyClass(metaclass=MyMetaClass):
pass
-
class
tools.helpers.models.metaclasses.LockChangeAttr¶ Bases:
typeMetaclass that locks attribute modification after a certain limit
-
class
tools.helpers.models.metaclasses.Singleton¶ Bases:
typeMetaclass that authorize only one instance of a class.
-
tools.helpers.models.metaclasses.lock_change_attr_metaclass(modification_limit=1, attr_exceptions=())¶ Returns a custom metaclass inherited from LockChangeAttr
- Parameters
modification_limit – number of times an attribute can be modified
attr_exceptions – iterable of attributes that can be modified without any limit
tools.helpers.models.path_models module¶
Classes to manipulate paths. Path and PathCollection define custom strings/collections with pathname manipulations methods. FileExt describes a file extension. DefaultFiletypesDict defines a dictionary-like class with file types understandable by tkinter file dialogs.
-
class
tools.helpers.models.path_models.DefaultFiletypesDict(dico=None, all_files=True)¶ Bases:
object-
get(key, default=None)¶
-
-
class
tools.helpers.models.path_models.FileExt¶ Bases:
tools.helpers.models.str_models._CustomStrFile extension class model
-
EXT_SEP= '.'¶
-
property
isempty¶
-
-
class
tools.helpers.models.path_models.Path¶ Bases:
tools.helpers.models.path_models._BasePathClass defining a path, inherited from str built-in type. If an iterable is passed, return a PathCollection of multiple Path objects.
>>> p = Path('a/b/c.d') >>> p Path: a/b/c.d >>> Path(None) Path: None >>> p.filename Path: c.d >>> p.isdir False >>> p.split_path [Path: a/b, Path: c.d]
# Collections
>>> p_c = Path(['a/b/c.d', 'e/f/g.h']) >>> p_c [Path: a/b/c.d, Path: e/f/g.h] >>> p_c.filename [Path: c.d, Path: g.h] >>> p_c.isdir [False, False] >>> p_c.split_path [[Path: a/b, Path: c.d], [Path: e/f, Path: g.h]]
# As _MODIFY_COLLECTION_INPLACE is True, PathCollection object has the same behavior as Path:
>>> PathCollection(['a/b/c.d']) == Path(['a/b/c.d']) True >>> PathCollection(['a/b/c.d']) [Path: a/b/c.d]
# Types of supported iterables: list, tuple, set and inherited objects.
>>> Path(['a/b/c.d', ['e/f/g.h'], ('i/j/k.l',), {'m/n/o.p'}]) [Path: a/b/c.d, [Path: e/f/g.h], [Path: i/j/k.l], [Path: m/n/o.p]]
-
class
tools.helpers.models.path_models.PathCollection(*args, **kwargs)¶ Bases:
tools.helpers.models.str_models._CollectionCustomStrCollection of Path objects, inherited from list built-in type
tools.helpers.models.str_models module¶
Classes inherited from string (“Custom strings”) and from list (“Collections”).
tools.helpers.models.types_models module¶
Various model classes and functions linked to them.
-
class
tools.helpers.models.types_models.EmptyClass¶ Bases:
objectClass to create empty objects
-
class
tools.helpers.models.types_models.Property(fget=None, fset=None, fdel=None, doc=None)¶ Bases:
objectEmulate PyProperty_Type() in Objects/descrobject.c
-
deleter(fdel)¶
-
getter(fget)¶
-
setter(fset)¶
-
-
class
tools.helpers.models.types_models.Reference¶ Bases:
objectReference class
-
class
tools.helpers.models.types_models.Wildcard¶ Bases:
objectClass to define wildcard objects
-
tools.helpers.models.types_models.add_tag(tag='tag', tag_value=True)¶ Set an attribute to a function or a property.
-
tools.helpers.models.types_models.keep_type(func_type='function')¶ Set the attribute ‘keep_type’ to a method or property and convert its result to original class.
Handle functions, methods, properties, class methods.
Module contents¶
Model classes
-
class
tools.helpers.models.Singleton¶ Bases:
typeMetaclass that authorize only one instance of a class.
-
class
tools.helpers.models.Path¶ Bases:
tools.helpers.models.path_models._BasePathClass defining a path, inherited from str built-in type. If an iterable is passed, return a PathCollection of multiple Path objects.
>>> p = Path('a/b/c.d') >>> p Path: a/b/c.d >>> Path(None) Path: None >>> p.filename Path: c.d >>> p.isdir False >>> p.split_path [Path: a/b, Path: c.d]
# Collections
>>> p_c = Path(['a/b/c.d', 'e/f/g.h']) >>> p_c [Path: a/b/c.d, Path: e/f/g.h] >>> p_c.filename [Path: c.d, Path: g.h] >>> p_c.isdir [False, False] >>> p_c.split_path [[Path: a/b, Path: c.d], [Path: e/f, Path: g.h]]
# As _MODIFY_COLLECTION_INPLACE is True, PathCollection object has the same behavior as Path:
>>> PathCollection(['a/b/c.d']) == Path(['a/b/c.d']) True >>> PathCollection(['a/b/c.d']) [Path: a/b/c.d]
# Types of supported iterables: list, tuple, set and inherited objects.
>>> Path(['a/b/c.d', ['e/f/g.h'], ('i/j/k.l',), {'m/n/o.p'}]) [Path: a/b/c.d, [Path: e/f/g.h], [Path: i/j/k.l], [Path: m/n/o.p]]
-
class
tools.helpers.models.PathCollection(*args, **kwargs)¶ Bases:
tools.helpers.models.str_models._CollectionCustomStrCollection of Path objects, inherited from list built-in type
-
class
tools.helpers.models.DefaultFiletypesDict(dico=None, all_files=True)¶ Bases:
object-
get(key, default=None)¶
-
-
class
tools.helpers.models.FileExt¶ Bases:
tools.helpers.models.str_models._CustomStrFile extension class model
-
EXT_SEP= '.'¶
-
property
isempty¶
-
-
class
tools.helpers.models.Reference¶ Bases:
objectReference class
-
class
tools.helpers.models.Wildcard¶ Bases:
objectClass to define wildcard objects
-
class
tools.helpers.models.Property(fget=None, fset=None, fdel=None, doc=None)¶ Bases:
objectEmulate PyProperty_Type() in Objects/descrobject.c
-
deleter(fdel)¶
-
getter(fget)¶
-
setter(fset)¶
-
-
class
tools.helpers.models.EmptyClass¶ Bases:
objectClass to create empty objects
-
class
tools.helpers.models.IdentityDict(*args, **kwargs)¶ Bases:
collections.UserDictDict which returns the key if key not in dict when getting item. If ‘func’ arg is set, the function ‘func’ is applied to key before return
-
class
tools.helpers.models.BaseDict(*args, **kwargs)¶ Bases:
objectBase class of ordered-dictionary-like objects where keys have a specified format.
-
TO_KEY_FUNC(x)¶
-
clear()¶
-
copy()¶
-
deepcopy()¶
-
classmethod
from_dict(dico)¶
-
classmethod
fromkeys(*args, **kwargs)¶
-
get(item, default=None)¶
-
items()¶
-
keys()¶
-
move_to_end(key)¶
-
pop(item, default=None)¶
-
popitem(item)¶
-
setdefault(k, default=None)¶
-
update(other)¶
-
values()¶
-