Skip to content

Commit

Permalink
Merge branch 'release/3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
xrotwang committed Feb 16, 2017
2 parents cb55df9 + 1eff0cb commit 8cdb757
Show file tree
Hide file tree
Showing 37 changed files with 10,857 additions and 6,859 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -21,6 +21,7 @@ develop-eggs
.installed.cfg
lib64
.webassets-*
.eggs

# Installer logs
pip-log.txt
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.rst
Expand Up @@ -2,6 +2,14 @@
Changes
-------


3.2.0
~~~~~

- factored out DeclEnum and LGR_ABBRS to clldutils
- upgraded leaflet to version 1.0.3


3.1.1
~~~~~

Expand Down
7 changes: 4 additions & 3 deletions LICENSE.txt
Expand Up @@ -9,6 +9,10 @@ jquery is provided via a
leaflet is provided via
`this <https://raw.github.com/Leaflet/Leaflet/master/LICENSE>`_ license.

Leaflet.fullscreen is provided via
`this <https://raw.githubusercontent.com/Leaflet/Leaflet.fullscreen/gh-pages/LICENSE`_
license.

jquery dataTables is provided via
`this <https://raw.github.com/DataTables/DataTables/master/license-bsd.txt>`_ license.

Expand All @@ -21,9 +25,6 @@ jqTree is provided via a
intro.js is provided via a
`MIT <http://opensource.org/licenses/MIT>`_ license.

audio.js is provided via a
`MIT <http://opensource.org/licenses/MIT>`_ license.

hint.css is provided via a
`MIT <http://opensource.org/licenses/MIT>`_ license.

Expand Down
2 changes: 1 addition & 1 deletion clld/__init__.py
Expand Up @@ -5,7 +5,7 @@
from clld import interfaces


__version__ = "3.1.1"
__version__ = "3.2.0"


class Resource(namedtuple('Resource', 'name model interface with_index with_rdfdump')):
Expand Down
11 changes: 0 additions & 11 deletions clld/tests/test_util.py
Expand Up @@ -49,17 +49,6 @@ class A(DeclEnum):
val1 = '1', 'value 1'
val2 = '2', 'value 2'

for val, desc in A:
assert val == '1'
break

assert '1' in repr(A.val1)
assert A.from_string('1') == A.val1
try:
A.from_string('x')
assert False # pragma: no cover
except ValueError:
assert True
db_type = A.db_type()
assert A.val1 == db_type.process_result_value(
db_type.process_bind_param(A.val1, None), None)
Expand Down
160 changes: 4 additions & 156 deletions clld/util.py
Expand Up @@ -5,10 +5,11 @@
from string import ascii_lowercase
from contextlib import contextmanager

from six import add_metaclass
from sqlalchemy.types import SchemaType, TypeDecorator, Enum
from clldutils import misc
from clldutils.path import remove, move, Path
from clldutils.declenum import DeclEnum as BaseEnum
from clldutils.lgr import ABBRS as LGR_ABBRS
assert LGR_ABBRS


def random_string(length):
Expand Down Expand Up @@ -45,74 +46,8 @@ def summary(text, max_length=70):
return res.strip()


#
# From "The Enum Recipe": http://techspot.zzzeek.org/2011/01/14/the-enum-recipe/
#
class EnumSymbol(misc.UnicodeMixin):

"""Define a fixed symbol tied to a parent class."""

def __init__(self, cls_, name, value, description, *args):
self.cls_ = cls_
self.name = name
self.value = value
self.description = description
self.args = args

def __reduce__(self):
"""Allow unpickling to return the symbol linked to the DeclEnum class."""
return getattr, (self.cls_, self.name) # pragma: no cover

def __iter__(self):
return iter([self.value, self.description])

def __repr__(self):
return "<%s>" % self.name

def __unicode__(self):
return self.value

def __lt__(self, other):
return self.value < getattr(other, 'value', None)

def __json__(self, request=None):
return self.value


class EnumMeta(type):

"""Generate new DeclEnum classes."""

def __init__(cls, classname, bases, dict_):
cls._reg = reg = cls._reg.copy()
for k, v in dict_.items():
if isinstance(v, tuple):
sym = reg[v[0]] = EnumSymbol(cls, k, *v)
setattr(cls, k, sym)
return type.__init__(cls, classname, bases, dict_)

def __iter__(cls):
return iter(sorted(cls._reg.values()))


@add_metaclass(EnumMeta)
class DeclEnum(object):

"""Declarative enumeration."""

_reg = {}

@classmethod
def from_string(cls, value):
try:
return cls._reg[value]
except KeyError:
raise ValueError("Invalid value for %r: %r" % (cls.__name__, value))

@classmethod
def values(cls):
return list(cls._reg.keys())

class DeclEnum(BaseEnum):
@classmethod
def db_type(cls):
return DeclEnumType(cls)
Expand Down Expand Up @@ -141,90 +76,3 @@ def process_result_value(self, value, dialect):
if value is None:
return None
return self.enum.from_string(value.strip())


# Standard abbreviations according to the Leipzig Glossing Rules
# see http://www.eva.mpg.de/lingua/resources/glossing-rules.php
LGR_ABBRS = {
'A': 'agent-like argument of canonical transitive verb',
'ABL': 'ablative',
'ABS': 'absolutive',
'ACC': 'accusative',
'ADJ': 'adjective',
'ADV': 'adverb(ial)',
'AGR': 'agreement',
'ALL': 'allative',
'ANTIP': 'antipassive',
'APPL': 'applicative',
'ART': 'article',
'AUX': 'auxiliary',
'BEN': 'benefactive',
'CAUS': 'causative',
'CLF': 'classifier',
'COM': 'comitative',
'COMP': 'complementizer',
'COMPL': 'completive',
'COND': 'conditional',
'COP': 'copula',
'CVB': 'converb',
'DAT': 'dative',
'DECL': 'declarative',
'DEF': 'definite',
'DEM': 'demonstrative',
'DET': 'determiner',
'DIST': 'distal',
'DISTR': 'distributive',
'DU': 'dual',
'DUR': 'durative',
'ERG': 'ergative',
'EXCL': 'exclusive',
'F': 'feminine',
'FOC': 'focus',
'FUT': 'future',
'GEN': 'genitive',
'IMP': 'imperative',
'INCL': 'inclusive',
'IND': 'indicative',
'INDF': 'indefinite',
'INF': 'infinitive',
'INS': 'instrumental',
'INTR': 'intransitive',
'IPFV': 'imperfective',
'IRR': 'irrealis',
'LOC': 'locative',
'M': 'masculine',
'N': 'neuter',
'N-': 'non- (e.g. NSG nonsingular, NPST nonpast)',
'NEG': 'negation, negative',
'NMLZ': 'nominalizer/nominalization',
'NOM': 'nominative',
'OBJ': 'object',
'OBL': 'oblique',
'P': 'patient-like argument of canonical transitive verb',
'PASS': 'passive',
'PFV': 'perfective',
'PL': 'plural',
'POSS': 'possessive',
'PRED': 'predicative',
'PRF': 'perfect',
'PRS': 'present',
'PROG': 'progressive',
'PROH': 'prohibitive',
'PROX': 'proximal/proximate',
'PST': 'past',
'PTCP': 'participle',
'PURP': 'purposive',
'Q': 'question particle/marker',
'QUOT': 'quotative',
'RECP': 'reciprocal',
'REFL': 'reflexive',
'REL': 'relative',
'RES': 'resultative',
'S': 'single argument of canonical intransitive verb',
'SBJ': 'subject',
'SBJV': 'subjunctive',
'SG': 'singular',
'TOP': 'topic',
'TR': 'transitive',
'VOC': 'vocative',
}
5 changes: 2 additions & 3 deletions clld/web/assets.py
Expand Up @@ -20,6 +20,7 @@ def skip(_in, out, **kw):
Bundle(
'js/jquery.js',
'js/leaflet-src.js',
'js/Leaflet.fullscreen.js',
filters=(skip,)),
'js/bootstrap.min.js',
'js/jquery.dataTables.min.js',
Expand All @@ -28,8 +29,6 @@ def skip(_in, out, **kw):
'js/bootstrapx-clickover.js',
'js/tree.jquery.js',
'js/leaflet-providers.js',
'js/leaflet.label.js',
'js/Control.FullScreen.js',
'js/leaflet-hash.js',
'js/clld.js',
'project.js',
Expand All @@ -38,11 +37,11 @@ def skip(_in, out, **kw):
'css': [
Bundle(
'css/leaflet.css',
'css/leaflet.fullscreen.css',
filters=(skip,)),
Bundle(
'css/clld.css',
'css/jqtree.css',
'css/leaflet.label.css',
'css/hint.css',
'css/jquery.dataTables.css',
filters='yui_css'),
Expand Down
19 changes: 0 additions & 19 deletions clld/web/static/audiojs/LICENSE

This file was deleted.

0 comments on commit 8cdb757

Please sign in to comment.