# Path: dplace_app/models.py
# class Source(models.Model):
#     """
#     Stores references for Value, also for dataset sources.
#     """
#     # Not really sure if we should separate dataset sources from references (I
#     # think we should), but since all the code has already been written with
#     # this model, I won't change it yet.
# 
#     # text, because might be '1996', '1999-2001', or 'ND'
#     year = models.CharField(max_length=30, db_index=True)
#     author = models.TextField(db_index=True)
#     reference = models.TextField()
#     name = models.CharField(max_length=100, db_index=True, default="")
# 
#     def __unicode__(self):
#         return "%s (%s)" % (self.author, self.year)
# 
#     class Meta(object):
#         unique_together = ('year', 'author')
#         ordering = ('name', )


import sys
import re
import django
import attr
from itertools import groupby
from time import time
from functools import partial
from django.db import transaction
from clldutils.dsv import reader
from clldutils.text import split_text
from clldutils.path import Path
from clldutils import jsonlib
from dplace_app.models import Source
from loader.util import configure_logging, load_regions
from loader.society import society_locations, load_societies, load_society_relations
from loader.phylogenies import load_phylogenies
from loader.variables import load_vars
from loader.values import load_data
from loader.sources import load_references
from loader.glottocode import load_languages
    title = attr.ib()
    definition = attr.ib()
    type = attr.ib(
        validator=partial(valid_enum_member, ['Continuous', 'Categorical', 'Ordinal']))
    units = attr.ib()
    source = attr.ib()
    changes = attr.ib()
    notes = attr.ib()
    codes = attr.ib(default=attr.Factory(list))


@attr.s
class Data(object):
    soc_id = attr.ib()
    sub_case = attr.ib()
    year = attr.ib()
    var_id = attr.ib()
    code = attr.ib()
    comment = attr.ib()
    references = attr.ib(convert=semicolon_split)
    source_coded_data = attr.ib()
    admin_comment = attr.ib()


@attr.s
class ObjectWithSource(object):
    id = attr.ib()
    name = attr.ib()
    year = attr.ib()
    author = attr.ib()

# Path: dplace_app/models.py
# class Source(models.Model):
#     """
#     Stores references for Value, also for dataset sources.
#     """
#     # Not really sure if we should separate dataset sources from references (I
#     # think we should), but since all the code has already been written with
#     # this model, I won't change it yet.
# 
#     # text, because might be '1996', '1999-2001', or 'ND'
#     year = models.CharField(max_length=30, db_index=True)
#     author = models.TextField(db_index=True)
#     reference = models.TextField()
#     name = models.CharField(max_length=100, db_index=True, default="")
# 
#     def __unicode__(self):
#         return "%s (%s)" % (self.author, self.year)
# 
#     class Meta(object):
#         unique_together = ('year', 'author')
#         ordering = ('name', )


# Path: dplace_app/load.py
import sys
import re
import django
import attr
from itertools import groupby
from time import time
from functools import partial
from django.db import transaction
from clldutils.dsv import reader
from clldutils.text import split_text
from clldutils.path import Path
from clldutils import jsonlib
from dplace_app.models import Source
from loader.util import configure_logging, load_regions
from loader.society import society_locations, load_societies, load_society_relations
from loader.phylogenies import load_phylogenies
from loader.variables import load_vars
from loader.values import load_data
from loader.sources import load_references
from loader.glottocode import load_languages

    title = attr.ib()
    definition = attr.ib()
    type = attr.ib(
        validator=partial(valid_enum_member, ['Continuous', 'Categorical', 'Ordinal']))
    units = attr.ib()
    source = attr.ib()
    changes = attr.ib()
    notes = attr.ib()
    codes = attr.ib(default=attr.Factory(list))


@attr.s
class Data(object):
    soc_id = attr.ib()
    sub_case = attr.ib()
    year = attr.ib()
    var_id = attr.ib()
    code = attr.ib()
    comment = attr.ib()
    references = attr.ib(convert=semicolon_split)
    source_coded_data = attr.ib()
    admin_comment = attr.ib()


@attr.s
class ObjectWithSource(object):
    id = attr.ib()
    name = attr.ib()
    year = attr.ib()
    author = attr.ib()

    reference = attr.ib()