devtools/devctl.py
changeset 2527 e60db6312aa0
parent 2458 4d114865098f
child 2528 6ae5d8082b39
equal deleted inserted replaced
2526:40e41eb34a7d 2527:e60db6312aa0
   114     w('# schema pot file, generated on %s\n' % datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
   114     w('# schema pot file, generated on %s\n' % datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
   115     w('# \n')
   115     w('# \n')
   116     w('# singular and plural forms for each entity type\n')
   116     w('# singular and plural forms for each entity type\n')
   117     w('\n')
   117     w('\n')
   118     if libconfig is not None:
   118     if libconfig is not None:
       
   119         print 'lib conf cubes', libconfig.cubes()
   119         libschema = libconfig.load_schema(remove_unused_rtypes=False)
   120         libschema = libconfig.load_schema(remove_unused_rtypes=False)
   120         entities = [e for e in schema.entities() if not e in libschema]
   121         entities = [e for e in schema.entities() if not e in libschema]
   121     else:
   122     else:
   122         entities = schema.entities()
   123         entities = schema.entities()
   123     done = set()
   124     done = set()
   325             cubes = [cubepath for cubepath in cubes if exists(join(cubepath, 'i18n'))]
   326             cubes = [cubepath for cubepath in cubes if exists(join(cubepath, 'i18n'))]
   326         update_cubes_catalogs(cubes)
   327         update_cubes_catalogs(cubes)
   327 
   328 
   328 
   329 
   329 def update_cubes_catalogs(cubes):
   330 def update_cubes_catalogs(cubes):
   330     toedit = []
       
   331     for cubedir in cubes:
   331     for cubedir in cubes:
       
   332         toedit = []
   332         if not isdir(cubedir):
   333         if not isdir(cubedir):
   333             print '-> ignoring %s that is not a directory.' % cubedir
   334             print '-> ignoring %s that is not a directory.' % cubedir
   334             continue
   335             continue
   335         try:
   336         try:
   336             toedit += update_cube_catalogs(cubedir)
   337             toedit += update_cube_catalogs(cubedir)
   337         except Exception:
   338         except Exception:
   338             import traceback
   339             import traceback
   339             traceback.print_exc()
   340             traceback.print_exc()
   340             print '-> Error while updating catalogs for cube', cubedir
   341             print '-> error while updating catalogs for cube', cubedir
   341     # instructions pour la suite
   342         else:
   342     print '-> regenerated this cube\'s .po catalogs.'
   343             # instructions pour la suite
   343     print '\nYou can now edit the following files:'
   344             print '-> regenerated .po catalogs for cube %s.' % cubedir
   344     print '* ' + '\n* '.join(toedit)
   345             print '\nYou can now edit the following files:'
   345     print 'when you are done, run "cubicweb-ctl i18ninstance yourinstance".'
   346             print '* ' + '\n* '.join(toedit)
       
   347             print ('When you are done, run "cubicweb-ctl i18ninstance '
       
   348                    '<yourinstance>" to see changes in your instances.')
   346 
   349 
   347 def update_cube_catalogs(cubedir):
   350 def update_cube_catalogs(cubedir):
   348     import shutil
   351     import shutil
   349     import tempfile
   352     import tempfile
   350     from logilab.common.fileutils import ensure_fs_mode
   353     from logilab.common.fileutils import ensure_fs_mode