def __setitem__(self, key, value): if key in self._validators: raise self.ValidatorManagementError( 'Validator cannot be reassigned') if not isinstance(value, Schema): value = Schema(value) self._validators[key] = Schema(value)
def get(): """ Return the glossary schema. """ common = da.check.schema.common return Schema({Required('title'): common.TITLE_TEXT, Extra: Reject})
def job_descriptions(idclass_tab): """ Return the daybook.job_description schema. """ counterparty_id = idclass_tab['counterparty'] item_id = idclass_tab['item'] job_id = idclass_tab['job'] project_id = idclass_tab['project'] return Schema({ Required(job_id): [ da.check.schema.common.PARAGRAPH_TEXT, { 'counterparty': counterparty_id, Extra: Reject }, { 'project': project_id, Extra: Reject }, { 'mandate': [item_id], Extra: Reject } ], Extra: Reject })
def get(idclass_schema_tab): """ Return the data validation schema for the codeword register. """ common = da.check.schema.common return Schema({ 'title': common.TITLE_TEXT, 'identification': { 'counterparty': idclass_schema_tab['counterparty'], 'project_year': common.YEAR_YYYY, 'project': idclass_schema_tab['project'], 'timebox': common.TIMEBOX }, 'catalog': [{ 'date': common.DATE_MMDD, 'plat_cfg': idclass_schema_tab['platform'], 'rec_serial': idclass_schema_tab['recording'], 'streams': { idclass_schema_tab['stream']: { 'path': common.LOWERCASE_PATH, 'utc_start': common.TIME_HHMMSS, 'utc_end': common.TIME_HHMMSS, 'bytes': common.NUMERIC_STRING, 'sha256': common.LOWERCASE_HEX } }, 'notes': common.PARAGRAPH_TEXT, 'tags': [common.LOWERCASE_NAME] }], Extra: Reject })
def requirement_item_schema(idclass_tab): """ Return the data specification schema for a requirement line-item. """ item_id = idclass_tab['item'] requirement_line_item = Schema([ SUMMARY_TEXT, Optional({ 'notes': PARAGRAPH_TEXT, Extra: Reject }), Required({ Required('type'): Any('guidance', 'mandate', 'information'), Extra: Reject }), Required({ Required('state'): Any('draft'), Extra: Reject }), Optional({ Required('ref'): [item_id], Extra: Reject }), { Extra: Reject } ]) return requirement_line_item
def get(idclass_tab): """ Return the data validation schema for the team register. """ common = da.check.schema.common team_member_id = idclass_tab['team_member'] project_id = idclass_tab['project'] return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { team_member_id: { 'name': str, 'email': common.EMAIL_ADDRESS, 'alias': [common.LOWERCASE_NAME], 'project': { project_id: { 'role': ['developer'] } } } }, Extra: Reject })
def idclass_schema(dirpath_lwc_root=None): """ Return a table of idclass schemata. """ return dict( (name, Schema(Match(regex, expected='id: ' + name))) for (name, regex) in da.idclass.regex_table(dirpath_lwc_root).items())
def _get_optimizer_schema (self): schema = Schema ({ 'name': All (str, Length (min=1)), 'date': All (str, Length (min=1)), 'pis_file_path': IsFile(), 'salary_file_path': IsFile(), }, default_keys=Required, extra_keys=Allow) return schema
def _get_predictor_schema(self): schema = Schema( { 'name': All(str, Length(min=1)), 'data_file_path': IsFile(), }, default_keys=Required, extra_keys=Allow) return schema
def function_scope_schema(idclass_tab): """ Return the validation schema for data within python function scope. """ return Schema( Any( Required(function_metadata_schema()), Optional( da.check.schema.common.requirement_set_schema(idclass_tab))))
def requirement_set_schema(idclass_tab): """ Return the data specification schema for a set of requirement line-items. """ item_id = idclass_tab['item'] requirement_set = Schema( {Required(item_id): requirement_item_schema(idclass_tab)}) return requirement_set
def function_metadata_schema(): """ Return the data validation schema for python function metadata. """ key_value_pair = Schema({da.check.schema.common.LOWERCASE_NAME: str}) return Schema({ 'type': Any('constructor', 'context_manager', 'coroutine', 'function', 'generator'), 'args': key_value_pair, Optional('yields'): Any(key_value_pair, str), Optional('returns'): Any(key_value_pair, str), Optional('preconditions'): [str], Optional('side_effects'): [str], })
def class_metadata_schema(): """ Return the data validation schema for python class metadata. """ return Schema({ 'type': 'class', 'attributes': { da.check.schema.common.LOWERCASE_NAME: str } })
def section_content(): """ Return the engineering document section content schema. """ return Schema({ Required('_num'): str, Required('_req'): str, Required('_txt'): Any(str, None), Extra: Reject })
def get(): """ Return the data validation schema for the mnemonic register. """ common = da.check.schema.common return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': [common.LOWERCASE_NAME], Extra: Reject })
def job_comments(idclass_tab): """ Return the daybook.job_description schema. """ job_id = idclass_tab['job'] return Schema({ Required(job_id): All(list, Length(min=2, max=2), [ da.check.schema.common.SUMMARY_TEXT, da.check.schema.common.PARAGRAPH_TEXT ]) })
def get(idclass_tab): """ Return the daybook schema. """ return Schema({ Required('agenda'): job_descriptions(idclass_tab), Required('chronicle'): { Required(da.check.schema.common.DATE_YYYYMMDD): [job_comments(idclass_tab)], Extra: Reject }, Extra: Reject })
def get(): """ Return the glossary schema. """ common = da.check.schema.common return Schema({ Required(common.LOWERCASE_NAME): { 'def': common.PARAGRAPH_TEXT, 'alt': [str], 'tag': [str], 'ref': [str] } })
def get(idclass_tab): """ Return the data specification schema for requiremnts specifications. """ common = da.check.schema.common item_id = idclass_tab['item'] return Schema({ Required('title'): common.TITLE_TEXT, Required(item_id): common.requirement_item_schema(idclass_tab), Extra: Reject })
def get(): """ Return data validation schema for the design document repository register. """ common = da.check.schema.common return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { common.LOWERCASE_PATH: { 'configuration': Any(None, common.LOWERCASE_HEX) } }, Extra: Reject })
def get(idclass_tab): """ Return the data validation schema for the process class register. """ common = da.check.schema.common process_class_id = idclass_tab['process_class'] return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { process_class_id: { 'name': common.TITLE_TEXT } }, Extra: Reject })
def get(idclass_tab): """ Return the data validation schema for the codeword register. """ common = da.check.schema.common counterparty_id = idclass_tab['counterparty'] machine_id = idclass_tab['machine'] project_id = idclass_tab['project'] return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { common.LOWERCASE_NAME: Maybe([counterparty_id, machine_id, project_id]) }, Extra: Reject })
def get(): """ Return the dataflow schema. """ common = da.check.schema.common return Schema({ 'title': common.TITLE_TEXT, 'dataflow': { common.LOWERCASE_NAME: { 'order': int, 'logic': common.LOWERCASE_NAME, 'edges': [[common.LOWERCASE_NAME, common.LOWERCASE_NAME]] } }, Extra: Reject })
def get(): """ Return the data validation schema for the dependencies register. """ common = da.check.schema.common api_iface_name = Any('include', 'lib_native', 'lib_javascript', 'lib_python2', 'lib_python3') api_config = Any({}, {api_iface_name: common.LOWERCASE_PATH}) cli_config = Any({}, {common.LOWERCASE_NAME: common.LOWERCASE_PATH}) gui_config = Any({}, {common.LOWERCASE_NAME: common.LOWERCASE_PATH}) return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { common.LOWERCASE_NAME: { 'desc': Any('TBD', common.SUMMARY_TEXT), 'notes': Any('TBD', common.PARAGRAPH_TEXT), 'dirname': common.LOWERCASE_NAME, 'policy': common.LOWERCASE_NAME, 'api': api_config, 'cli': cli_config, 'gui': gui_config, 'config': { 'method': Any('automatic', 'manual', 'n/a'), 'tool': Any('bzr', 'git', 'hg', 'svn', 'darcs', 'ftp', 'manual', 'n/a', 'TBD'), 'url': common.URL }, 'build': { 'method': Any('automatic', 'manual', 'n/a'), 'tool': Any('n/a', 'python_setuptools', 'python_distutils', 'make', 'n/a', 'TBD') } } }, Extra: Reject })
def get(idclass_tab): """ Return the data validation schema for the machine register. """ common = da.check.schema.common machine_id = idclass_tab['machine'] return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { machine_id: { 'hostname': common.LOWERCASE_NAME, 'desc': common.TITLE_TEXT } }, Extra: Reject })
def get(idclass_tab): """ Return the data validation schema for the dependencies register. """ common = da.check.schema.common lifecycle_product_class_id = idclass_tab['lifecycle_product_class'] return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { lifecycle_product_class_id: { 'name': common.SUMMARY_TEXT, 'purpose': common.PARAGRAPH_TEXT } }, Extra: Reject })
def get(): """ Return the data validation schema for the identifier class register. """ common = da.check.schema.common return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { common.LOWERCASE_NAME: { 'desc': common.TITLE_TEXT, Optional('pfix'): Match(r'[a-z]{1,3}'), Optional('dgts'): Range(1, 12), Optional('expr'): str, 'note': common.PARAGRAPH_TEXT } }, Extra: Reject })
def get(idclass_tab): """ Return the data validation schema for the dependencies register. """ common = da.check.schema.common coordinate_system_id = idclass_tab['coordinate_system'] return Schema({ 'title': common.TITLE_TEXT, 'introduction': common.PARAGRAPH_TEXT, 'register': { coordinate_system_id: { 'name': common.SUMMARY_TEXT, 'mnemonic': common.LOWERCASE_NAME, 'description': common.PARAGRAPH_TEXT, 'definition': common.PARAGRAPH_TEXT } }, Extra: Reject })
def metadata(): """ Return the engineering document metadata schema. """ return Schema({ Required('_metadata'): { Required('document_type'): str, Required('document_type_acronym'): str, Optional('system_of_interest_name'): str, Optional('document_id'): str, Optional('compilation_date'): str, Optional('timebox_id'): str, Optional('configuration_id'): str, Optional('lifecycle_stage'): str, Optional('protective_marking'): str, Optional('contact_person'): str, Optional('contact_email'): str, Extra: Reject } })
def __call__(self, name, type_or_validator, default=Unspecified): """ Getting a variable from config file is here. :param name: variable name in the config file :param type_or_validator: how validate this variable :param default: if specified, after failed getting a variable from config, this default will be used :return: validated variable from config file (`Schema` object) """ if self._is_collected(name): raise self.ReassignmentError( 'Variable "{}" is already loaded'.format(name)) if not isinstance(type_or_validator, Schema): type_or_validator = Schema(type_or_validator) default_is_specified = default is not Unspecified default_is_used = False try: value = self._load_from_file_entry(name) except self.IncompleteConfigError: if default_is_specified: value = default default_is_used = True self._data[name] = value else: raise if not default_is_used: # Validate only if it is not a default value try: validated_value = type_or_validator(value) except Invalid as e: raise self.ValidationError(e) else: validated_value = value self._collected_data.append(name) return validated_value