def status(self): # TODO This is horribly ugly. Consider serious refactoring. if self._cached_status is None: allowed_status_values = status.allowed_status_values() allowed_status_values += [ '!' + x for x in status.allowed_status_values() ] if 'pcbdetails' in self._configdata.keys(): try: policy = ConfigOptionPolicy(self._validation_context, ('pcbdetails', 'status'), allowed_status_values, default='Experimental', is_error=True) ststr = get_dict_val(self._configdata, policy) except ValidationError as e: ststr = e.policy.default self._validation_errors.add(e) elif 'paneldetails' in self._configdata.keys(): try: policy = ConfigOptionPolicy(self._validation_context, ('paneldetails', 'status'), allowed_status_values, default='Experimental', is_error=True) ststr = get_dict_val(self._configdata, policy) except ValidationError as e: ststr = e.policy.default self._validation_errors.add(e) else: e = ValidationError( ConfigOptionPolicy(self._validation_context, 'pcbdetails', is_error=True)) e.detail = "Status not defined or not found in config file." ststr = None self._validation_errors.add(e) if ststr and self.status_forced: ststr = ststr[1:] else: ststr = self._cached_status return status.get_status(ststr)
def validate(self): super(EDAProjectConfig, self).validate() if not self._pcb_allowed and self.pcbname is not None: e = ValidationError( ConfigOptionPolicy(self._validation_context, 'pcbname', is_error=True)) e.detail = "pcbname defined, but PCB is not supported " \ "for this project." self._validation_errors.add(e)
def load(self, targetpath): baseparser = getattr(self, 'SchemaControlledYamlFile') target = baseparser(targetpath) target_schema = target.schema_name if target_schema not in self._file_schemas.keys(): # TODO Replace with a generic OptionPolicy? policy = ConfigOptionPolicy(self._validation_context, 'schema.name', self._file_schemas.keys()) raise SchemaNotSupportedError(policy, target_schema) return getattr(self, target_schema)(targetpath)
def validate(self): if not self._pcb_allowed and 'pcbname' in self._configdata.keys() and \ self._configdata['pcbname'] is not None: e = ValidationError( ConfigOptionPolicy(self._validation_context, 'pcbname', is_error=True)) e.detail = "pcbname defined, but PCB is not supported " \ "for this project." self._validation_errors.add(e) super(ConfigsFile, self).validate()
def _schema_ver_policy(self): return ConfigOptionPolicy(self._validation_context, ('schema', 'version'))
def _schema_name_policy(self): return ConfigOptionPolicy(self._validation_context, ('schema', 'name'))
def _p(self, *args, **kwargs): return ConfigOptionPolicy(self._validation_context, *args, **kwargs)
def _pspol_labeldefs(self): return ConfigOptionPolicy(context=self._psctx, path=('documentation', 'labels'), options=None, is_error=True, default=None)
def _pspol_labelling(self): return ConfigOptionPolicy(context=self._psctx, path=('productionstrategy', 'labelling'), options=['normal', 'lazy'], is_error=True, default='normal')
def _pspol_doc_am(self): return ConfigOptionPolicy(context=self._psctx, path=('documentation', 'am'), options=[True, False], is_error=True, default=True)