devtools/devctl.py
branchtls-sprint
changeset 1451 982e8616d9a2
parent 1415 98b8e5c627b8
child 1470 fbdf66a08fbb
--- a/devtools/devctl.py	Thu Apr 23 16:10:17 2009 +0200
+++ b/devtools/devctl.py	Thu Apr 23 16:11:30 2009 +0200
@@ -40,7 +40,7 @@
 
     def my_cubes(self, cube):
         return (cube,) + self.cube_dependencies(cube) + self.cube_recommends(cube)
-    
+
     @property
     def apphome(self):
         return None
@@ -77,7 +77,7 @@
             if mod.__file__.startswith(path):
                 del sys.modules[name]
                 break
-    
+
 def generate_schema_pot(w, cubedir=None):
     """generate a pot file with schema specific i18n messages
 
@@ -101,7 +101,8 @@
     vreg.set_schema(schema)
     w(DEFAULT_POT_HEAD)
     _generate_schema_pot(w, vreg, schema, libschema=libschema, cube=cube)
-                
+
+
 def _generate_schema_pot(w, vreg, schema, libschema=None, cube=None):
     from cubicweb.common.i18n import add_msg
     w('# schema pot file, generated on %s\n' % datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
@@ -147,21 +148,26 @@
     for eschema in schema.entities():
         if eschema.is_final():
             continue
-        for x, rschemas in (('subject', eschema.subject_relations()),
+        for role, rschemas in (('subject', eschema.subject_relations()),
                             ('object', eschema.object_relations())):
             for rschema in rschemas:
                 if rschema.is_final():
                     continue
-                for teschema in rschema.targets(eschema, x):
-                    if defined_in_library(libschema, eschema, rschema, teschema, x):
+                for teschema in rschema.targets(eschema, role):
+                    if defined_in_library(libschema, eschema, rschema,
+                                          teschema, role):
                         continue
-                    if actionbox.relation_mode(rschema.type, teschema.type, x) == 'create':
-                        if x == 'subject':
-                            label = 'add %s %s %s %s' % (eschema, rschema, teschema, x)
-                            label2 = "creating %s (%s %%(linkto)s %s %s)" % (teschema, eschema, rschema, teschema)
+                    if actionbox.relation_mode(rschema, eschema, teschema, role) == 'create':
+                        if role == 'subject':
+                            label = 'add %s %s %s %s' % (eschema, rschema,
+                                                         teschema, role)
+                            label2 = "creating %s (%s %%(linkto)s %s %s)" % (
+                                teschema, eschema, rschema, teschema)
                         else:
-                            label = 'add %s %s %s %s' % (teschema, rschema, eschema, x)
-                            label2 = "creating %s (%s %s %s %%(linkto)s)" % (teschema, teschema, rschema, eschema)
+                            label = 'add %s %s %s %s' % (teschema, rschema,
+                                                         eschema, role)
+                            label2 = "creating %s (%s %s %s %%(linkto)s)" % (
+                                teschema, teschema, rschema, eschema)
                         add_msg(w, label)
                         add_msg(w, label2)
     cube = (cube and 'cubes.%s.' % cube or 'cubicweb.')
@@ -177,12 +183,13 @@
                     add_msg(w, objid)
                     done.add(objid)
 
-                    
-def defined_in_library(libschema, etype, rtype, tetype, x):
-    """return true if the given relation definition exists in cubicweb's library"""
+
+def defined_in_library(libschema, etype, rtype, tetype, role):
+    """return true if the given relation definition exists in cubicweb's library
+    """
     if libschema is None:
         return False
-    if x == 'subject':
+    if role == 'subject':
         subjtype, objtype = etype, tetype
     else:
         subjtype, objtype = tetype, etype
@@ -211,7 +218,7 @@
 
 class UpdateCubicWebCatalogCommand(Command):
     """Update i18n catalogs for cubicweb library.
-    
+
     It will regenerate cubicweb/i18n/xx.po files. You'll have then to edit those
     files to add translations of newly added messages.
     """
@@ -281,7 +288,7 @@
     """
     name = 'i18nupdate'
     arguments = '[<cube>...]'
-    
+
     def run(self, args):
         """run the command with its specific arguments"""
         if args:
@@ -328,7 +335,7 @@
             execute('xgettext --no-location --omit-header -k_ -L java --from-code=utf-8 -o %s %s'
                     % (tmppotfile, ' '.join(jsfiles)))
             # no pot file created if there are no string to translate
-            if exists(tmppotfile): 
+            if exists(tmppotfile):
                 potfiles.append(tmppotfile)
         print '******** create cube specific catalog'
         tmppotfile = join(tempdir, 'generated.pot')
@@ -367,7 +374,7 @@
     name = 'live-server'
     arguments = ''
     options = ()
-    
+
     def run(self, args):
         """run the command with its specific arguments"""
         from cubicweb.devtools.livetest import runserver
@@ -415,7 +422,7 @@
          ),
         )
 
-    
+
     def run(self, args):
         if len(args) != 1:
             raise BadCommandUsage("exactly one argument (cube name) is expected")
@@ -449,7 +456,7 @@
                     distname = 'cubicweb-' + distname
         else:
             distname = 'cubicweb-%s' % cubename.lower()
-        
+
         longdesc = shortdesc = raw_input('Enter a short description for your cube: ')
         if verbose:
             longdesc = raw_input('Enter a long description (or nothing if you want to reuse the short one): ')
@@ -487,7 +494,7 @@
             elif ans == 's':
                 break
         return includes
-    
+
 
 class ExamineLogCommand(Command):
     """Examine a rql log file.
@@ -506,7 +513,7 @@
     name = 'exlog'
     options = (
         )
-    
+
     def run(self, args):
         if args:
             raise BadCommandUsage("no argument expected")
@@ -540,7 +547,7 @@
         print 'Percentage;Cumulative Time;Occurences;Query'
         for time, occ, rql in stat:
             print '%.2f;%.2f;%s;%s' % (time/total_time, time, occ, rql)
-        
+
 register_commands((UpdateCubicWebCatalogCommand,
                    UpdateTemplateCatalogCommand,
                    LiveServerCommand,