# encoding: utf-8
from __future__ import print_function, division, absolute_import
import os
from .bunch import Bunch
"""
# Some principles:
- We implement "duplicate" classes for domain objects (which eg are created by parsing yaml files)
and dbo objects from sqlalchemy, because sqlalchemy objects sometimes do some confusing "magic".
Althouth this can be circumvented the resulting fixes makes code hard to understand and dangerous
to modify if someone is not aware of this "magic".
- We try to keep the domain objects and dbo objects as slick as possible.
"""
class RelPathMixin:
def set_rel_path(self, rel_path):
self._rel_path = rel_path
@property
def file_name(self):
if self._rel_path is not None:
return os.path.basename(self._rel_path)
@property
def rel_path(self):
return self._rel_path
class BunchBasedDomainObject(Bunch, RelPathMixin):
def __init__(self, bunch, rel_path=None):
super().__init__(bunch)
self.set_rel_path(rel_path)
class Site(BunchBasedDomainObject):
pass
class Signal(Bunch):
pass
class Picture(Bunch):
pass
class Parameter(Bunch):
pass
class Parameters(RelPathMixin):
def __init__(self, parameters, rel_path):
self.parameters = parameters
self.set_rel_path(rel_path)
def __str__(self):
return str(self.Parameters)
def __repr__(self):
return repr(self.Parameters)
def __iter__(self):
return iter(self.parameters)
class ParameterAveraging(BunchBasedDomainObject):
pass
class Source(BunchBasedDomainObject):
pass
class SourceType(BunchBasedDomainObject):
pass
class SpecialValueDefinition(BunchBasedDomainObject):
pass
class SignalQuality(BunchBasedDomainObject):
pass
class Quality(BunchBasedDomainObject):
pass
class Comment(BunchBasedDomainObject):
pass
|