equal
deleted
inserted
replaced
1 """This module compare the Schema on the file system to the one in the database""" |
|
2 |
|
3 from cStringIO import StringIO |
|
4 from cubicweb.web.schemaviewer import SchemaViewer |
|
5 from logilab.common.ureports import TextWriter |
|
6 import difflib |
|
7 |
|
8 viewer = SchemaViewer() |
|
9 layout_db = viewer.visit_schema(schema, display_relations=True) |
|
10 layout_fs = viewer.visit_schema(fsschema, display_relations=True) |
|
11 writer = TextWriter() |
|
12 stream_db = StringIO() |
|
13 stream_fs = StringIO() |
|
14 writer.format(layout_db, stream=stream_db) |
|
15 writer.format(layout_fs, stream=stream_fs) |
|
16 |
|
17 stream_db.seek(0) |
|
18 stream_fs.seek(0) |
|
19 db = stream_db.getvalue().splitlines() |
|
20 fs = stream_fs.getvalue().splitlines() |
|
21 open('db_schema.txt', 'w').write(stream_db.getvalue()) |
|
22 open('fs_schema.txt', 'w').write(stream_fs.getvalue()) |
|
23 #for diff in difflib.ndiff(fs, db): |
|
24 # print diff |
|