# Path: inspire_schemas/utils.py
# def filter_empty_parameters(func):
#     """Decorator that is filtering empty parameters.
# 
#     :param func: function that you want wrapping
#     :type func: function
#     """
#     @wraps(func)
#     def func_wrapper(self, *args, **kwargs):
#         my_kwargs = {key: value for key, value in kwargs.items()
#                      if value not in EMPTIES}
#         args_is_empty = all(arg in EMPTIES for arg in args)
# 
#         if (
#                 {'source', 'material'}.issuperset(my_kwargs) or not my_kwargs
#         ) and args_is_empty:
#             return
#         return func(self, *args, **my_kwargs)
# 
#     return func_wrapper
# 
# def author_id_normalize_and_schema(uid, schema=None):
#     """Detect and normalize an author UID schema.
# 
#     Args:
#         uid (string): a UID string
#         schema (string): try to resolve to schema
# 
#     Returns:
#         Tuple[string, string]: a tuple (uid, schema) where:
#         - uid: the UID normalized to comply with the id.json schema
#         - schema: a schema of the UID or *None* if not recognised
# 
#     Raise:
#         UnknownUIDSchema: if UID is too little to definitively guess the schema
#         SchemaUIDConflict: if specified schema is not matching the given UID
#     """
#     def _get_uid_normalized_in_schema(_uid, _schema):
#         regex, template = _RE_AUTHORS_UID[_schema]
#         match = regex.match(_uid)
#         if match:
#             return template.format(match.group('uid'))
# 
#     if idutils.is_orcid(uid) and schema in (None, 'ORCID'):
#         return idutils.normalize_orcid(uid), 'ORCID'
# 
#     if schema and schema not in _RE_AUTHORS_UID:
#         # Schema explicitly specified, but this function can't handle it
#         raise UnknownUIDSchema(uid)
# 
#     if schema:
#         normalized_uid = _get_uid_normalized_in_schema(uid, schema)
#         if normalized_uid:
#             return normalized_uid, schema
#         else:
#             raise SchemaUIDConflict(schema, uid)
# 
#     match_schema, normalized_uid = None, None
#     for candidate_schema in _RE_AUTHORS_UID:
#         candidate_uid = _get_uid_normalized_in_schema(uid, candidate_schema)
#         if candidate_uid:
#             if match_schema:
#                 # Valid against more than one candidate schema, ambiguous
#                 raise UnknownUIDSchema(uid)
#             match_schema = candidate_schema
#             normalized_uid = candidate_uid
# 
#     if match_schema:
#         return normalized_uid, match_schema
# 
#     # No guessess have been found
#     raise UnknownUIDSchema(uid)
# 
# Path: inspire_schemas/errors.py
# class UnknownUIDSchema(InspireSchemasException):
#     """Exception raised when a schema of a UID is unknown."""
# 
#     def __init__(self, uid):
#         """Exception raised when a schema of a UID is unknown.
# 
#         Args:
#             uid (string): given UID
#         """
#         message = 'Schema of UID "{}" is unrecognized.'.format(uid)
#         super(UnknownUIDSchema, self).__init__(message)


from inspire_utils.name import normalize_name
from ..utils import (
    filter_empty_parameters,
    author_id_normalize_and_schema,
)
from ..errors import UnknownUIDSchema
        })

    @filter_empty_parameters
    def set_uid(self, uid, schema=None):
        """Set a unique ID.

        If a UID of a given schema already exists in a record it will
        be overwritten, otherwise it will be appended to the record.

        Args:
            uid (string): unique identifier.
            schema (Optional[string]): schema of the unique identifier. If
                ``None``, the schema will be guessed based on the shape of
                ``uid``.

        Raises:
            SchemaUIDConflict: it UID and schema are not matching
        """
        try:
            uid, schema = author_id_normalize_and_schema(uid, schema)
        except UnknownUIDSchema:
            # Explicit schema wasn't provided, and the UID is too little
            # to figure out the schema of it, this however doesn't mean
            # the UID is invalid
            pass

        self._ensure_field('ids', [])
        self.obj['ids'] = [id_ for id_ in self.obj['ids'] if id_.get('schema') != schema]
        self._add_uid(uid, schema)


# Path: inspire_schemas/utils.py
# def filter_empty_parameters(func):
#     """Decorator that is filtering empty parameters.
# 
#     :param func: function that you want wrapping
#     :type func: function
#     """
#     @wraps(func)
#     def func_wrapper(self, *args, **kwargs):
#         my_kwargs = {key: value for key, value in kwargs.items()
#                      if value not in EMPTIES}
#         args_is_empty = all(arg in EMPTIES for arg in args)
# 
#         if (
#                 {'source', 'material'}.issuperset(my_kwargs) or not my_kwargs
#         ) and args_is_empty:
#             return
#         return func(self, *args, **my_kwargs)
# 
#     return func_wrapper
# 
# def author_id_normalize_and_schema(uid, schema=None):
#     """Detect and normalize an author UID schema.
# 
#     Args:
#         uid (string): a UID string
#         schema (string): try to resolve to schema
# 
#     Returns:
#         Tuple[string, string]: a tuple (uid, schema) where:
#         - uid: the UID normalized to comply with the id.json schema
#         - schema: a schema of the UID or *None* if not recognised
# 
#     Raise:
#         UnknownUIDSchema: if UID is too little to definitively guess the schema
#         SchemaUIDConflict: if specified schema is not matching the given UID
#     """
#     def _get_uid_normalized_in_schema(_uid, _schema):
#         regex, template = _RE_AUTHORS_UID[_schema]
#         match = regex.match(_uid)
#         if match:
#             return template.format(match.group('uid'))
# 
#     if idutils.is_orcid(uid) and schema in (None, 'ORCID'):
#         return idutils.normalize_orcid(uid), 'ORCID'
# 
#     if schema and schema not in _RE_AUTHORS_UID:
#         # Schema explicitly specified, but this function can't handle it
#         raise UnknownUIDSchema(uid)
# 
#     if schema:
#         normalized_uid = _get_uid_normalized_in_schema(uid, schema)
#         if normalized_uid:
#             return normalized_uid, schema
#         else:
#             raise SchemaUIDConflict(schema, uid)
# 
#     match_schema, normalized_uid = None, None
#     for candidate_schema in _RE_AUTHORS_UID:
#         candidate_uid = _get_uid_normalized_in_schema(uid, candidate_schema)
#         if candidate_uid:
#             if match_schema:
#                 # Valid against more than one candidate schema, ambiguous
#                 raise UnknownUIDSchema(uid)
#             match_schema = candidate_schema
#             normalized_uid = candidate_uid
# 
#     if match_schema:
#         return normalized_uid, match_schema
# 
#     # No guessess have been found
#     raise UnknownUIDSchema(uid)
# 
# Path: inspire_schemas/errors.py
# class UnknownUIDSchema(InspireSchemasException):
#     """Exception raised when a schema of a UID is unknown."""
# 
#     def __init__(self, uid):
#         """Exception raised when a schema of a UID is unknown.
# 
#         Args:
#             uid (string): given UID
#         """
#         message = 'Schema of UID "{}" is unrecognized.'.format(uid)
#         super(UnknownUIDSchema, self).__init__(message)


# Path: inspire_schemas/builders/signatures.py
from inspire_utils.name import normalize_name
from ..utils import (
    filter_empty_parameters,
    author_id_normalize_and_schema,
)
from ..errors import UnknownUIDSchema

        })

    @filter_empty_parameters
    def set_uid(self, uid, schema=None):
        """Set a unique ID.

        If a UID of a given schema already exists in a record it will
        be overwritten, otherwise it will be appended to the record.

        Args:
            uid (string): unique identifier.
            schema (Optional[string]): schema of the unique identifier. If
                ``None``, the schema will be guessed based on the shape of
                ``uid``.

        Raises:
            SchemaUIDConflict: it UID and schema are not matching
        """
        try:
            uid, schema = author_id_normalize_and_schema(uid, schema)
        except UnknownUIDSchema:
            # Explicit schema wasn't provided, and the UID is too little
            # to figure out the schema of it, this however doesn't mean
            # the UID is invalid
            pass

        self._ensure_field('ids', [])
        self.obj['ids'] = [id_ for id_ in self.obj['ids'] if id_.get('schema') != schema]
        self._add_uid(uid, schema)


    @filter_empty_parameters