Created
March 9, 2015 16:10
-
-
Save ThiefMaster/176b929d8ef3f0902397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from indico.util.console import cformat | |
colors = { | |
'fk': 'yellow!', | |
'pk': 'red!', | |
'ix': 'green!', | |
'ck': 'cyan!', | |
'uq': 'blue!' | |
} | |
def print_stuff(table): | |
t = db.Model.metadata.tables[table] | |
print t.name | |
for c in sorted(t.constraints, key=lambda x: x.name): | |
if c._create_rule and isinstance(c._create_rule.target, db.Boolean): | |
continue | |
color = colors[c.name[:2]] | |
print cformat(' - %%{%s}{}%%{reset}' % color).format(c.name) | |
for idx in sorted(t.indexes, key=lambda x: x.name): | |
color = colors[idx.name[:2]] | |
print cformat(' - %%{%s}{}%%{reset}' % color).format(idx.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment