misc/cmp_schema.py
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 08 Jan 2014 14:00:31 +0100
changeset 9377 4e0d8f06efbc
parent 5372 b74eed7e8b37
permissions -rw-r--r--
[js/widgets] fix the InOut widget with modern jQuery versions Several things are done there: * reduction in size and complexity of the code * the unused defaultsettings are removed * the initial `unlinked` list is now correctly populated from python-side * the unit test is adjusted because it tested an irrelevant implementation detail which is no longer true (but the widget of course still handles correctly the linkto information) Tested with ie7, ie9, chromium, firefox. Tested with jQuery 1.6 (cw 3.17.x) and 1.10. Closes #3154531.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5372
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     1
"""This module compare the Schema on the file system to the one in the database"""
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     2
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     3
from cStringIO import StringIO
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     4
from cubicweb.web.schemaviewer import SchemaViewer
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     5
from logilab.common.ureports import TextWriter
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     6
import difflib
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     7
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     8
viewer = SchemaViewer()
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
     9
layout_db = viewer.visit_schema(schema, display_relations=True)
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    10
layout_fs = viewer.visit_schema(fsschema, display_relations=True)
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    11
writer = TextWriter()
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    12
stream_db = StringIO()
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    13
stream_fs = StringIO()
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    14
writer.format(layout_db, stream=stream_db)
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    15
writer.format(layout_fs, stream=stream_fs)
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    16
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    17
stream_db.seek(0)
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    18
stream_fs.seek(0)
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    19
db = stream_db.getvalue().splitlines()
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    20
fs = stream_fs.getvalue().splitlines()
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    21
open('db_schema.txt', 'w').write(stream_db.getvalue())
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    22
open('fs_schema.txt', 'w').write(stream_fs.getvalue())
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    23
#for diff in difflib.ndiff(fs, db):
b74eed7e8b37 Add a basic script to compare the db_schema to the fs_schema.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
    24
#    print diff