当前位置: 首页>>代码示例>>Python>>正文


Python common.Language类代码示例

本文整理汇总了Python中clld.db.models.common.Language的典型用法代码示例。如果您正苦于以下问题:Python Language类的具体用法?Python Language怎么用?Python Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Language类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_Language

    def test_Language(self):
        from clld.db.models.common import Language

        d = Language(id='abc')
        assert d.glottocode is None
        assert d.iso_code is None
        assert d.__solr__(None)
开发者ID:cevmartinez,项目名称:clld,代码行数:7,代码来源:test_db_models.py

示例2: test_Versioning

    def test_Versioning(self):
        from clld.db.models.common import Language, Identifier, LanguageIdentifier
        from clld.db.meta import VersionedDBSession

        l = Language(id='abc', name='Old Name', jsondata={'i': 2})
        VersionedDBSession.add(l)
        VersionedDBSession.flush()
        self.assertEqual(l.version, 1)

        l.name = 'New Name'
        l.description = 'New Description'
        VersionedDBSession.flush()
        self.assertEqual(l.version, 2)

        History = l.__history_mapper__.class_
        res = VersionedDBSession.query(History).filter(History.pk == l.pk).all()
        self.assertEqual(res[0].name, 'Old Name')

        li = LanguageIdentifier(
            identifier=Identifier(id='asd', type='wals'),
            language=l)
        VersionedDBSession.flush()
        VersionedDBSession.delete(li)
        VersionedDBSession.delete(l)
        VersionedDBSession.flush()
开发者ID:FieldDB,项目名称:clld,代码行数:25,代码来源:test_db_versioned.py

示例3: test_Data

def test_Data(db):
    from clld.db.models.common import Language, Language_data

    l = Language(id='abc', name='Name')
    l.data.append(Language_data(key='abstract', value='c'))
    DBSession.add(l)
    DBSession.flush()
    DBSession.refresh(l)
    assert l.datadict()['abstract'] == 'c'
开发者ID:clld,项目名称:clld,代码行数:9,代码来源:test_db_models.py

示例4: test_Base

    def test_Base(self):
        l = Language(id='abc', name='Name')
        VersionedDBSession.add(l)
        VersionedDBSession.flush()
        VersionedDBSession.expunge(l)
        l = Language.get('abc')
        self.assertEqual(l.name, 'Name')
        assert not list(l.history())

        # a bit of a hack to test the human readable representations.
        # we exploit the fact, that on py2, string and unicode comparison does type
        # coercion, while on py3, the two methods should actually return the same string.
        self.assertEqual(l.__str__(), l.__unicode__())
        Language().__str__()
开发者ID:Woseseltops,项目名称:clld,代码行数:14,代码来源:test_db_meta.py

示例5: test_Base

def test_Base(db):
    l = Language(id='abc', name='Name')
    VersionedDBSession.add(l)
    VersionedDBSession.flush()
    VersionedDBSession.expunge(l)
    l = Language.get('abc', session=VersionedDBSession)
    assert l.name == 'Name'
    assert not list(l.history())

    # a bit of a hack to test the human readable representations.
    # we exploit the fact, that on py2, string and unicode comparison does type
    # coercion, while on py3, the two methods should actually return the same string.
    assert l.__str__() == l.__unicode__()
    Language().__str__()
    assert repr(l) == "<Language 'abc'>" if PY3 else "<Language u'abc'>"
开发者ID:clld,项目名称:clld,代码行数:15,代码来源:test_db_meta.py

示例6: get_identifier_objs

 def get_identifier_objs(self, type_):
     if getattr(type_, 'value', type_) == IdentifierType.glottolog.value:
         return [
             Identifier(name=self.id, type=IdentifierType.glottolog.value)]
     #elif type_ == IdentifierType.iso and :
     #    return
     return Language.get_identifier_objs(self, type_)
开发者ID:kublaj,项目名称:glottolog3,代码行数:7,代码来源:models.py

示例7: test_CLLDRequest

 def test_CLLDRequest(self):
     self.assertTrue(isinstance(self.env['request'].purl, URL))
     c = self.env['request'].db.query(Contribution).first()
     self.env['request'].resource_url(c, ext='geojson')
     self.assertEqual(None, self.env['request'].ctx_for_url('/some/path/to/nowhere'))
     self.env['request'].file_url(Language_files(id='1', object=Language.first()))
     assert self.env['request'].get_datatable('valuesets', ValueSet)
开发者ID:mitcho,项目名称:clld,代码行数:7,代码来源:test_web_app.py

示例8: __init__

 def __init__(self, req, model, language=None, **kw):
     super(Sources, self).__init__(req, model, **kw)
     if language:
         self.language = language
     elif 'language' in req.params:
         self.language = Language.get(req.params['language'])
     else:
         self.language = None
开发者ID:mitcho,项目名称:clld,代码行数:8,代码来源:source.py

示例9: update

def update(args):
    count = 0
    for url, glottocode in args.json.items():
        lang = Language.get(glottocode, default=None)
        if lang:
            count += 1
            lang.update_jsondata(languagelandscape=url)
    print 'assigned', count, 'languagelandscape urls'
开发者ID:kublaj,项目名称:glottolog3,代码行数:8,代码来源:languagelandscape.py

示例10: __init__

    def __init__(self, req, model, language=None, **kw):
        if language:
            self.language = language
        elif 'language' in req.params:
            self.language = Language.get(req.params['language'])
        else:
            self.language = None

        DataTable.__init__(self, req, model, **kw)
开发者ID:mitcho,项目名称:clld,代码行数:9,代码来源:unit.py

示例11: test_CLLDRequest

def test_CLLDRequest(env):
    assert isinstance(env['request'].purl, URL)
    c = env['request'].db.query(Contribution).first()
    env['request'].resource_url(c, ext='geojson')
    assert env['request'].ctx_for_url('/some/path/to/nowhere') is None
    assert env['request'].ctx_for_url('/')
    env['request'].file_url(Language_files(id='1', object=Language.first()))
    assert env['request'].get_datatable('valuesets', ValueSet)
    assert env['request'].blog is None
开发者ID:clld,项目名称:clld,代码行数:9,代码来源:test_web_app.py

示例12: __init__

 def __init__(self, req, *args, **kw):
     Parameters.__init__(self, req, *args, **kw)
     if kw.get('languages'):
         self.languages = kw['languages']
     elif 'languages' in req.params:
         self.languages = nfilter([
             Language.get(id_, default=None)
             for id_ in req.params['languages'].split(',')])
     else:
         self.languages = []
     self._langs = [
         aliased(ValueSet, name='l%s' % i) for i in range(len(self.languages))]
开发者ID:clld,项目名称:tsammalex,代码行数:12,代码来源:datatables.py

示例13: test_Versioning

    def test_Versioning(self):
        from clld.db.models.common import Language, Language_data
        from clld.db.meta import VersionedDBSession

        l = Language(id='abc', name='Old Name', jsondata={'i': 2})
        VersionedDBSession.add(l)
        VersionedDBSession.flush()
        self.assertEqual(l.version, 1)

        l.name = 'New Name'
        l.description = 'New Description'
        VersionedDBSession.flush()
        self.assertEqual(l.version, 2)

        History = l.__history_mapper__.class_
        res = VersionedDBSession.query(History).filter(History.pk == l.pk).all()
        self.assertEqual(res[0].name, 'Old Name')

        l.data.append(Language_data(key='k', value='v'))
        VersionedDBSession.flush()
        assert l.datadict()
        VersionedDBSession.delete(l)
        VersionedDBSession.flush()
开发者ID:cevmartinez,项目名称:clld,代码行数:23,代码来源:test_db_versioned.py

示例14: test_Base_jsondata

def test_Base_jsondata(db):
    l = Language(id='abc', name='Name')
    VersionedDBSession.add(l)
    VersionedDBSession.flush()
    l.update_jsondata(a=1)
    assert 'a' in l.jsondata
    l.update_jsondata(b=1)
    assert 'b' in l.jsondata and 'a' in l.jsondata
    assert 'b' in l.__json__(None)['jsondata']
开发者ID:clld,项目名称:clld,代码行数:9,代码来源:test_db_meta.py

示例15: test_CsvMixin

def test_CsvMixin(db):
    l1 = Language(id='abc', name='Name', latitude=12.4, jsondata=dict(a=None))
    DBSession.add(l1)
    DBSession.flush()
    l1 = Language.csv_query(DBSession).first()
    cols = l1.csv_head()
    row = l1.to_csv()
    for k, v in zip(cols, row):
        if k == 'jsondata':
            assert 'a' in json.loads(v)
    l2 = Language.from_csv(row)
    assert pytest.approx(l1.latitude) == l2.latitude
    row[cols.index('latitude')] = '3,5'
    l2 = Language.from_csv(row)
    assert l2.latitude < l1.latitude
开发者ID:clld,项目名称:clld,代码行数:15,代码来源:test_db_meta.py


注:本文中的clld.db.models.common.Language类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。