hercule.py
branchtls-sprint
changeset 1802 d628defebc17
parent 1141 66d532e62dd8
child 1977 606923dff11b
--- a/hercule.py	Thu May 14 10:24:56 2009 +0200
+++ b/hercule.py	Thu May 14 11:38:40 2009 +0200
@@ -13,11 +13,11 @@
 from logilab.common.cli import CLIHelper
 from logilab.common.clcommands import BadCommandUsage, pop_arg, register_commands
 from cubicweb.toolsutils import CONNECT_OPTIONS, Command
- 
+
 # result formatter ############################################################
 
 PAGER = os.environ.get('PAGER', 'less')
-            
+
 def pager_format_results(writer, layout):
     """pipe results to a pager like more or less"""
     (r, w) = os.pipe()
@@ -42,8 +42,8 @@
 def izip2(list1, list2):
     for i in xrange(len(list1)):
         yield list1[i] + tuple(list2[i])
-        
-def format_results(writer, layout, stream=sys.stdout): 
+
+def format_results(writer, layout, stream=sys.stdout):
     """format result as text into the given file like object"""
     writer.format(layout, stream)
 
@@ -60,7 +60,7 @@
     return str(value)
 
 # command line querier ########################################################
-    
+
 class RQLCli(CLIHelper):
     """Interactive command line client for CubicWeb, allowing user to execute
     arbitrary RQL queries and to fetch schema information
@@ -74,10 +74,10 @@
         'description'  : "CubicWeb",
         'commit' :       "CubicWeb",
         'rollback' :     "CubicWeb",
-        'autocommit'  :  "Others", 
+        'autocommit'  :  "Others",
         'debug' :        "Others",
         })
-    
+
     def __init__(self, application=None, user=None, password=None,
                  host=None, debug=0):
         CLIHelper.__init__(self, os.path.join(os.environ["HOME"], ".erqlhist"))
@@ -94,7 +94,7 @@
         if application is not None:
             self.do_connect(application, user, password, host)
         self.do_debug(debug)
-        
+
     def do_connect(self, application, user=None, password=None, host=None):
         """connect to an cubicweb application"""
         from cubicweb.dbapi import connect
@@ -113,7 +113,7 @@
         self._completer.list = (self.commands.keys() +
                                 self.schema.entities() + ['Any'])
         print _('You are now connected to %s') % application
-        
+
 
     help_do_connect = ('connect', "connect <application> [<user> [<password> [<host>]]]",
                        _(do_connect.__doc__))
@@ -127,9 +127,9 @@
             self._format = pager_format_results
         if self._debug:
             print _('Debug level set to %s'%debug)
-        
+
     help_do_debug = ('debug', "debug [debug_level]", _(do_debug.__doc__))
-    
+
     def do_description(self):
         """display the description of the latest result"""
         if self.rset.description is None:
@@ -139,7 +139,7 @@
                              for line_desc in self.rset.description])
 
     help_do_description = ('description', "description", _(do_description.__doc__))
-    
+
     def do_schema(self, name=None):
         """display information about the application schema """
         if self.cnx is None:
@@ -159,28 +159,28 @@
                 done = 1
         if done is None:
             print _('Unable to find anything named "%s" in the schema !') % name
-            
+
     help_do_schema = ('schema', "schema [keyword]", _(do_schema.__doc__))
 
-    
+
     def do_commit(self):
         """commit the current transaction"""
         self.cnx.commit()
 
     help_do_commit = ('commit', "commit", _(do_commit.__doc__))
-    
+
     def do_rollback(self):
         """rollback the current transaction"""
         self.cnx.rollback()
 
     help_do_rollback = ('rollback', "rollback", _(do_rollback.__doc__))
-    
+
     def do_autocommit(self):
         """toggle autocommit mode"""
         self.autocommit = not self.autocommit
 
     help_do_autocommit = ('autocommit', "autocommit", _(do_autocommit.__doc__))
-    
+
 
     def handle_line(self, stripped_line):
         """handle non command line :
@@ -232,7 +232,7 @@
     """A command line querier for CubicWeb, using the Relation Query Language.
 
     <application>
-      identifier of the application to connect to 
+      identifier of the application to connect to
     """
     name = 'client'
     arguments = '<application>'
@@ -247,7 +247,7 @@
           'help': 'file containing a batch of RQL statements to execute.',
           }),
         )
-    
+
     def run(self, args):
         """run the command with its specific arguments"""
         appid = pop_arg(args, expected_size_after=None)
@@ -271,5 +271,5 @@
                 cli.handle_line(line)
         else:
             cli.run()
-        
+
 register_commands((CubicWebClientCommand,))