__author__ = 'mkaplenko'


views = []


def to_static_html(func):
    def wrapper(*args, **kwargs):
        if func not in views:
            views.append(func)
            print views
        return func(*args, **kwargs)
    return wrapper

from functools import wraps
import os

static_root = os.path.join(os.path.dirname(__file__), 'static')

views = []


def to_static_html(path):
    def decorator(func):
        if func not in views:
                views.append((path, func))

        @wraps(func)
        def wrapper(*args, **kwargs):
            return func(*args, **kwargs)
        return wrapper
    return decorator


def construct_html():
    for view in views:
        with open(os.path.join(static_root, view[0]), 'w') as html_file:
            html_file.write(view[1]())

Add to static_html decorator code
Add to static_html decorator code

- __author__ = 'mkaplenko'
+ from functools import wraps
+ import os
  
+ static_root = os.path.join(os.path.dirname(__file__), 'static')
  
  views = []
  
  
- def to_static_html(func):
+ def to_static_html(path):
-     def wrapper(*args, **kwargs):
+     def decorator(func):
          if func not in views:
-             views.append(func)
+                 views.append((path, func))
-             print views
-         return func(*args, **kwargs)
-     return wrapper
  
+         @wraps(func)
+         def wrapper(*args, **kwargs):
+             return func(*args, **kwargs)
+         return wrapper
+     return decorator
+ 
+ 
+ def construct_html():
+     for view in views:
+         with open(os.path.join(static_root, view[0]), 'w') as html_file:
+             html_file.write(view[1]())
+ 
Add to static_html decorator code
## Code Before:
__author__ = 'mkaplenko'


views = []


def to_static_html(func):
    def wrapper(*args, **kwargs):
        if func not in views:
            views.append(func)
            print views
        return func(*args, **kwargs)
    return wrapper

## Instruction:
Add to static_html decorator code
## Code After:
from functools import wraps
import os

static_root = os.path.join(os.path.dirname(__file__), 'static')

views = []


def to_static_html(path):
    def decorator(func):
        if func not in views:
                views.append((path, func))

        @wraps(func)
        def wrapper(*args, **kwargs):
            return func(*args, **kwargs)
        return wrapper
    return decorator


def construct_html():
    for view in views:
        with open(os.path.join(static_root, view[0]), 'w') as html_file:
            html_file.write(view[1]())
