| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | import pathlibfrom .model import modelfrom .proxy import proxyfrom .field_generator import field_generatorfrom .constants import constantsfrom .validators import validatorsfrom .exceptions import resources_not_existsclass attachment(model):    """    That model store attachment to the item. Attachment is file, which could    be downloaded by the user, like instruction in PDF, or used in frontend     like images.    Fields    ------    name : str        Name of the attachment visible for user.    description : str        Description of the attachment visible for user.    """    name = field_generator.name()    description = field_generator.description()    resources = field_generator.path()       @property    def resources_path(self) -> pathlib.Path:        return pathlib.Path(self.resources)    def _validators(self) -> dict:        """        That function return dict of validators which would be used to         validate text fields of the model.        Returns        -------        dict            Validators which would be used to validate text fields.        """        return {            "name": validators.name,            "description": validators.description,            "resources": validators.path        }class attachment_proxy(proxy):       @classmethod    def create(cls, resources: str) -> proxy:        return cls(attachment(            name = cls.__extract_name(resources),            resources = resources,            description = constants.empty_text()        ))    @classmethod    def __extract_name(cls, resources: str) -> str:        splited = resources.split(".")        if len(splited) == 1:            return splited[0]        return str(".").join(splited[:-1])    def set_name(self, target: str) -> object:        self._target.name = target        return self    def set_description(self, target: str) -> object:        self._target.description = target        return self
 |