def do_edit(self, args):
        """Edit a command with $EDITOR."""
        if 'EDITOR' not in os.environ:
            print('*** $EDITOR not set')
        else:
            path = os.path.join(utils.CONFIG_DIR, 'sql')
            cmd = os.environ['EDITOR']
            try:
                os.system(cmd + ' ' + path)
                if os.path.exists(path):
                    with open(path, 'r') as f:
                        sql = f.read()
                        if sql:
                            self.default(sql)
            finally:
                if os.path.exists(path):
                    os.remove(path)
def do_edit ( self , args ) : if 'EDITOR' not in os . environ : print ( '*** $EDITOR not set' ) else : path = os . path . join ( utils . CONFIG_DIR , 'sql' ) cmd = os . environ [ 'EDITOR' ] try : os . system ( cmd + ' ' + path ) if os . path . exists ( path ) : with open ( path , 'r' ) as f : sql = f . read ( ) if sql : self . default ( sql ) finally : if os . path . exists ( path ) : os . remove ( path )
Edit a command with $EDITOR.