Beispiel #1
0
    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)
Beispiel #3
0
 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)
Beispiel #4
0
 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()
Beispiel #5
0
 def _schema_ver_policy(self):
     return ConfigOptionPolicy(self._validation_context,
                               ('schema', 'version'))
Beispiel #6
0
 def _schema_name_policy(self):
     return ConfigOptionPolicy(self._validation_context, ('schema', 'name'))
Beispiel #7
0
 def _p(self, *args, **kwargs):
     return ConfigOptionPolicy(self._validation_context, *args, **kwargs)
Beispiel #8
0
 def _pspol_labeldefs(self):
     return ConfigOptionPolicy(context=self._psctx,
                               path=('documentation', 'labels'),
                               options=None,
                               is_error=True,
                               default=None)
Beispiel #9
0
 def _pspol_labelling(self):
     return ConfigOptionPolicy(context=self._psctx,
                               path=('productionstrategy', 'labelling'),
                               options=['normal', 'lazy'],
                               is_error=True,
                               default='normal')
Beispiel #10
0
 def _pspol_doc_am(self):
     return ConfigOptionPolicy(context=self._psctx,
                               path=('documentation', 'am'),
                               options=[True, False],
                               is_error=True,
                               default=True)