Skip to content

Commit

Permalink
pep8 rules
Browse files Browse the repository at this point in the history
  • Loading branch information
TigorC committed Dec 12, 2012
1 parent 4a905b3 commit 00d393a
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions flowplayer/templatetags/flowplayer_tags.py
@@ -1,16 +1,17 @@
from django.conf import settings
from django.db.models.query import QuerySet
from django.template import TemplateSyntaxError, VariableDoesNotExist, Node
from django.template import Node, TemplateSyntaxError
from django.template import Library, Variable, loader, Context

# ID of current flowplayer being rendered (global to ensure unique)
FLOWPLAYER_ITERATOR = 0

register = Library()


class FlowPlayerNode(Node):
"Renderer class for the flowplayer template tag."

def __init__(self, media, player_class, player_id=None):
"""
Constructor.
Expand Down Expand Up @@ -49,13 +50,13 @@ def render(self, context):
else:
context['flowplayer_iterator'] = 0

try:
try:
# Try resolve this variable in the template context
self.media_element = self.media.resolve(context)
self.media_element = self.media.resolve(context)
except:
# Cannot resolve, therefore treat as url string
self.media_element = self.media

try:
self.extra_id = self.player_id.resolve(context)
except:
Expand All @@ -73,18 +74,19 @@ def render(self, context):
else:
self.media_url = self.media_element
self.media_playlist = False

t = loader.get_template('flowplayer/flowplayer.html')
code_context = Context(
{"player_url": self.player_url,
"player_id": '%s%s' % (context['flowplayer_iterator'],self.extra_id),
"player_id": '%s%s' % (context['flowplayer_iterator'], self.extra_id),
"player_class": self.player_class,
"player_config": self.player_config,
"media_url": self.media_url,
"media_playlist":self.media_playlist
"media_playlist": self.media_playlist
}, autoescape=context.autoescape)
return t.render(code_context)


def do_flowplayer(parser, token):
"""
This will insert an flash-based flv videoplayer (flowplayer) in form of an <object>
Expand All @@ -95,28 +97,28 @@ def do_flowplayer(parser, token):
{% flowplayer media_url %}
Example::
{% flowplayer video.flv %}
By default, 'flowplayer' tag will use FlowPlayerLight.swf found at
{% flowplayer video.flv %}
By default, 'flowplayer' tag will use FlowPlayerLight.swf found at
``{{ MEDIA_URL }}flowplayer/FlowPlayerLight.swf``.
To change this add FLOWPLAYER_URL to your settings.py file
Pass a dict of urls to the player to get a playlisted player instance
"""
"""

args = token.split_contents()

if len(args) < 2:
raise TemplateSyntaxError, "'flowplayer' tag requires at least one argument."
raise TemplateSyntaxError("'flowplayer' tag requires at least one argument.")

if len(args) == 3:
player_class = args[2]
else:
player_class = None

if len(args) == 4:
player_id = args[3]
else:
Expand All @@ -127,6 +129,5 @@ def do_flowplayer(parser, token):
return FlowPlayerNode(media, player_class, player_id)


# register the tag
# register the tag
register.tag('flowplayer', do_flowplayer)

0 comments on commit 00d393a

Please sign in to comment.