Show
Ignore:
Timestamp:
09/27/08 22:02:37 (16 years ago)
Author:
jerome
Message:

Removed unnecessary spaces at EOL.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/mysqlstorage.py

    r3411 r3413  
    88# the Free Software Foundation, either version 3 of the License, or 
    99# (at your option) any later version. 
    10 #  
     10# 
    1111# This program is distributed in the hope that it will be useful, 
    1212# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414# GNU General Public License for more details. 
    15 #  
     15# 
    1616# You should have received a copy of the GNU General Public License 
    1717# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    2929try : 
    3030    import MySQLdb 
    31 except ImportError :     
     31except ImportError : 
    3232    import sys 
    3333    # TODO : to translate or not to translate ? 
     
    4141            (host, port) = host.split(":") 
    4242            port = int(port) 
    43         except ValueError :     
     43        except ValueError : 
    4444            port = 3306           # Use the default MySQL port 
    45          
     45 
    4646        self.tool.logdebug("Trying to open database (host=%s, port=%s, dbname=%s, user=%s)..." % (host, port, dbname, user)) 
    4747        try : 
    4848            self.database = MySQLdb.connect(host=host, port=port, db=dbname, user=user, passwd=passwd, charset="utf8") 
    49         except TypeError :     
     49        except TypeError : 
    5050            self.tool.logdebug("'charset' argument not allowed with this version of python-mysqldb, retrying without...") 
    5151            self.database = MySQLdb.connect(host=host, port=port, db=dbname, user=user, passwd=passwd) 
    52              
     52 
    5353        try : 
    5454            self.database.autocommit(1) 
    55         except AttributeError :     
     55        except AttributeError : 
    5656            raise PyKotaStorageError, _("Your version of python-mysqldb is too old. Please install a newer release.") 
    5757        self.cursor = self.database.cursor() 
     
    6262        try : 
    6363            # Here we try to select a string (an &eacute;) which is 
    64             # already encoded in UTF-8. If python-mysqldb suffers from  
     64            # already encoded in UTF-8. If python-mysqldb suffers from 
    6565            # the double encoding problem, we will catch the exception 
    6666            # and activate a workaround. 
    6767            self.cursor.execute("SELECT '%s';" % (chr(0xc3) + chr(0xa9))) # &eacute; in UTF-8 
    6868            self.cursor.fetchall() 
    69         except UnicodeDecodeError :     
     69        except UnicodeDecodeError : 
    7070            self.needsworkaround = True 
    7171            self.tool.logdebug("Database needs encoding workaround.") 
     
    7373            self.needsworkaround = False 
    7474            self.tool.logdebug("Database doesn't need encoding workaround.") 
    75              
    76     def close(self) :     
     75 
     76    def close(self) : 
    7777        """Closes the database connection.""" 
    7878        if not self.closed : 
     
    8181            self.closed = True 
    8282            self.tool.logdebug("Database closed.") 
    83          
    84     def beginTransaction(self) :     
     83 
     84    def beginTransaction(self) : 
    8585        """Starts a transaction.""" 
    8686        self.cursor.execute("BEGIN;") 
    8787        self.tool.logdebug("Transaction begins...") 
    88          
    89     def commitTransaction(self) :     
     88 
     89    def commitTransaction(self) : 
    9090        """Commits a transaction.""" 
    9191        self.database.commit() 
    9292        self.tool.logdebug("Transaction committed.") 
    93          
    94     def rollbackTransaction(self) :      
     93 
     94    def rollbackTransaction(self) : 
    9595        """Rollbacks a transaction.""" 
    9696        self.database.rollback() 
    9797        self.tool.logdebug("Transaction aborted.") 
    98          
     98 
    9999    def doRawSearch(self, query) : 
    100100        """Does a raw search query.""" 
    101         query = query.strip()     
    102         if not query.endswith(';') :     
     101        query = query.strip() 
     102        if not query.endswith(';') : 
    103103            query += ';' 
    104104        self.querydebug("QUERY : %s" % query) 
    105         if self.needsworkaround :     
     105        if self.needsworkaround : 
    106106            query = query.decode("UTF-8") 
    107107        try : 
    108108            self.cursor.execute(query) 
    109         except self.database.Error, msg :     
     109        except self.database.Error, msg : 
    110110            raise PyKotaStorageError, repr(msg) 
    111         else :     
     111        else : 
    112112            # This returns a list of lists. Integers are returned as longs. 
    113113            return self.cursor.fetchall() 
    114              
    115     def doSearch(self, query) :         
     114 
     115    def doSearch(self, query) : 
    116116        """Does a search query.""" 
    117117        result = self.doRawSearch(query) 
     
    131131    def doModify(self, query) : 
    132132        """Does a (possibly multiple) modify query.""" 
    133         query = query.strip()     
    134         if not query.endswith(';') :     
     133        query = query.strip() 
     134        if not query.endswith(';') : 
    135135            query += ';' 
    136136        self.querydebug("QUERY : %s" % query) 
    137         if self.needsworkaround :     
     137        if self.needsworkaround : 
    138138            query = query.decode("UTF-8") 
    139139        try : 
    140140            self.cursor.execute(query) 
    141         except self.database.Error, msg :     
     141        except self.database.Error, msg : 
    142142            self.tool.logdebug("Query failed : %s" % repr(msg)) 
    143143            raise PyKotaStorageError, repr(msg) 
    144              
     144 
    145145    def doQuote(self, field) : 
    146146        """Quotes a field for use as a string in SQL queries."""