예제 #1
0
def _construct_creators(creators, ignore_email=False):
    from collections.abc import Iterable

    creators = creators or ()

    if not isinstance(creators, Iterable) or isinstance(creators, str):
        raise errors.ParameterError("Invalid type")

    people = []
    no_email_warnings = []
    for creator in creators:
        if isinstance(creator, str):
            person = Person.from_string(creator)
        elif isinstance(creator, dict):
            person = Person.from_dict(creator)
        else:
            raise errors.ParameterError("Invalid type")

        message = 'A valid format is "Name <email> [affiliation]"'

        if not person.name:  # pragma: no cover
            raise errors.ParameterError(
                f'Name is invalid: "{creator}".\n{message}')

        if not person.email:
            if not ignore_email:  # pragma: no cover
                raise errors.ParameterError(
                    f'Email is invalid: "{creator}".\n{message}')
            else:
                no_email_warnings.append(creator)

        people.append(person)

    return people, no_email_warnings
예제 #2
0
def create_dataset(
    client,
    name,
    short_name=None,
    description=None,
    creators=None,
    commit_message=None,
):
    """Create an empty dataset in the current repo.

    :raises: ``renku.core.errors.ParameterError``
    """
    if not creators:
        creators = [Person.from_git(client.repo)]

    elif hasattr(creators, '__iter__') and isinstance(creators[0], str):
        creators = [Person.from_string(c) for c in creators]

    elif hasattr(creators, '__iter__') and isinstance(creators[0], dict):
        creators = [Person.from_dict(creator) for creator in creators]

    dataset, _, __ = client.create_dataset(name=name,
                                           short_name=short_name,
                                           description=description,
                                           creators=creators)

    return dataset