goa/tools/generate_schema_img.py
changeset 6366 1806148d6ce8
parent 6333 e3994fcc21c3
parent 6365 a15cc5e16178
child 6367 d4c485ec1ca1
equal deleted inserted replaced
6333:e3994fcc21c3 6366:1806148d6ce8
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of CubicWeb.
       
     5 #
       
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 """
       
    19 
       
    20 """
       
    21 import sys
       
    22 from os.path import dirname, abspath, join
       
    23 from yams import schema2dot
       
    24 from cubicweb.web.views.schema import SKIP_TYPES
       
    25 
       
    26 APPLROOT = abspath(join(dirname(abspath(__file__)), '..'))
       
    27 
       
    28 try:
       
    29     import custom
       
    30 except ImportError:
       
    31     sys.path.insert(0, APPLROOT)
       
    32     import custom
       
    33 
       
    34 
       
    35 schema = custom.SCHEMA
       
    36 skip_rels = ('owned_by', 'created_by', 'identity', 'is', 'is_instance_of')
       
    37 path = join(APPLROOT, 'data', 'schema.png')
       
    38 schema2dot.schema2dot(schema, path, #size=size,
       
    39                       skiptypes=SKIP_TYPES)
       
    40 print 'generated', path
       
    41 path = join(APPLROOT, 'data', 'metaschema.png')
       
    42 schema2dot.schema2dot(schema, path)
       
    43 print 'generated', path