# 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 logging
from clldutils.text import split_text
from dplace_app.models import Source
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


_SOURCE_CACHE = {}


def get_source(ds):
    dsid = getattr(ds, 'id', ds)
    if dsid not in _SOURCE_CACHE:
        try:
            o = Source.objects.get(year=ds.year, author=ds.author)

# 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/loader/sources.py
import logging
from clldutils.text import split_text
from dplace_app.models import Source

# -*- coding: utf-8 -*-
from __future__ import unicode_literals


_SOURCE_CACHE = {}


def get_source(ds):
    dsid = getattr(ds, 'id', ds)
    if dsid not in _SOURCE_CACHE:
        try:
            o = Source.objects.get(year=ds.year, author=ds.author)

        except Source.DoesNotExist: