Exemple #1
0
    def add_collaboration(self, collaboration):
        """Add collaboration.

        :param collaboration: collaboration for the current document
        :type collaboration: string
        """
        collaborations = normalize_collaboration(collaboration)
        for collaboration in collaborations:
            self._append_to('collaborations', {'value': collaboration})
Exemple #2
0
def collaborations(self, key, value):
    """Populate the ``collaborations`` key."""
    collaborations = normalize_collaboration(value.get('g'))

    if len(collaborations) == 1:
        return [
            {
                'record': get_record_ref(maybe_int(value.get('0')),
                                         'experiments'),
                'value': collaborations[0],
            },
        ]
    else:
        return [{'value': collaboration} for collaboration in collaborations]
def collaborations(self, key, value):
    """Populate the ``collaborations`` key."""
    result = []

    for g_value in force_list(value.get('g')):
        collaborations = normalize_collaboration(g_value)
        if len(collaborations) == 1:
            result.append({
                'record': get_record_ref(maybe_int(value.get('0')), 'experiments'),
                'value': collaborations[0],
            })
        else:
            result.extend({'value': collaboration} for collaboration in collaborations)

    return result
def test_normalize_collaboration_handles_parentheses_splits_and_removes_fluff():
    collaboration = '(for the CMS and ATLAS Collaborations)'
    assert utils.normalize_collaboration(collaboration) == ['CMS', 'ATLAS']
def test_normalize_collaboration_handles_parentheses():
    collaboration = '(ATLAS Collaboration)'
    assert utils.normalize_collaboration(collaboration) == ['ATLAS']
def test_normalize_collaboration_splits_and_removes_fluff():
    collaboration = 'for the CMS and ATLAS Collaborations'
    assert utils.normalize_collaboration(collaboration) == ['CMS', 'ATLAS']
def test_normalize_collaboration_removes_fluff():
    collaboration = 'for the ATLAS Collaboration'
    assert utils.normalize_collaboration(collaboration) == ['ATLAS']
def test_normalize_collaboration_splits_on_and():
    assert utils.normalize_collaboration('ATLAS and CMS') == ['ATLAS', 'CMS']
def test_normalize_collaboration_handles_none():
    assert utils.normalize_collaboration(None) == []
def test_normalize_collaboration_preserves_valid_input():
    assert utils.normalize_collaboration('ATLAS') == ['ATLAS']