# Path: inspire_schemas/builders/builder.py
# class RecordBuilder(object):
#     """Base record builder."""
# 
#     _collections = []
# 
#     def __init__(self, record=None, source=None):
#         if record is None:
#             record = {'_collections': [_ for _ in self.__class__._collections]}
#         self.record = record
#         self.source = source
# 
#     def __repr__(self):
#         """Printable representation of the builder."""
#         return u'{}(source={!r}, record={})'.format(
#             type(self).__name__,
#             self.source,
#             self.record
#         )
# 
#     @filter_empty_parameters
#     def _append_to(self, field, element=None, default_list=None, **kwargs):
#         if default_list is None:
#             default_list = []
#         if element not in EMPTIES:
#             self._ensure_list_field(field, default_list)
#             if element not in self.record[field]:
#                 self.record[field].append(element)
#         elif kwargs:
#             if 'record' in kwargs and isinstance(kwargs['record'], six.string_types):
#                 kwargs['record'] = {'$ref': kwargs['record']}
#             self._ensure_list_field(field, default_list)
#             if kwargs not in self.record[field]:
#                 self.record[field].append(kwargs)
# 
#     def _ensure_field(self, field_name, default_value, obj=None):
#         if obj is None:
#             obj = self.record
#         if field_name not in obj:
#             obj[field_name] = default_value
# 
#     def _ensure_list_field(self, field_name, default_value=None, obj=None):
#         if default_value is None:
#             default_value = []
#         self._ensure_field(field_name, default_value, obj)
# 
#     def _ensure_dict_field(self, field_name, default_value=None, obj=None):
#         if default_value is None:
#             default_value = {}
#         self._ensure_field(field_name, default_value, obj)
# 
#     def _sourced_dict(self, source=None, **kwargs):
#         if source:
#             kwargs['source'] = source
#         elif self.source:
#             kwargs['source'] = self.source
# 
#         return {key: value for key, value in kwargs.items() if value not in EMPTIES}
# 
# 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 sanitize_html(text):
#     """Sanitize HTML for use inside records fields.
# 
#     This strips most of the tags and attributes, only allowing a safe whitelisted subset."""
#     return _bleach_cleaner.clean(text)
# 
# def validate(data, schema=None):
#     """Validate the given dictionary against the given schema.
# 
#     Args:
#         data (dict): record to validate.
#         schema (Union[dict, str]): schema to validate against. If it is a
#             string, it is intepreted as the name of the schema to load (e.g.
#             ``authors`` or ``jobs``). If it is ``None``, the schema is taken
#             from ``data['$schema']``. If it is a dictionary, it is used
#             directly.
# 
#     Raises:
#         SchemaNotFound: if the given schema was not found.
#         SchemaKeyNotFound: if ``schema`` is ``None`` and no ``$schema`` key was
#             found in ``data``.
#         jsonschema.SchemaError: if the schema is invalid.
#         jsonschema.ValidationError: if the data is invalid.
#     """
#     schema = _load_schema_for_record(data, schema)
# 
#     return jsonschema_validate(
#         instance=data,
#         schema=schema,
#         resolver=LocalRefResolver.from_schema(schema),
#         format_checker=inspire_format_checker,
#     )


import six
from inspire_utils.name import normalize_name
from inspire_schemas.builders.builder import RecordBuilder
from inspire_schemas.utils import (
    filter_empty_parameters,
    sanitize_html,
    validate,
)
from inspire_utils.date import normalize_date
            category_dict = self._sourced_dict(
                source,
                term=category,
            )
            self._append_to('inspire_categories', category_dict)

    @filter_empty_parameters
    def add_keyword(self, value, schema=None, source=None):
        """Add a keyword.

        Args:
            keyword (str): keyword to add.
            schema (str): schema to which the keyword belongs.
            source (str): source for the keyword.
        """
        keyword_dict = self._sourced_dict(source, value=value, schema=schema)

        self._append_to('keywords', keyword_dict)

    @filter_empty_parameters
    def add_material_url(self, value, description=None):
        """Add url of material to list.

        Args:
            value (str): url of the material.
            description (str): description of the url.
        """
        entry = self._prepare_url(value, description)
        self._append_to('material_urls', entry)


# Path: inspire_schemas/builders/builder.py
# class RecordBuilder(object):
#     """Base record builder."""
# 
#     _collections = []
# 
#     def __init__(self, record=None, source=None):
#         if record is None:
#             record = {'_collections': [_ for _ in self.__class__._collections]}
#         self.record = record
#         self.source = source
# 
#     def __repr__(self):
#         """Printable representation of the builder."""
#         return u'{}(source={!r}, record={})'.format(
#             type(self).__name__,
#             self.source,
#             self.record
#         )
# 
#     @filter_empty_parameters
#     def _append_to(self, field, element=None, default_list=None, **kwargs):
#         if default_list is None:
#             default_list = []
#         if element not in EMPTIES:
#             self._ensure_list_field(field, default_list)
#             if element not in self.record[field]:
#                 self.record[field].append(element)
#         elif kwargs:
#             if 'record' in kwargs and isinstance(kwargs['record'], six.string_types):
#                 kwargs['record'] = {'$ref': kwargs['record']}
#             self._ensure_list_field(field, default_list)
#             if kwargs not in self.record[field]:
#                 self.record[field].append(kwargs)
# 
#     def _ensure_field(self, field_name, default_value, obj=None):
#         if obj is None:
#             obj = self.record
#         if field_name not in obj:
#             obj[field_name] = default_value
# 
#     def _ensure_list_field(self, field_name, default_value=None, obj=None):
#         if default_value is None:
#             default_value = []
#         self._ensure_field(field_name, default_value, obj)
# 
#     def _ensure_dict_field(self, field_name, default_value=None, obj=None):
#         if default_value is None:
#             default_value = {}
#         self._ensure_field(field_name, default_value, obj)
# 
#     def _sourced_dict(self, source=None, **kwargs):
#         if source:
#             kwargs['source'] = source
#         elif self.source:
#             kwargs['source'] = self.source
# 
#         return {key: value for key, value in kwargs.items() if value not in EMPTIES}
# 
# 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 sanitize_html(text):
#     """Sanitize HTML for use inside records fields.
# 
#     This strips most of the tags and attributes, only allowing a safe whitelisted subset."""
#     return _bleach_cleaner.clean(text)
# 
# def validate(data, schema=None):
#     """Validate the given dictionary against the given schema.
# 
#     Args:
#         data (dict): record to validate.
#         schema (Union[dict, str]): schema to validate against. If it is a
#             string, it is intepreted as the name of the schema to load (e.g.
#             ``authors`` or ``jobs``). If it is ``None``, the schema is taken
#             from ``data['$schema']``. If it is a dictionary, it is used
#             directly.
# 
#     Raises:
#         SchemaNotFound: if the given schema was not found.
#         SchemaKeyNotFound: if ``schema`` is ``None`` and no ``$schema`` key was
#             found in ``data``.
#         jsonschema.SchemaError: if the schema is invalid.
#         jsonschema.ValidationError: if the data is invalid.
#     """
#     schema = _load_schema_for_record(data, schema)
# 
#     return jsonschema_validate(
#         instance=data,
#         schema=schema,
#         resolver=LocalRefResolver.from_schema(schema),
#         format_checker=inspire_format_checker,
#     )


# Path: inspire_schemas/builders/seminars.py
import six
from inspire_utils.name import normalize_name
from inspire_schemas.builders.builder import RecordBuilder
from inspire_schemas.utils import (
    filter_empty_parameters,
    sanitize_html,
    validate,
)
from inspire_utils.date import normalize_date

            category_dict = self._sourced_dict(
                source,
                term=category,
            )
            self._append_to('inspire_categories', category_dict)

    @filter_empty_parameters
    def add_keyword(self, value, schema=None, source=None):
        """Add a keyword.

        Args:
            keyword (str): keyword to add.
            schema (str): schema to which the keyword belongs.
            source (str): source for the keyword.
        """
        keyword_dict = self._sourced_dict(source, value=value, schema=schema)

        self._append_to('keywords', keyword_dict)

    @filter_empty_parameters
    def add_material_url(self, value, description=None):
        """Add url of material to list.

        Args:
            value (str): url of the material.
            description (str): description of the url.
        """
        entry = self._prepare_url(value, description)
        self._append_to('material_urls', entry)


    @filter_empty_parameters