# Path: languk/corpus/mongodb.py
# def with_reconnect(func):
#     def _reconnector(*args, **kwargs):
#     def __init__(self, collection):
#     def __getattr__(self, func):
#     def __repr__(self):
#     def __str__(self):
#     def __init__(self, database):
#     def __getattr__(self, func):
#     def __getitem__(self, func):
#     def __repr__(self):
#     def __str__(self):
#     def __init__(self, connection, default=None):
#     def __getattr__(self, alias):
#     def __repr__(self):
#     def __str__(self):
#     def __init__(self, databases):
#     def __getitem__(self, alias):
# def get_db():
# class ConnectionDoesNotExist(Exception):
# class CollectionWrapper(object):
# class DatabaseWrapper(object):
# class ConnectionWrapper(object):
# class MongoHandler(object):


from collections import defaultdict
from typing import Tuple
from django import forms
from django.core import exceptions
from django.db import models
from django.contrib.postgres.fields import ArrayField
from django.conf import settings
from django_task.models import TaskRQ
from .mongodb import db
        from .jobs import ExportCorpusJob
        from .jobs import TagWithUDPipeJob
        from .jobs import BuildFreqVocabJob
                return
            raise exceptions.ValidationError(
                self.error_messages["invalid_choice"],
                code="invalid_choice",
                params={"value": value},
            )

        if value is None and not self.null:
            raise exceptions.ValidationError(self.error_messages["null"], code="null")

        if not self.blank and value in self.empty_values:
            raise exceptions.ValidationError(self.error_messages["blank"], code="blank")


class Corpus:
    @staticmethod
    def get_sources():
        grouped = defaultdict(list)

        for source in db.corpus__sources.find():
            try:
                grouped[source["collection"]].append(source)
            except KeyError:
                pass

        return grouped

    @staticmethod
    def get_source(collection, _id):


# Path: languk/corpus/mongodb.py
# def with_reconnect(func):
#     def _reconnector(*args, **kwargs):
#     def __init__(self, collection):
#     def __getattr__(self, func):
#     def __repr__(self):
#     def __str__(self):
#     def __init__(self, database):
#     def __getattr__(self, func):
#     def __getitem__(self, func):
#     def __repr__(self):
#     def __str__(self):
#     def __init__(self, connection, default=None):
#     def __getattr__(self, alias):
#     def __repr__(self):
#     def __str__(self):
#     def __init__(self, databases):
#     def __getitem__(self, alias):
# def get_db():
# class ConnectionDoesNotExist(Exception):
# class CollectionWrapper(object):
# class DatabaseWrapper(object):
# class ConnectionWrapper(object):
# class MongoHandler(object):


# Path: languk/corpus/models.py
from collections import defaultdict
from typing import Tuple
from django import forms
from django.core import exceptions
from django.db import models
from django.contrib.postgres.fields import ArrayField
from django.conf import settings
from django_task.models import TaskRQ
from .mongodb import db
        from .jobs import ExportCorpusJob
        from .jobs import TagWithUDPipeJob
        from .jobs import BuildFreqVocabJob

                return
            raise exceptions.ValidationError(
                self.error_messages["invalid_choice"],
                code="invalid_choice",
                params={"value": value},
            )

        if value is None and not self.null:
            raise exceptions.ValidationError(self.error_messages["null"], code="null")

        if not self.blank and value in self.empty_values:
            raise exceptions.ValidationError(self.error_messages["blank"], code="blank")


class Corpus:
    @staticmethod
    def get_sources():
        grouped = defaultdict(list)

        for source in db.corpus__sources.find():
            try:
                grouped[source["collection"]].append(source)
            except KeyError:
                pass

        return grouped

    @staticmethod
    def get_source(collection, _id):


        return db.corpus__sources.find_one({"collection": collection, "_id": _id})