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 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(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 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_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 the glossary schema. """ common = da.check.schema.common return Schema({Required('title'): common.TITLE_TEXT, Extra: Reject})
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 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 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(): """ 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] } })
# -*- coding: utf-8 -*- from good import Schema, All, Required, Optional, Length, Match, Email login_schema = Schema({ Required('login'): unicode, Required('password'): unicode }) signup_schema = Schema({ Required('username'): All(unicode, Match(r'^[\w.]+$'), Length(max=32)), Required('email'): Email(), Required('password'): All(unicode, Length(min=3, max=32)) }) edit_schema = Schema({ Optional('firstname'): All(unicode, Length(max=32)), Optional('lastname'): All(unicode, Length(max=32)), Optional('password'): Schema({ Required('old'): All(unicode, Length(min=3, max=32)), Required('new'): All(unicode, Length(min=3, max=32)) }) })
# -*- coding: utf-8 -*- from good import Schema, Required signup = Schema({ Required('username'): unicode, Required('password'): unicode })
except Invalid as err: raise DataFormatError('{} format error: {}'.format(name, err)) def _check_and_write_data(data, stream, schema, name): try: schema(copy.deepcopy(data)) except Invalid as err: raise DataFormatError('{} format error: {}'.format(name, err)) yaml.dump(data, stream, Dumper) CameraParameters = namedtuple('CameraParameters', ('fov_y', 'aspect_ratio')) CAMERA_PARAMETERS_SCHEMA = Schema({ Required('camera'): { Required('fov_y'): All(float, Range(min=0)), Required('aspect_ratio'): All(float, Range(min=0)) } }) def read_camera_parameters(stream: IO[str]) -> CameraParameters: data = _check_data_format(stream, CAMERA_PARAMETERS_SCHEMA, 'Camera') return CameraParameters(data['camera']['fov_y'], data['camera']['aspect_ratio']) def write_camera_parameters(camera_parameters: CameraParameters, stream: IO[str]) -> None: data = {
def file_metadata_schema(idclass_tab): """ Return the data validation schema for python file metadata. """ hiai_copyright = Schema( 'Copyright 2016 High Integrity Artificial Intelligence Systems') hashdist_copyright = Schema( 'Copyright 2012, Dag Sverre Seljebotn and Ondrej Certik') copyright_notice = Any(hiai_copyright, hashdist_copyright) apache_license_v2 = Schema( 'Licensed under the Apache License, Version 2.0 ' '(the License); you may not use this file except in compliance ' 'with the License. You may obtain a copy of the License at\n' 'http://www.apache.org/licenses/LICENSE-2.0\n' 'Unless required by applicable law or agreed to in writing, ' 'software distributed under the License is distributed on an ' 'AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, ' 'either express or implied. See the License for the specific ' 'language governing permissions and limitations under the ' 'License.') bsd_3_clause_license = ( 'Licensed under the BSD 3-clause license.\n' 'Redistribution and use in source and binary forms, with or without ' 'modification, are permitted provided that the following conditions ' 'are met:\n' 'Redistributions of source code must retain the above copyright ' 'notice, this list of conditions and the following disclaimer.\n' 'Redistributions in binary form must reproduce the above ' 'copyright notice, this list of conditions and the following ' 'disclaimer in the documentation and/or other materials provided ' 'with the distribution.\n' 'Neither the name of the copyright holders nor the names of ' 'other contributors may be used to endorse or promote products ' 'derived from this software without specific prior written ' 'permission.\n' 'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ' 'AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ' 'LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ' 'FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ' 'COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ' 'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ' 'BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ' 'LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ' 'CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ' 'LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ' 'ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ' 'POSSIBILITY OF SUCH DAMAGE.') counterparty_confidential = Schema( 'This document is not intended for redistribution. ' 'Counterparty confidentiality should be taken ' 'into consideration when handling this document. ' 'Nondisclosure agreements or other similar ' 'contractual obligations may be in force.') license_notice = Any(apache_license_v2, bsd_3_clause_license, counterparty_confidential) protection_level = All(idclass_tab['protection_level'], Any('k00_public', 'k01_counterparty_confidential')) validation_level = All(idclass_tab['validation_level'], Any('v00_minimum')) return Schema({ Required('type'): Any('python_module', 'python_package'), Required('validation_level'): validation_level, Required('protection'): protection_level, Required('copyright'): copyright_notice, Required('license'): license_notice, Extra: Reject })
def get(idclass_tab): """ Return the build configuration schema. """ common = da.check.schema.common environment_id = idclass_tab['environment'] build_scope = Schema({ Optional('defined_baselines'): [common.GIT_COMMIT_ISH], Optional('environment'): [environment_id], Optional('restriction'): common.BUILD_RESTRICTION, Extra: Reject }) build_options = Schema({ Optional('clean_tmp_dir'): bool, Optional('auto_commit'): bool, Optional('loglevel_overall'): common.LOG_LEVEL, Optional('loglevel_file'): common.LOG_LEVEL, Optional('loglevel_console'): common.LOG_LEVEL, Optional('enable_build_profiling'): bool, Optional('enable_build_debugger'): bool, Optional('enable_cms_registration'): bool, Optional('enable_cms_delete_old_builds'): bool, Optional('cms_expiration_days'): int, Optional('check_changed_files_only'): bool, Optional('errors_abort_immediately'): bool, Optional('dep_build_exclusion'): Maybe(str), Optional('dep_build_limitation'): Maybe(str), Optional('optimisation_module'): Maybe(str), Extra: Reject }) build_steps = Schema({ Optional('enable_dep_fetch_src'): bool, Optional('enable_dep_build'): bool, Optional('enable_main_build'): bool, Optional('enable_test_python_unittest'): bool, Optional('enable_static_data_validation'): bool, Optional('enable_static_indexing'): bool, Optional('enable_static_test_python_complexity'): bool, Optional('enable_static_test_python_codestyle'): bool, Optional('enable_static_test_python_docstyle'): bool, Optional('enable_static_test_python_pylint'): bool, Optional('enable_static_test_python_typecheck'): bool, Optional('enable_compile_gcc'): bool, Optional('enable_compile_clang'): bool, Optional('enable_generate_design_docs'): bool, Optional('enable_report_generation'): bool, Optional('enable_bulk_data_checks'): bool, Extra: Reject }) return Schema({ Required('title'): common.TITLE_TEXT, Optional('scope'): build_scope, Optional('options'): build_options, Optional('steps'): build_steps, Extra: Reject })
# -*- coding: utf-8 -*- __author__ = 'AminHP' # python imports from good import Schema, All, Any, Required, Optional, Length, Range, Match, Default # project imports from project.modules.recaptcha_validator import ReCaptcha create_schema = Schema({ Required('name'): All(unicode, Length(min=1, max=32)), Required('starts_at'): int, Required('ends_at'): int, Required('recaptcha'): ReCaptcha() }) edit_schema = Schema({ Optional('name'): All(unicode, Length(min=1, max=32)), Optional('starts_at'): int, Optional('ends_at'): int }) team_join_schema = Schema({Required('team_id'): unicode}) problem_create_schema = Schema({ Required('title'): All(unicode, Length(min=1, max=32)), Required('time_limit'): All(Any(float, int), Range(min=0.1, max=10.0)), Required('space_limit'): All(int, Range(min=16, max=256))
# -*- coding: utf-8 -*- __author__ = 'AminHP' from good import Schema, All, Any, Required, Optional, Length, Match, Default create_schema = Schema({ Required('name'): All(unicode, Length(min=1, max=32)), Required('members'): Any(All([Schema(unicode)], Length(max=2)), Default([])) }) edit_schema = Schema({ Optional('name'): All(unicode, Length(min=1, max=32)), Optional('members'): All([Schema(unicode)], Length(max=2)) })
# -*- coding: utf-8 -*- from good import Schema, All, Required, Length, Match, Email signup = Schema({ Required('username'): All(unicode, Match(r'^[a-zA-Z0-9_]+$')), Required('email'): Email(), Required('password'): All(unicode, Length(min=5)) })
# -*- coding: utf-8 -*- __author__ = 'AminHP' # python imports from good import Schema, All, Required, Optional, Length, Match, Email # project imports from project.modules.recaptcha_validator import ReCaptcha signup_schema = Schema({ Required('username'): All(unicode, Match(r'^[a-zA-Z0-9_]*$'), Length(min=1, max=32)), Required('email'): Email(), Required('password'): All(unicode, Length(min=3, max=32)), Required('recaptcha'): ReCaptcha() }) login_schema = Schema({ Required('login'): unicode, Required('password'): unicode }) edit_schema = Schema({ Optional('email'): Email(), Optional('password'): Schema({ Required('old_password'): All(unicode, Length(min=3, max=32)), Required('new_password'): All(unicode, Length(min=3, max=32)) }), Optional('firstname'): All(unicode, Length(min=1, max=32)),
# -*- coding: utf-8 -*- from good import Schema, Required welcome = Schema({Required('name'): unicode})