Пример #1
0
 def _verify_schema_decl(self, configdata):
     schema_policy = SchemaPolicy(self._validation_context,
                                  self.schema_name, self.schema_version_max,
                                  self.schema_version_min)
     schema_name = get_dict_val(configdata, self._schema_name_policy)
     schema_version = Decimal(
         get_dict_val(configdata, self._schema_ver_policy))
     if schema_policy.validate(schema_name, schema_version):
         return configdata
     else:
         raise SchemaNotSupportedError(
             schema_policy, '{0}v{1}'.format(schema_name, schema_version))
Пример #2
0
 def _verify_schema_decl(self, configdata):
     schema_policy = SchemaPolicy(
         self._validation_context, self.schema_name,
         self.schema_version_max, self.schema_version_min
     )
     schema_name = get_dict_val(configdata, self._schema_name_policy)
     schema_version = Decimal(get_dict_val(configdata, self._schema_ver_policy))
     if schema_policy.validate(schema_name, schema_version):
         return configdata
     else:
         raise SchemaNotSupportedError(
             schema_policy, '{0}v{1}'.format(schema_name, schema_version)
         )
Пример #3
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)
Пример #4
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)
Пример #5
0
    def _get_production_strategy(self):
        rval = {}
        configdata = self.configs.rawconfig
        ec = ErrorCollector()

        try:
            am = get_dict_val(configdata, self._pspol_doc_am)
        except ValidationError as e:
            am = e.policy.default
            ec.add(e)
        if am is True:
            # Assembly manifest should be used
            rval['prodst'] = "@AM"
            rval['genmanifest'] = True
        else:
            # No Assembly manifest needed
            rval['prodst'] = "@THIS"
            rval['genmanifest'] = False

        try:
            testing = get_dict_val(configdata, self._pspol_testing)
        except ValidationError as e:
            testing = e.policy.default
            ec.add(e)
        if testing == 'normal':
            # Normal test procedure, Test when made
            rval['testst'] = "@NOW"
        if testing == 'lazy':
            # Lazy test procedure, Test when used
            rval['testst'] = "@USE"

        try:
            labelling = get_dict_val(configdata, self._pspol_labelling)
        except ValidationError as e:
            labelling = e.policy.default
            ec.add(e)
        if labelling == 'normal':
            # Normal test procedure, Label when made
            rval['lblst'] = "@NOW"
        if labelling == 'lazy':
            # Lazy test procedure, Label when used
            rval['lblst'] = "@USE"
        rval['genlabel'] = False
        rval['labels'] = []

        try:
            labeldefs = get_dict_val(configdata, self._pspol_labeldefs)
        except ValidationError as e:
            labeldefs = e.policy.default
            ec.add(e)

        if labeldefs is not None:
            if isinstance(labeldefs, dict):
                for k in sorted(labeldefs.keys()):
                    rval['labels'].append(
                        {'code': k,
                         'ident': self.ident + '.' + configdata['label'][k]}
                    )
                rval['genlabel'] = True
            elif isinstance(labeldefs, str):
                rval['labels'].append(
                    {'code': labeldefs,
                     'ident': self.ident}
                )
                rval['genlabel'] = True
        return rval
Пример #6
0
    def _get_production_strategy(self):
        rval = {}
        configdata = self.configs.rawconfig
        ec = ErrorCollector()

        try:
            am = get_dict_val(configdata, self._pspol_doc_am)
        except ValidationError as e:
            am = e.policy.default
            ec.add(e)
        if am is True:
            # Assembly manifest should be used
            rval['prodst'] = "@AM"
            rval['genmanifest'] = True
        else:
            # No Assembly manifest needed
            rval['prodst'] = "@THIS"
            rval['genmanifest'] = False

        try:
            testing = get_dict_val(configdata, self._pspol_testing)
        except ValidationError as e:
            testing = e.policy.default
            ec.add(e)
        if testing == 'normal':
            # Normal test procedure, Test when made
            rval['testst'] = "@NOW"
        if testing == 'lazy':
            # Lazy test procedure, Test when used
            rval['testst'] = "@USE"

        try:
            labelling = get_dict_val(configdata, self._pspol_labelling)
        except ValidationError as e:
            labelling = e.policy.default
            ec.add(e)
        if labelling == 'normal':
            # Normal test procedure, Label when made
            rval['lblst'] = "@NOW"
        if labelling == 'lazy':
            # Lazy test procedure, Label when used
            rval['lblst'] = "@USE"
        rval['genlabel'] = False
        rval['labels'] = []

        try:
            labeldefs = get_dict_val(configdata, self._pspol_labeldefs)
        except ValidationError as e:
            labeldefs = e.policy.default
            ec.add(e)

        if labeldefs is not None:
            if isinstance(labeldefs, dict):
                for k in sorted(labeldefs.keys()):
                    rval['labels'].append(
                        {'code': k,
                         'ident': self.ident + '.' + configdata['label'][k]}
                    )
                rval['genlabel'] = True
            elif isinstance(labeldefs, str):
                rval['labels'].append(
                    {'code': labeldefs,
                     'ident': self.ident}
                )
                rval['genlabel'] = True
        return rval