Exemple #1
0
    def create(cls, name, dynamic=0, **kwargs):
        file = codecs.open(
            os.path.join(
                cls.path, 'patterns', '%s.json' % name
            ), 'w+', Default.encoding
        )

        pattern = PatternModel(dynamic=dynamic)
        if dynamic:
            pattern.add(
                PatternModel(kwargs.get('itemskind') or 'dict'), '$items'
            )

        file.write(cls.encoder(pattern.getDict()))
        file.close()
        for dir in ('balance',):
            os.mkdir(
                os.path.join(cls.path, dir, name)
            )
        cls.model = Model
        cls.load_content(cls.path)
        cls.table[ name ] = Table(
            core=cls, name=name, template=pattern.getDict()
        )
        cls.table[ name ].__pinit__()
Exemple #2
0
    def __generate__(self, kind, **kwargs):
        pattern = PatternModel(kind, **kwargs)

        if kind == 'list' or \
        kind == 'dict' and kwargs.get('dynamic'):
            pattern.add(PatternModel(kwargs.get('itemskind') or 'dict'), '$items')

        return pattern.getDict()