Skip to content

Commit

Permalink
use better support for cldf export from clld
Browse files Browse the repository at this point in the history
  • Loading branch information
xrotwang committed Jun 23, 2016
1 parent f0824d0 commit b759055
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 35 deletions.
47 changes: 45 additions & 2 deletions ids/adapters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import unicode_literals

from clld.db.meta import DBSession
from clld.db.models.common import Language
from clld.db.models.common import Language, Identifier
from clld.web.adapters.geojson import GeoJsonParameter, GeoJsonLanguages
from clld.interfaces import IParameter, IContribution, IIndex
from clld.web.adapters.cldf import CldfDataset
from clld.interfaces import IParameter, IContribution, IIndex, ICldfDataset


class GeoJsonMeaning(GeoJsonParameter):
Expand All @@ -20,6 +21,48 @@ def feature_iterator(self, ctx, req):
return DBSession.query(Language)


class CldfDictionary(CldfDataset):
def columns(self, req):
return [
'ID',
{
'name': 'Language_ID',
'valueUrl': Identifier(type='glottolog', name='{Language_ID}').url()},
'Language_name',
{
'name': 'Parameter_ID',
'valueUrl': 'http://concepticon.clld.org/parameters/{Parameter_ID}'},
'Value',
'Transcription',
'Concept',
'Source',
'Comment',
'AlternativeValue',
'AlternativeTranscription',
]

def refs_and_sources(self, req, value):
if not hasattr(self, '_refs_and_sources'):
self._refs_and_sources = CldfDataset.refs_and_sources(self, req, self.obj)
return self._refs_and_sources

def row(self, req, value, refs):
return [
value.id,
self.obj.language.glottocode,
self.obj.language.name,
value.valueset.parameter.concepticon_id,
value.word.name,
self.obj.default_representation,
value.valueset.parameter.name,
refs,
value.valueset.comment or '',
value.valueset.alt_representation or '',
self.obj.alt_representation or '',
]


def includeme(config):
config.register_adapter(GeoJsonMeaning, IParameter)
config.register_adapter(CldfDictionary, IContribution, ICldfDataset, name='cldf')
config.register_adapter(GeoJsonDictionaries, IContribution, IIndex)
64 changes: 31 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
from setuptools import setup, find_packages

requires = [
'clld>=2.1.1',
'clldmpg>=2.0.0',
'clld-glottologfamily-plugin>=0.3',
]

tests_require = [
'WebTest >= 1.3.1', # py3 compat
'mock',
'psycopg2',
]

setup(name='ids',
version='0.0',
description='ids',
long_description='',
classifiers=[
setup(
name='ids',
version='0.0',
description='ids',
long_description='',
classifiers=[
"Programming Language :: Python",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='',
author_email='',
url='',
keywords='web pyramid pylons',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=requires,
tests_require=tests_require,
test_suite="ids",
entry_points="""\
[paste.app_factory]
main = ids:main
""",
)
],
author='',
author_email='',
url='',
keywords='web pyramid pylons',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=[
'clld>=2.2.2',
'clldmpg>=2.0.0',
'clld-glottologfamily-plugin>=1.3',
'pycldf>=0.3.0',
],
tests_require=[
'WebTest >= 1.3.1', # py3 compat
'mock',
'psycopg2',
],
test_suite="ids",
entry_points="""\
[paste.app_factory]
main = ids:main
""",
)

0 comments on commit b759055

Please sign in to comment.