Exemple #1
0
    def _sort(self, objects, depsfn=None):
        g = {}

        for obj in objects:
            this_item = g[obj.name] = {'item': obj, 'merge': [], 'deps': []}

            if depsfn is not None:
                deps = depsfn(obj)
                for dep in deps:
                    this_item['deps'].append(dep.name)
                    g[dep.name] = {'item': dep, 'merge': [], 'deps': []}

            if obj.bases:
                g[obj.name]['deps'].extend(b.name for b in obj.bases)

                for base in obj.bases:
                    if base.name.module != obj.name.module:
                        g[base.name] = {'item': base, 'merge': [], 'deps': []}

        if not g:
            return ordered.OrderedSet()

        item = next(iter(g.values()))['item']
        modname = item.name.module
        objs = topological.sort(g)
        return ordered.OrderedSet(
            filter(lambda obj: obj.name.module == modname, objs))
Exemple #2
0
    def sort_subcommands_by_type(self):
        def _key(c):
            if isinstance(c, CreateObject):
                return 0
            else:
                return 2

        self.ops = ordered.OrderedSet(sorted(self.ops, key=_key))
Exemple #3
0
    def iter_columns(self, writable_only=False, only_self=False):
        cols = collections.OrderedDict()
        cols.update((c.name, c) for c in self._columns
                    if not writable_only or not c.readonly)

        if not only_self:
            for c in reversed(self.bases):
                cols.update((name, bc) for name, bc in c.columns.items()
                            if not writable_only or not bc.readonly)

        return ordered.OrderedSet(cols.values())
Exemple #4
0
    def __init__(self,
                 name,
                 table_name,
                 unique=True,
                 expr=None,
                 predicate=None,
                 inherit=False,
                 metadata=None,
                 columns=None):
        super().__init__(inherit=inherit, metadata=metadata)

        assert table_name[1] != 'feature'

        self.name = name
        self.table_name = table_name
        self._columns = ordered.OrderedSet()
        if columns:
            self.add_columns(columns)
        self.predicate = predicate
        self.unique = unique
        self.expr = expr

        if self.name_in_catalog != self.name:
            self.add_metadata('fullname', self.name)
Exemple #5
0
 def copy(self):
     result = super().copy()
     result.ops = ordered.OrderedSet(op.copy() for op in self.ops)
     result.before_ops = ordered.OrderedSet(op.copy()
                                            for op in self.before_ops)
     return result
Exemple #6
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.ops = ordered.OrderedSet()
     self.before_ops = ordered.OrderedSet()
Exemple #7
0
 def __init__(self, deltas):
     self.deltas = ordered.OrderedSet(deltas)
Exemple #8
0
 def __init__(self, name, columns=None):
     super().__init__()
     self.name = name
     self._columns = ordered.OrderedSet()
     self.add_columns(columns or [])
Exemple #9
0
 def __init__(self, name, *, columns=None, bases=None, constraints=None):
     self.constraints = ordered.OrderedSet(constraints or [])
     self.bases = ordered.OrderedSet(bases or [])
     self.data = []
     super().__init__(name, columns=columns)