Skip to content

Commit

Permalink
When restricting dbtoyaml to schemas/tables, don't exclude non-schema…
Browse files Browse the repository at this point in the history
… objects.
  • Loading branch information
jmafc committed Dec 14, 2011
1 parent 5f51dae commit f03810b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pyrseas/dbtoyaml.py
Expand Up @@ -42,16 +42,17 @@ def main(host='localhost', port=5432, schema=None):
if options.schema:
skey = 'schema ' + options.schema
for sch in dbmap.keys():
if sch != skey:
if sch[:7] == 'schema ' and sch != skey:
del dbmap[sch]
if options.tablist:
ktablist = ['table ' + tbl for tbl in options.tablist]
for sch in dbmap.keys():
for tbl in dbmap[sch].keys():
if tbl not in ktablist:
del dbmap[sch][tbl]
if not dbmap[sch]:
del dbmap[sch]
if sch[:7] == 'schema ':
for tbl in dbmap[sch].keys():
if tbl not in ktablist:
del dbmap[sch][tbl]
if not dbmap[sch]:
del dbmap[sch]

print yaml.dump(dbmap, default_flow_style=False)

Expand Down

0 comments on commit f03810b

Please sign in to comment.