def _try_link(
    links,
    base_obs,
    obs_type,
    value,
    description,
    source,
    first_seen=None,
    last_seen=None,
):
    """Try to add a link from `base_obs` to a new or existing obervable of
    type `obs_type`. ObservableValidationError exceptions on observable
    creation are silently ignored.

    This is useful, for example, to prevent crashes when trying to add
    Hostname observables based on fields that can contain either a
    hostname or an IP address (e.g., the commonName field of X509
    certificate subjects).

    """
    try:
        obs = obs_type.get_or_create(value=value)
    except ObservableValidationError:
        pass
    else:
        links.update(
            base_obs.link_to(
                obs, description, source, first_seen=first_seen, last_seen=last_seen
            )
        )
Try to add a link from `base_obs` to a new or existing obervable of
    type `obs_type`. ObservableValidationError exceptions on observable
    creation are silently ignored.

    This is useful, for example, to prevent crashes when trying to add
    Hostname observables based on fields that can contain either a
    hostname or an IP address (e.g., the commonName field of X509
    certificate subjects).

    
contrib/analytics/ivre_api/ivre_api.py