# -*- coding: utf-8 -*-

$WARNING

$IMPORTS

from fdi.dataset.readonlydict import ReadOnlyDict

import itertools

import logging
# create logger
logger = logging.getLogger(__name__)
# logger.debug('level %d' %  (logger.getEffectiveLevel()))


class $MODELNAME($PARENTS):
    """ $CLASSDOC

    Generally a Product (inheriting BaseProduct) has project-wide attributes and can be extended to define a plethora of specialized products.
    """


    def __init__(self,
$INITARGS
                 zInfo=None,
                 **kwds):
        """ Initializes instances with more metadata as attributes, set to default values.

        Put description keyword argument here to allow e.g. BaseProduct("foo") and description='foo'
        """

        # collect MDPs from args-turned-local-variables.
        metasToBeInstalled = OrderedDict(
            itertools.filterfalse(
                lambda x: x[0] in ('self', '__class__', 'zInfo', 'kwds'),
                locals().items())
        )

        global Model
        if zInfo is None:
            zInfo = Model

        # print('@1 zInfo', id(self.zInfo['metadata']), id(self), id(self.zInfo),
        #      self.zInfo['metadata']['version'], list(metasToBeInstalled.keys()))

        # must be the first line to initiate meta
        super().__init__(zInfo=zInfo, **metasToBeInstalled, **kwds)

        #print(self.meta.keySet(), id(self.meta))

$PROPERTIES

# Data Model specification for mandatory components
$MODELSPEC

Model = ReadOnlyDict(_Model_Spec)

MdpInfo = Model['metadata']

