Nessuna descrizione
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dict.py 928B

1234567891011121314151617181920212223
  1. # -*- coding: utf-8 -*-
  2. from lodel.leapi.datahandlers.reference import Reference
  3. from lodel.editorial_model.components import EmClass
  4. class DataHandler(Reference):
  5. ## @brief instanciates a dict reference
  6. # @param allowed_classes list | None : list of allowed em classes if None no restriction
  7. # @param internal bool : if False, the field is not internal
  8. # @param kwargs : Other named arguments
  9. def __init__(self, allowed_classes=None, internal=False, **kwargs):
  10. super().__init__(allowed_classes=allowed_classes, internal=internal, **kwargs)
  11. ## @brief adds a referenced element
  12. # @param ref_name str : key of the item in the reference dict
  13. # @param emclass EmClass
  14. # @return bool
  15. def add_ref(self, ref_name, emclass):
  16. if isinstance(emclass, EmClass) and isinstance(ref_name, str):
  17. self._refs[ref_name] = emclass
  18. return True
  19. return False