Changeset 3514 in products


Ignore:
Timestamp:
Aug 22, 2012 12:40:59 PM (12 years ago)
Author:
kroman0
Message:

Pep8 fixes

Location:
quintagroup.dropdownmenu/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/controlpanel.py

    r3511 r3514  
    5050                label = translate(term.title, context=widget.request, 
    5151                                  default=term.title) 
    52             widget.items.append({'id': id, 'name': widget.name + ':list', 
     52            widget.items.append({ 
     53                'id': id, 'name': widget.name + ':list', 
    5354                'value': term.token, 'label': label, 'checked': checked}) 
    5455 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py

    r3491 r3514  
    4343    # typically purges entries after 60 minutes. 
    4444    return view.__name__ + \ 
    45            path_key + \ 
    46            language + \ 
    47            str(time() // (60 * 5)) 
     45        path_key + \ 
     46        language + \ 
     47        str(time() // (60 * 5)) 
    4848 
    4949 
     
    5757    def func(view): 
    5858        portal_state = getMultiAdapter((view.context, view.request), 
    59                                         name=u'plone_portal_state') 
     59                                       name=u'plone_portal_state') 
    6060        # it is impossible to reliably cache entire rendered menu generated 
    6161        # with potral actions strategy. 
    6262        if not view.conf.enable_caching or view.conf.show_actions_tabs or \ 
    63            (not portal_state.anonymous() and \ 
     63            (not portal_state.anonymous() and 
    6464                view.conf.caching_strategy == 'anonymous'): 
    6565            return f(view) 
     
    9191        self.site_url = getToolByName(context, 'portal_url')() 
    9292        self.context_state = getMultiAdapter((self.context, self.request), 
    93                                               name="plone_context_state") 
     93                                             name="plone_context_state") 
    9494        self.context_url = self.context_state.is_default_page() and \ 
    9595            '/'.join(self.context.absolute_url().split('/')[:-1]) or \ 
     
    120120        conf = self.conf 
    121121        tool = self.tool 
     122        url = self.context_url 
     123        starts = url.startswith 
    122124 
    123125        # check if we have required root actions category inside tool 
     
    136138        delta = 1000 
    137139        for info in listtabs: 
    138             if  self.context_url.startswith(info['url']) and \ 
    139                 len(self.context_url) - len(info['url']) < delta: 
     140            if starts(info['url']) and len(url) - len(info['url']) < delta: 
    140141                delta = len(self.context_url) - len(info['url']) 
    141142                current_item = listtabs.index(info) 
    142143        self.id_chain = [] 
    143144 
    144         if current_item > -1 and current_item < len(listtabs) and \ 
    145             (listtabs[current_item]['url'] != self.site_url or \ 
    146             listtabs[current_item]['url'] == self.site_url and \ 
    147             self.context_url == self.site_url): 
    148  
     145        active = listtabs[current_item]['url'] == self.site_url 
     146        active = active and self.context_url == self.site_url 
     147        active = listtabs[current_item]['url'] != self.site_url or active 
     148        if  current_item > -1 and current_item < len(listtabs) and active: 
    149149            self.mark_active(listtabs[current_item]['id'], 
    150150                             listtabs[current_item]['url']) 
    151  
    152151        self._activate(res) 
    153152        return res 
     
    165164                    # try to find out appropriate subcategory 
    166165                    subcat_id = self.cat_prefix + info['id'] + self.cat_sufix 
    167                     if subcat_id != info['id'] and \ 
    168                        subcat_id in category.objectIds(): 
     166                    in_category = subcat_id in category.objectIds() 
     167                    if subcat_id != info['id'] and in_category: 
    169168                        subcat = category._getOb(subcat_id) 
    170169                        if IActionCategory.providedBy(subcat): 
     
    173172                                                         info['url']) 
    174173 
    175                 parent_id = category.getId().replace(self.cat_prefix, 
    176                                 '').replace(self.cat_sufix, '') 
     174                parent_id = category.getId() 
     175                parent_id = parent_id.replace(self.cat_prefix, '') 
     176                parent_id = parent_id.replace(self.cat_sufix, '') 
    177177                tab = {'id': info['id'], 
    178                    'title': info['title'], 
    179                    'url': info['url'], 
    180                    'parent': (parent_id, parent_url)} 
     178                       'title': info['title'], 
     179                       'url': info['url'], 
     180                       'parent': (parent_id, parent_url)} 
    181181                tabslist.append(tab) 
    182182 
     
    218218        ec = self.tool._getExprContext(object) 
    219219        actions = [ActionInfo(action, ec) for action in category.objectValues() 
    220                     if IAction.providedBy(action)] 
     220                   if IAction.providedBy(action)] 
    221221 
    222222        action_infos = [] 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/interfaces.py

    r3491 r3514  
    1111    [SimpleTerm(value=u'anonymous', title=_(u'Cache only for anonymous')), 
    1212     SimpleTerm(value=u'all', title=_(u'Cache for all users')), ] 
    13     ) 
     13) 
    1414 
    1515 
     
    8989        description=_(u"Caching of the menu viewlet improves page rendering " 
    9090                      u"speed."), 
    91         default=True 
    92         ) 
     91        default=True) 
    9392 
    9493    caching_strategy = schema.Choice( 
     
    9796                      u"built."), 
    9897        default="anonymous", 
    99         vocabulary=cachings 
    100         ) 
     98        vocabulary=cachings) 
    10199 
    102100    mobile_menu = schema.Bool( 
    103101        title=_(u"Display menu as select for small screens"), 
    104102        description=_(u"Use select tag to display menu for small screens"), 
    105         default=False, 
    106         ) 
     103        default=False) 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/setuphandlers.py

    r3153 r3514  
    3636    if qiprod: 
    3737        utilities = getattr(qiprod, 'utilities', []) 
    38         todel = filter(lambda k: not sum(map( 
    39                     lambda i: PROJECT_NAME in i, k)), utilities) 
     38        is_project = lambda i: PROJECT_NAME in i 
     39        todel = filter(lambda k: not sum(map(is_project, k)), utilities) 
    4040        for u in todel: 
    4141            uidx = utilities.index(u) 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_controlpanel.py

    r3153 r3514  
    2121        # Check if dropdownmenu is in the control panel 
    2222        self.controlpanel = getToolByName(self.portal, "portal_controlpanel") 
    23         self.failUnless('dropdownmenu' in [a.getAction(self)['id'] 
    24                             for a in self.controlpanel.listActions()]) 
     23        self.failUnless('dropdownmenu' in [ 
     24            a.getAction(self)['id'] 
     25            for a in self.controlpanel.listActions()]) 
    2526 
    2627    def test_show_icons(self): 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_docs.py

    r3153 r3514  
    2828        #    test_class=TestCase), 
    2929 
    30         ]) 
     30    ]) 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_installation.py

    r3153 r3514  
    2525        qi = self.portal.portal_quickinstaller 
    2626        self.assertTrue(qi.isProductInstalled(PROJECT_NAME), 
    27             '%s is not installed.' % PROJECT_NAME) 
     27                        '%s is not installed.' % PROJECT_NAME) 
    2828 
    2929    def testInstalledDependencies(self): 
    3030        cp = self.portal.portal_controlpanel 
    3131        configlets = [ai['id'] for ai in cp.listActionInfos( 
    32                                              check_permissions=0)] 
     32                      check_permissions=0)] 
    3333        self.assertTrue([1 for ai in configlets if ai == "plone.app.registry"], 
    34                 'Not installed required plone.app.registry product.') 
     34                        'Not installed required plone.app.registry product.') 
    3535 
    3636    def testStyles(self): 
     
    4343        cp = self.portal.portal_controlpanel 
    4444        configlets = [ai['id'] for ai in cp.listActionInfos( 
    45                                              check_permissions=0)] 
     45                      check_permissions=0)] 
    4646        for cid in CONFIGLETS: 
    47             self.assertTrue([1 for ai in configlets if ai == cid], 
     47            self.assertTrue([ 
     48                1 for ai in configlets if ai == cid], 
    4849                'No "%s" configlet added to plone control panel' % cid) 
    4950 
     
    5657        afield = "show_content_tabs" 
    5758        self.assertTrue(registry.records.get(IPREFIX + afield, None), 
    58             "Not registered '%s' registry interface" % IPREFIX) 
     59                        "Not registered '%s' registry interface" % IPREFIX) 
    5960 
    6061 
     
    6465        qi = self.portal.portal_quickinstaller 
    6566        self.assertFalse(qi.isProductInstalled(PROJECT_NAME), 
    66             '%s not uninstalled.' % PROJECT_NAME) 
     67                         '%s not uninstalled.' % PROJECT_NAME) 
    6768 
    6869    def testStyles(self): 
     
    7576        cp = self.portal.portal_controlpanel 
    7677        configlets = [ai['id'] for ai in cp.listActionInfos( 
    77                                             check_permissions=0)] 
     78                      check_permissions=0)] 
    7879        for cid in CONFIGLETS: 
    7980            self.assertFalse([1 for ai in configlets if ai == cid], 
    80                 '"%s" configlet not uninstalled '\ 
    81                 'from plone control panel' % cid) 
     81                             '"%s" configlet not uninstalled ' 
     82                             'from plone control panel' % cid) 
    8283 
    8384    def testBrowserLayer(self): 
    8485        self.assertFalse(IDropDownMenuLayer in blutils.registered_layers(), 
    85                      "Not unregistered 'IDropDownMenuLayer' browser layer") 
     86                         "Not unregistered 'IDropDownMenuLayer' browser layer") 
    8687 
    8788    def testRegistry(self): 
     
    8990        afield = "show_content_tabs" 
    9091        self.assertFalse(registry.records.get(IPREFIX + afield, None), 
    91             "Not unregistered '%s' registry interface" % IPREFIX) 
     92                         "Not unregistered '%s' registry interface" % IPREFIX) 
    9293 
    9394 
  • quintagroup.dropdownmenu/trunk/setup.py

    r3492 r3514  
    55 
    66tests_require = ['zope.testing', 
    7                'collective.testcaselayer'] 
     7                 'collective.testcaselayer'] 
    88 
    99setup(name='quintagroup.dropdownmenu', 
    1010      version=version, 
    1111      description="Multilevel portal dropdown menu for Plone sites.", 
    12       long_description=open("README.txt").read() + "\n" + 
    13                       open(os.path.join("docs", "HISTORY.txt")).read(), 
     12      long_description=open("README.txt").read( 
     13      ) + "\n" + open(os.path.join("docs", "HISTORY.txt")).read(), 
    1414      classifiers=[ 
    15         "Framework :: Plone", 
    16         "Programming Language :: Python", 
    17         "License :: OSI Approved :: GNU General Public License (GPL)", 
    18         "Operating System :: OS Independent", 
    19         "Topic :: Software Development :: Libraries :: Python Modules", 
    20         ], 
     15          "Framework :: Plone", 
     16          "Programming Language :: Python", 
     17          "License :: OSI Approved :: GNU General Public License (GPL)", 
     18          "Operating System :: OS Independent", 
     19          "Topic :: Software Development :: Libraries :: Python Modules", 
     20      ], 
    2121      keywords='web plone menu', 
    2222      author='Quintagroup', 
Note: See TracChangeset for help on using the changeset viewer.