Ignore:
Timestamp:
Apr 19, 2011 9:06:50 AM (13 years ago)
Author:
vmaksymiv
Message:

pep8 fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.catalogupdater/trunk/quintagroup/catalogupdater/utility.py

    r1981 r3142  
    1 import logging, types 
     1import logging 
     2import types 
    23import transaction 
    34from zope.interface import implements 
     
    67 
    78from Missing import MV 
    8 from Acquisition import aq_inner 
    99from Acquisition import aq_parent 
    1010 
     
    1818        as _old_IIndexableObjectWrapper 
    1919    IS_NEW = False 
    20 else:     
     20else: 
    2121    IS_NEW = True 
    2222 
     
    3333    def validate(self, cat, cols): 
    3434        # Validate catalog and column name 
    35         AVAIL_COLTYPES = list(types.StringTypes) + [types.ListType, types.TupleType] 
     35        AVAIL_COLTYPES = list(types.StringTypes) + [types.ListType, 
     36                                                    types.TupleType] 
    3637 
    3738        _cat = getattr(cat, '_catalog', None) 
     
    4041 
    4142        if not type(cols) in AVAIL_COLTYPES: 
    42             raise TypeError("'columns' parameter must be one of the following " \ 
    43                 "types: %s" % AVAIL_COLTYPES) 
     43            raise TypeError("'columns' parameter must be one of the " \ 
     44                "following types: %s" % AVAIL_COLTYPES) 
    4445        # Normalize columns 
    4546        if type(cols) in types.StringTypes: 
    46             cols = [cols,] 
     47            cols = [cols, ] 
    4748        # Check is every column present in the catalog 
    4849        for col in cols: 
    49             if not _cat.schema.has_key(col): 
    50                 raise AttributeError("'%s' - not presented column in %s catalog " % (col, cat)) 
     50            if not col in _cat.schema: 
     51                raise AttributeError("'%s' - not presented column in " \ 
     52                                     "%s catalog " % (col, cat)) 
    5153 
    5254        return _cat, cols 
    53  
    5455 
    5556    def getWrappedObjectNew(self, obj, portal, catalog): 
     
    5758        wrapper = None 
    5859        if not IIndexableObject.providedBy(obj): 
    59              # This is the CMF 2.2 compatible approach, which should be used going forward 
    60              wrapper = queryMultiAdapter((obj, catalog), IIndexableObject) 
     60            # This is the CMF 2.2 compatible approach, 
     61            # which should be used going forward 
     62            wrapper = queryMultiAdapter((obj, catalog), IIndexableObject) 
    6163        return wrapper and wrapper or obj 
    6264 
     
    7274        else: 
    7375            vars = {} 
    74          
     76 
    7577        w = getMultiAdapter((obj, portal), _old_IIndexableObjectWrapper) 
    7678        w.update(vars) 
    7779 
    7880        return w 
    79  
    8081 
    8182    def updateMetadata4All(self, catalog, columns): 
     
    8788        portal = getToolByName(catalog, 'portal_url').getPortalObject() 
    8889        root = aq_parent(portal) 
    89          
     90 
    9091        data = _catalog.data 
    9192        schema = _catalog.schema 
    9293        paths = _catalog.paths 
    93         getWrappedObject = IS_NEW and self.getWrappedObjectNew or self.getWrappedObjectOld 
     94        getWrappedObject = (IS_NEW and self.getWrappedObjectNew 
     95                                    or self.getWrappedObjectOld) 
    9496        # For subtransaction support 
    9597        threshold = getattr(catalog, 'threshold', 10000) 
     
    112114            for column in columns: 
    113115                # calculate the column value 
    114                 attr=getattr(obj, column, MV) 
    115                 if(attr is not MV and safe_callable(attr)): attr=attr() 
     116                attr = getattr(obj, column, MV) 
     117                if (attr is not MV and safe_callable(attr)): 
     118                    attr = attr() 
    116119                # Update metadata value 
    117120                indx = schema[column] 
     
    134137                    _v_total = 0 
    135138                    LOG.info('commiting subtransaction') 
    136  
Note: See TracChangeset for help on using the changeset viewer.