Ejemplo n.º 1
0
    def test_ContextObject(self):
        from clld.lib.coins import ContextObject

        bib = Record('book', '1', title='The Title', author='L, F')
        co = ContextObject('sid', 'book', ('btitle', 'the title'))
        co = ContextObject.from_bibtex('sid', bib)
        bib = Record('article', '1',
                     title='The Title', author='The One and The Other', journal='J')
        co = ContextObject.from_bibtex('sid', bib)
        bib = Record('phdthesis', '1', title='The Title')
        co = ContextObject.from_bibtex('sid', bib)
        bib = Record('conference', '1', title='The Title', booktitle='something')
        co = ContextObject.from_bibtex('sid', bib)
        self.assertTrue(isinstance(co.span_attrs(), dict))
Ejemplo n.º 2
0
Archivo: helpers.py Proyecto: clld/clld
def coins(req, obj, label=''):
    if not isinstance(obj, bibtex.Record):
        adapter = get_adapter(interfaces.IMetadata, obj, req, ext='md.bib')
        if not adapter:
            return label
        obj = adapter.rec(obj, req)
    co = ContextObject.from_bibtex('clld', obj)
    return HTML.span(label, **co.span_attrs())
Ejemplo n.º 3
0
def coins(req, obj, label=''):
    if not isinstance(obj, bibtex.Record):
        adapter = get_adapter(interfaces.IMetadata, obj, req, ext='md.bib')
        if not adapter:
            return label
        obj = adapter.rec(obj, req)
    co = ContextObject.from_bibtex('clld', obj)
    return HTML.span(label, **co.span_attrs())
Ejemplo n.º 4
0
def test_ContextObject():
    from clld.lib.coins import ContextObject

    c = ContextObject('sid', 'journal', ('jtitle', '\xe2'))
    assert '%C3%A2' in c.span_attrs()['title']
    c = ContextObject('sid', 'journal',
                      ('jtitle', binary_type('ä'.encode('utf8'))))
    assert '%C3%A4' in c.span_attrs()['title']

    bib = Record('book', '1', title='The Title', author='L, F')
    ContextObject('sid', 'book', ('btitle', 'the title'))
    ContextObject.from_bibtex('sid', bib)
    bib = Record('article',
                 '1',
                 title='The Title',
                 author='The One and The Other',
                 journal='J')
    ContextObject.from_bibtex('sid', bib)
    bib = Record('phdthesis', '1', title='The Title')
    ContextObject.from_bibtex('sid', bib)
    bib = Record('conference', '1', title='The Title', booktitle='something')
    co = ContextObject.from_bibtex('sid', bib)
    assert isinstance(co.span_attrs(), dict)

    assert ContextObject('äöü', 'äöü').span_attrs()
    assert ContextObject('äöü'.encode('latin1'), None).span_attrs()
Ejemplo n.º 5
0
    def test_ContextObject(self):
        from clld.lib.coins import ContextObject

        bib = Record('book', '1', title='The Title', author='L, F')
        co = ContextObject('sid', 'book', ('btitle', 'the title'))
        co = ContextObject.from_bibtex('sid', bib)
        bib = Record('article',
                     '1',
                     title='The Title',
                     author='The One and The Other',
                     journal='J')
        co = ContextObject.from_bibtex('sid', bib)
        bib = Record('phdthesis', '1', title='The Title')
        co = ContextObject.from_bibtex('sid', bib)
        bib = Record('conference',
                     '1',
                     title='The Title',
                     booktitle='something')
        co = ContextObject.from_bibtex('sid', bib)
        self.assertTrue(isinstance(co.span_attrs(), dict))
Ejemplo n.º 6
0
    def test_ContextObject(self):
        from clld.lib.coins import ContextObject

        c = ContextObject('sid', 'journal', ('jtitle', '\xe2'))
        self.assertIn('%C3%A2', c.span_attrs()['title'])
        c = ContextObject('sid', 'journal', ('jtitle', binary_type('ä'.encode('utf8'))))
        self.assertIn('%C3%A4', c.span_attrs()['title'])

        bib = Record('book', '1', title='The Title', author='L, F')
        ContextObject('sid', 'book', ('btitle', 'the title'))
        ContextObject.from_bibtex('sid', bib)
        bib = Record('article', '1',
                     title='The Title', author='The One and The Other', journal='J')
        ContextObject.from_bibtex('sid', bib)
        bib = Record('phdthesis', '1', title='The Title')
        ContextObject.from_bibtex('sid', bib)
        bib = Record('conference', '1', title='The Title', booktitle='something')
        co = ContextObject.from_bibtex('sid', bib)
        self.assertTrue(isinstance(co.span_attrs(), dict))

        assert ContextObject('äöü', 'äöü').span_attrs()
        assert ContextObject('äöü'.encode('latin1'), None).span_attrs()