def __str__(self): # We overwrite the base class' method to fix the order of columns. tg = TableGroup.fromvalue(self.MD) for col in sorted( self.column_labels, key=lambda t: (t == IPA_COLUMN, t.lower()), reverse=True): if col != self.GRAPHEME_COL: tg.tables[0].tableSchema.columns.append( Column.fromvalue({"name": col, "null": self.NULL})) return tg.tables[0].write(self.iteritems(), fname=None).decode('utf8').strip()
def _make_tg(tmpdir, *tables): tg = TableGroup.fromvalue({'tables': list(tables)}) tg._fname = Path(str(tmpdir / 'md.json')) # FIXME: clldutils dependency return tg