Permalink
Browse files

PEP8 clean up

  • Loading branch information...
1 parent 4624187 commit 72ad57dfcd9454e8197963f51ff694535d3f56b5 @GrAndSE committed Apr 23, 2012
View
@@ -1,4 +1,4 @@
-'''Tools for run commands in framework environment using simple manage.py
+'''Tools for run commands in framework environment using simple manage.py
script
'''
import itertools
@@ -54,6 +54,7 @@ def manage():
except Exception as e:
print(e)
return
+
# Try to get command name
def error_msg(msg):
raise argparse.ArgumentTypeError('%s. Commands available:\n\t%s\n' % (
View
@@ -84,7 +84,7 @@ def get(self, name, section=None):
if name in self.settings:
return self.settings[name]
else:
- if section in self.sections and name in self.sections[section]:
+ if section in self.sections and name in self.sections[section]:
return self.sections[section][name]
else:
raise KeyError('No section "%s" in configuration' % section)
View
@@ -31,15 +31,15 @@ def wrapper(self):
def monad_operator(func):
- '''Decorator that wraps function with one arugment type checking and
+ '''Decorator that wraps function with one arugment type checking and
exception catching
'''
@functools.wraps(func)
@handle_exception
def wrapper(self, value):
if isinstance(value, NoneMonad):
return value
- return ValueMonad(func(self, value.value
+ return ValueMonad(func(self, value.value
if isinstance(value, ValueMonad)
else value))
return wrapper
@@ -74,7 +74,7 @@ def check_argument(arg):
def monad_function(func):
- '''Decorator that wraps function with arguments, check all the values and
+ '''Decorator that wraps function with arguments, check all the values and
catch all the exceptions
'''
@functools.wraps(func)
@@ -216,7 +216,7 @@ def __init__(self, value):
'''Create new monad including value and store the code
'''
super(NoneMonad, self).__init__(value)
-
+
def __len__(self):
'''Returns 0
'''
@@ -1,8 +1,8 @@
-"""Package provides template tags manager and base tags list
+"""Package provides template tags manager and base tags list
"""
-VARIABLE = 0
-STRING = 1
-NUMBER = 2
+VARIABLE = 0
+STRING = 1
+NUMBER = 2
def parse_token(token):
@@ -20,7 +20,7 @@ def parse_token(token):
if idx > 0:
token_types.append(STRING)
tokens.append(word[0:idx])
- word = word[idx+1:]
+ word = word[idx + 1:]
if delim in word:
parts = word.split(delim)
tokens.append(parts[0])
@@ -55,17 +55,17 @@ def parse_token(token):
class TagManager(object):
- """Class used for tags manipulation
+ """Class used for tags manipulation
"""
def __init__(self):
- """Create new tag managet instance
+ """Create new tag managet instance
"""
super(TagManager, self).__init__()
self.tags = {}
def register(self, name, tag, is_block_tag=False, context_required=False,
- template_required=False, loader_required=False,
+ template_required=False, loader_required=False,
is_lazy_tag=True):
"""Register new tag
"""
@@ -98,7 +98,7 @@ def is_lazy_tag(self, name):
return self.is_tag_exists(name)[5]
def execute(self, name, token, context, block, template, loader):
- """Execute tag
+ """Execute tag
"""
tag = self.is_tag_exists(name)
args = {'token': token}
@@ -250,9 +250,8 @@ def partial(self, context, name='', key_args=()):
return result
-
class LazyTemplate(Template):
- '''Lazy template class can be used to access
+ '''Lazy template class can be used to access
'''
def prepare(self):
@@ -20,11 +20,11 @@ def sum(*args):
def float_format_args_parse(func, raw_value, format):
# Parse arguments
try:
- digits = abs(int(format))
+ digits = abs(int(format))
except:
raise Exception('%s arguments error: format is not integer' % func)
try:
- value = Decimal(raw_value)
+ value = Decimal(raw_value)
except:
raise Exception('%s supports only number values' % func)
return value, digits
@@ -95,9 +95,9 @@ def capfirst(value):
def stringformat(value, format):
- """Formats the variable according to the format, a string formatting
+ """Formats the variable according to the format, a string formatting
specifier.
-
+
This specifier uses Python string formating syntax, with the exception that
the leading "%" is dropped.
@@ -148,14 +148,14 @@ def spaceless(token, block, context):
"""This tag removes unused spaces
Template
-
+
{% spaceless %}
Some
text
{% endspaceless %}
will be rendered to:
-
+
Some text
"""
@@ -190,8 +190,8 @@ def with_tag(token, block, context):
"""
data_field, _, var_name = token.split(' ')
value = resolve(data_field, context)
- return exec_with_context(partial(exec_block, block),
- context, {var_name: value})
+ return exec_with_context(partial(exec_block, block), context,
+ {var_name: value})
tag_manager.register(
name='with',
@@ -212,7 +212,7 @@ def if_tag(token, block, context):
{% if user.is_authenticated %}Hello, {{ user.name }}!{% endif %}
TODO:
-
+
- add else
- add conditions
"""
@@ -247,7 +247,7 @@ def total(self):
@property
def last(self):
return not self.counter0 < self.total
-
+
@property
def first(self):
return self.counter0 == 0
@@ -267,7 +267,6 @@ def __call__(self, context):
return "".join([next for next in self.next(context)])
-
def for_tag(token, block, context):
"""For tag
@@ -276,7 +275,7 @@ def for_tag(token, block, context):
{% for a in items %}{{ a }}{% endfor %}
returns for items = [1, 2, 3]:
-
+
123
Also forloop variable will be added into scope. It contains few flags can
@@ -286,7 +285,7 @@ def for_tag(token, block, context):
{% spaceless %}<span
{% if forloop.first %} class="first"{% endif %}
{% if forloop.last %} class="last"{% endif %}>
- {{ forloop.counter0 }}.
+ {{ forloop.counter0 }}.
{{ forloop.counter }} from {{ forloop.total }}
</span>{% endspaceless %}
{% endfor %}
Oops, something went wrong.

0 comments on commit 72ad57d

Please sign in to comment.