import ast

from django.core.urlresolvers import reverse
from django.utils.encoding import iri_to_uri

import datetime

from knights.library import Library

register = Library()


@register.tag
def static(parser, token):
    src = parser.parse_expression(token)
    return ast.Yield(value=ast.BinOp(
        left=ast.Str(s='/static/%s'),
        op=ast.Mod(),
        right=src,
    ))


@register.helper
def capfirst(value):
    return value and value[0].upper() + value[1:]

@register.helper
def safe(value):
    return str(value)


@register.helper
def now(fmt):
    return datetime.datetime.now().strftime(fmt)

@register.helper
def url(name, *args, **kwargs):
    try:
        return reverse(name, args=args, kwargs=kwargs)
    except:
        return None


@register.helper
def static(filename):
    try:
        from django.conf import settings
    except ImportError:
        prefix = ''
    else:
        prefix = iri_to_uri(getattr(settings, name, ''))
    return prefix

import ast

from django.core.urlresolvers import reverse
from django.utils.encoding import iri_to_uri

import datetime

from knights.library import Library

register = Library()


@register.helper
def now(fmt):
    return datetime.datetime.now().strftime(fmt)


@register.helper
def url(name, *args, **kwargs):
    try:
        return reverse(name, args=args, kwargs=kwargs)
    except:
        return None


@register.helper
def static(filename):
    try:
        from django.conf import settings
    except ImportError:
        prefix = ''
    else:
        prefix = iri_to_uri(getattr(settings, name, ''))
    return prefix

Remove bodgy static tag Remove duplicate capfirst helper
Remove bodgy static tag
Remove duplicate capfirst helper

  import ast
  
  from django.core.urlresolvers import reverse
  from django.utils.encoding import iri_to_uri
  
  import datetime
  
  from knights.library import Library
  
  register = Library()
  
  
- @register.tag
- def static(parser, token):
-     src = parser.parse_expression(token)
-     return ast.Yield(value=ast.BinOp(
-         left=ast.Str(s='/static/%s'),
-         op=ast.Mod(),
-         right=src,
-     ))
- 
- 
- @register.helper
- def capfirst(value):
-     return value and value[0].upper() + value[1:]
- 
- @register.helper
- def safe(value):
-     return str(value)
- 
- 
  @register.helper
  def now(fmt):
      return datetime.datetime.now().strftime(fmt)
+ 
  
  @register.helper
  def url(name, *args, **kwargs):
      try:
          return reverse(name, args=args, kwargs=kwargs)
      except:
          return None
  
  
  @register.helper
  def static(filename):
      try:
          from django.conf import settings
      except ImportError:
          prefix = ''
      else:
          prefix = iri_to_uri(getattr(settings, name, ''))
      return prefix
  
Remove bodgy static tag Remove duplicate capfirst helper
## Code Before:
import ast

from django.core.urlresolvers import reverse
from django.utils.encoding import iri_to_uri

import datetime

from knights.library import Library

register = Library()


@register.tag
def static(parser, token):
    src = parser.parse_expression(token)
    return ast.Yield(value=ast.BinOp(
        left=ast.Str(s='/static/%s'),
        op=ast.Mod(),
        right=src,
    ))


@register.helper
def capfirst(value):
    return value and value[0].upper() + value[1:]

@register.helper
def safe(value):
    return str(value)


@register.helper
def now(fmt):
    return datetime.datetime.now().strftime(fmt)

@register.helper
def url(name, *args, **kwargs):
    try:
        return reverse(name, args=args, kwargs=kwargs)
    except:
        return None


@register.helper
def static(filename):
    try:
        from django.conf import settings
    except ImportError:
        prefix = ''
    else:
        prefix = iri_to_uri(getattr(settings, name, ''))
    return prefix

## Instruction:
Remove bodgy static tag Remove duplicate capfirst helper
## Code After:
import ast

from django.core.urlresolvers import reverse
from django.utils.encoding import iri_to_uri

import datetime

from knights.library import Library

register = Library()


@register.helper
def now(fmt):
    return datetime.datetime.now().strftime(fmt)


@register.helper
def url(name, *args, **kwargs):
    try:
        return reverse(name, args=args, kwargs=kwargs)
    except:
        return None


@register.helper
def static(filename):
    try:
        from django.conf import settings
    except ImportError:
        prefix = ''
    else:
        prefix = iri_to_uri(getattr(settings, name, ''))
    return prefix
