Esempio n. 1
0
def validate_yaml_groups(groups, yaml_file):
    """Validate groups in clowder loaded from yaml file

    :param dict groups: Parsed YAML python object for groups
    :param str yaml_file: Path to yaml file
    """

    validate_type(groups, 'groups', list, 'list', yaml_file)
    validate_not_empty(groups, 'groups', yaml_file)

    for group in groups:
        validate_type(group, 'group', dict, 'dict', yaml_file)
        validate_not_empty(group, 'group', yaml_file)

        validate_required_string(group, 'group', 'name', yaml_file)

        validate_dict_contains_value(group, 'group', 'projects', yaml_file)
        validate_yaml_projects(group['projects'], yaml_file)
        del group['projects']

        validate_depth(group, yaml_file)
        validate_optional_bool(group, 'recursive', yaml_file)
        validate_optional_ref(group, yaml_file)

        string_args = ['remote', 'source', 'timestamp_author']
        for arg in string_args:
            validate_optional_string(group, arg, yaml_file)

        validate_empty(group, 'group', yaml_file)
Esempio n. 2
0
def validate_yaml_fork(fork, yaml_file):
    """Validate fork in clowder loaded from yaml file

    :param dict fork: Parsed YAML python object for fork
    :param str yaml_file: Path to yaml file
    """

    validate_type(fork, 'fork', dict, 'dict', yaml_file)
    validate_not_empty(fork, 'fork', yaml_file)

    args = ['name', 'remote']
    for arg in args:
        validate_required_string(fork, 'fork', arg, yaml_file)

    validate_empty(fork, 'fork', yaml_file)
Esempio n. 3
0
def validate_yaml_defaults_import(defaults, yaml_file):
    """Validate clowder.yaml defaults with an import

    :param dict defaults: Parsed YAML python object for defaults
    :param str yaml_file: Path to yaml file
    """

    validate_type(defaults, 'defaults', dict, 'dict', yaml_file)
    validate_depth(defaults, yaml_file)
    validate_optional_ref(defaults, yaml_file)
    validate_optional_protocol(defaults, yaml_file)
    validate_optional_bool(defaults, 'recursive', yaml_file)
    args = ['remote', 'source', 'timestamp_author']
    for arg in args:
        validate_optional_string(defaults, arg, yaml_file)

    validate_empty(defaults, 'defaults', yaml_file)
Esempio n. 4
0
def validate_yaml_sources(sources, yaml_file):
    """Validate sources in clowder loaded from yaml file

    :param dict sources: Parsed YAML python object for sources
    :param str yaml_file: Path to yaml file
    """

    validate_type(sources, 'sources', list, 'list', yaml_file)
    validate_not_empty(sources, 'sources', yaml_file)

    for source in sources:
        validate_type(source, 'source', dict, 'dict', yaml_file)
        validate_not_empty(source, 'source', yaml_file)

        args = ['name', 'url']
        for arg in args:
            validate_required_string(source, 'source', arg, yaml_file)

        validate_empty(source, 'source', yaml_file)
Esempio n. 5
0
def validate_yaml_defaults(defaults, yaml_file):
    """Validate defaults in clowder loaded from yaml file

    :param dict defaults: Parsed YAML python object for defaults
    :param str yaml_file: Path to yaml file
    """

    validate_type(defaults, 'defaults', dict, 'dict', yaml_file)
    validate_not_empty(defaults, 'defaults', yaml_file)
    validate_required_ref(defaults, yaml_file)
    validate_required_protocol(defaults, yaml_file)
    validate_required_string(defaults, 'defaults', 'remote', yaml_file)
    validate_required_string(defaults, 'defaults', 'source', yaml_file)

    validate_depth(defaults, yaml_file)
    validate_optional_bool(defaults, 'recursive', yaml_file)
    validate_optional_string(defaults, 'timestamp_author', yaml_file)

    validate_empty(defaults, 'defaults', yaml_file)
Esempio n. 6
0
def validate_yaml_projects(projects, yaml_file):
    """Validate projects in clowder loaded from yaml file

    :param dict projects: Parsed YAML python object for projects
    :param str yaml_file: Path to yaml file
    """

    validate_type(projects, 'projects', list, 'list', yaml_file)
    validate_not_empty(projects, 'projects', yaml_file)

    for project in projects:
        validate_type(project, 'project', dict, 'dict', yaml_file)
        validate_not_empty(project, 'project', yaml_file)

        validate_required_string(project, 'project', 'name', yaml_file)
        validate_required_string(project, 'project', 'path', yaml_file)

        _validate_yaml_project_optional(project, yaml_file)

        validate_empty(project, 'project', yaml_file)