Skip to content

Commit

Permalink
Clean up according to PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Vetter committed Jul 29, 2013
1 parent cdff7f6 commit 51cd751
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 27 deletions.
3 changes: 2 additions & 1 deletion fancypages/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class FancypagesApplication(Application):
page_view = views.FancyPageDetailView

def get_urls(self):
urlpatterns = patterns('',
urlpatterns = patterns(
'',
url(
r'^(?P<slug>[\w-]+(/[\w-]+)*)/$',
self.page_view.as_view(),
Expand Down
8 changes: 4 additions & 4 deletions fancypages/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
########## END COMPRESSOR SETTINGS

########## TWITTER TAG SETTINGS
TWITTER_OAUTH_TOKEN=''
TWITTER_OAUTH_SECRET=''
TWITTER_CONSUMER_KEY=''
TWITTER_CONSUMER_SECRET=''
TWITTER_OAUTH_TOKEN = ''
TWITTER_OAUTH_SECRET = ''
TWITTER_CONSUMER_KEY = ''
TWITTER_CONSUMER_SECRET = ''
########## END TWITTER TAG SETTINGS
2 changes: 1 addition & 1 deletion fancypages/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def replace_insensitive(string, target, replacement):
index = no_case.rfind(target.lower())
if index >= 0:
return string[:index] + replacement + string[index + len(target):]
else: # no results so return the original string
else: # no results so return the original string
return string


Expand Down
3 changes: 2 additions & 1 deletion fancypages/templatetags/fp_block_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def get_content_type(obj):


##TODO need re-write due to new registered blocks
@register.inclusion_tag('fancypages/dashboard/block_select.html', takes_context=True)
@register.inclusion_tag('fancypages/dashboard/block_select.html',
takes_context=True)
def render_block_selection(context):
request = context.get('request')
if not request or not request.fancypages_edit_mode:
Expand Down
5 changes: 3 additions & 2 deletions fancypages/templatetags/fp_container_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ def fp_container(parser, token):

if len(args) != 2:
raise template.TemplateSyntaxError(
"%r tag expects a single argument container" \
% token.contents.split()[0]
"{0} tag expects a single argument container".format(
token.contents.split()[0]
)
)

tag_name, args = args[:1], args[1:]
Expand Down
11 changes: 8 additions & 3 deletions fancypages/templatetags/fp_sitemap_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,24 @@ def build_tree(root, parent, data, depth, instance_type):
@register.assignment_tag
def get_pages(visibility_type):
try:
visibility_type_instance = VisibilityType.objects.get(slug=visibility_type)
visibility_type_instance = VisibilityType.objects.get(
slug=visibility_type
)
except VisibilityType.DoesNotExist:
return Page.objects.none()
return Page.object.visible_in(visibility_type_instance)


@register.assignment_tag
def get_site_tree(visibility_type=None, depth=1, instance_type=INSTANCE_TYPE_PAGE):
def get_site_tree(visibility_type=None, depth=1,
instance_type=INSTANCE_TYPE_PAGE):
if instance_type not in INSTANCE_TYPES:
return []

try:
visibility_type_instance = VisibilityType.objects.get(slug=visibility_type)
visibility_type_instance = VisibilityType.objects.get(
slug=visibility_type
)
except VisibilityType.DoesNotExist:
visibility_type_instance = None
if visibility_type:
Expand Down
15 changes: 8 additions & 7 deletions fancypages/templatetags/verbatim.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from django import template

register = template.Library()


class VerbatimNode(template.Node):

def __init__(self, text):
self.text = text

def render(self, context):
return self.text


@register.tag
def verbatim(parser, token):
text = []
Expand All @@ -29,4 +30,4 @@ def verbatim(parser, token):
if not text[-1].startswith('='):
text[-1:-1] = [' ']
text.append(' %}')
return VerbatimNode(''.join(text))
return VerbatimNode(''.join(text))
2 changes: 1 addition & 1 deletion fancypages/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _checklogin(request, *args, **kwargs):
login_scheme, login_netloc = urlparse.urlparse(login_url)[:2]
current_scheme, current_netloc = urlparse.urlparse(path)[:2]
if ((not login_scheme or login_scheme == current_scheme) and
(not login_netloc or login_netloc == current_netloc)):
(not login_netloc or login_netloc == current_netloc)):
path = request.get_full_path()

messages.warning(request, _("You must log in to access this page"))
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
],
# See http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: Unix',
'Programming Language :: Python',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: Unix',
'Programming Language :: Python',
]
)
3 changes: 1 addition & 2 deletions tests/unit/blocks/test_text_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def setUp(self):
self.request_context['user'] = self.user

def test_can_be_rendered_in_template(self):
block = factories.TextBlockFactory.build()
block.id = 666
block = factories.TextBlockFactory.build(id=6)
renderer = block.get_renderer_class()(block, self.request_context)
block_html = renderer.render()

Expand Down

0 comments on commit 51cd751

Please sign in to comment.