Skip to content

Commit c2e92ea

Browse files
committed
PEP8 fixes
1 parent a5815bf commit c2e92ea

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

menu/menu.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from django.conf import settings
22

3-
import traceback
4-
import sys
53
import re
64

5+
76
class Menu(object):
87
"""
98
Menu is a class that generates menus
@@ -45,7 +44,7 @@ def load_menus(c):
4544
"""
4645

4746
# we don't need to do this more than once
48-
if c.loaded == True:
47+
if c.loaded:
4948
return
5049

5150
# loop through our INSTALLED_APPS
@@ -56,7 +55,7 @@ def load_menus(c):
5655

5756
menu_module = '%s.menus' % app
5857
try:
59-
__import__(menu_module, fromlist=["menu",])
58+
__import__(menu_module, fromlist=["menu"])
6059
except ImportError:
6160
pass
6261

@@ -69,8 +68,8 @@ def sort_menus(c):
6968
their weight
7069
"""
7170
for name in c.items:
72-
if c.sorted[name] != True:
73-
c.items[name].sort(cmp=lambda x,y: cmp(x.weight, y.weight))
71+
if not c.sorted[name]:
72+
c.items[name].sort(cmp=lambda x, y: cmp(x.weight, y.weight))
7473
c.sorted[name] = True
7574

7675
@classmethod
@@ -96,7 +95,7 @@ def process(c, request, name=None):
9695
curitem = None
9796
for item in c.items[name]:
9897
item.process(request)
99-
if item.visible == True:
98+
if item.visible:
10099
item.selected = False
101100
if item.match_url(request):
102101
if curitem is None or len(curitem.url) < len(item.url):
@@ -133,7 +132,7 @@ class MenuItem(object):
133132
menu (children).
134133
"""
135134

136-
def __init__(self, title, url, children=[], weight=1, check=None,
135+
def __init__(self, title, url, children=[], weight=1, check=None,
137136
visible=True, slug=None, exact_url=False, **kwargs):
138137
"""
139138
MenuItem constructor
@@ -232,11 +231,7 @@ def check_children(self, request):
232231

233232
def check_check(self, request):
234233
if callable(self.check):
235-
check = self.check(request)
236-
if check != True:
237-
self.visible = False
238-
else:
239-
self.visible = True
234+
self.visible = self.check(request)
240235

241236
def check_title(self, request):
242237
if callable(self._title):

0 commit comments

Comments
 (0)