__init__.py 916 Bytes
Newer Older
Nic's avatar
Nic committed
1
2
3
4
5
6
7
8
9
# -*- coding: utf-8 -*-

"""Top-level package for GridSource."""

from gridsource.io import IOMixin
from gridsource.validation import ValidatorMixin

__author__ = """Nicolas Cordier"""
__email__ = "nicolas.cordier@numeric-gmbh.ch"
Nic's avatar
Nic committed
10
__version__ = "0.37.0"
Nic's avatar
Nic committed
11
12
13
14
15
16
17
18
19
20


class _Base:
    def __init__(self):
        self._data = {}
        possible_mixins_init = ("validator_mixin_init", "io_mixin_init")
        for f in possible_mixins_init:
            if hasattr(self, f):
                getattr(self, f)()

21
22
23
24
25
26
27
    def get(self, tabname=None, attr="_data"):
        if not attr.startswith("_"):
            attr = "_" + attr
        if not tabname:
            raise AttributeError(f"`tabname` should be one of {set(self._data.keys())}")
        return getattr(self, attr)[tabname]

Nic's avatar
Nic committed
28
29
30
31
32
33
34
35
36
37
38

class Data(_Base, IOMixin, ValidatorMixin):
    pass


class ValidData(_Base, ValidatorMixin):
    pass


class IOData(_Base, IOMixin):
    pass