rpasdt.common package¶
Submodules¶
rpasdt.common.enums module¶
Common Enum subclasses that can be use to hold model choices (including ugettext_lazy values)
# Examples:
- class rpasdt.common.enums.ChoiceEnumMeta(cls, bases, attrs)[source]¶
Bases:
enum.EnumMetaMetaclass for ChoiceEnum classes.
- property choices¶
Retrieve a tuple of all choices - (value, label) pairs.
- property label_to_value¶
Retrieve a dict of all choices - (label, value) pairs. We lowercase the keys to make the search easier and keep the case in enum definition intact.
- property labels¶
Retrieve a tuple of all labels.
- property values¶
Retrieve a tuple of all values.
- class rpasdt.common.enums.DecimalChoiceEnum(value)[source]¶
Bases:
rpasdt.common.enums.DecimalEnumChoiceEnum with values / instances restricted to be Decimal objects.
- class rpasdt.common.enums.DecimalEnum(value)[source]¶
Bases:
decimal.Decimal,enum.EnumEnum where members are Decimal objects.
- class rpasdt.common.enums.GenericChoiceEnum(value)[source]¶
Bases:
enum.EnumChoiceEnum with type restriction on values / instances.
- class rpasdt.common.enums.IntChoiceEnum(value)[source]¶
Bases:
enum.IntEnumChoiceEnum with values / instances restricted to be integers.
- class rpasdt.common.enums.StringChoiceEnum(value)[source]¶
Bases:
rpasdt.common.enums.StringEnumChoiceEnum with values / instances restricted to be strings.
rpasdt.common.exceptions module¶
Exception utilities.
- rpasdt.common.exceptions.log_error(type: Optional[type] = None, exc: Optional[Exception] = None, exc_traceback: Optional[Any] = None, title: Optional[str] = None)[source]¶
Intended to be assigned to sys.exception as a hook. Gives programmer opportunity to do something useful with info from uncaught exceptions.
Parameters type: Exception type value: Exception’s value tb: Exception’s traceback title: Additional title
rpasdt.common.utils module¶
Common methods shared throughout the app.
- rpasdt.common.utils.copy_dict_values_into_object(object: Any, dict: dict) None[source]¶
Update object properties with dict values.
- rpasdt.common.utils.export_dataclass_as_json(object: Any, file_path: Optional[str] = None) str[source]¶
- rpasdt.common.utils.format_label(string: str, required_words: Optional[List[str]] = None) str[source]¶
- rpasdt.common.utils.get_object_type_as_json_exportable(object: Any) Type[source]¶
Get object type to be json exportable.
It appends to_json method to an object type dynamically.
Module contents¶
Common methods utylized by the app.