# Path: applications/locale.py
# def get_translation(settings_dir=None):
#     return gettext_lazy
# 
# Path: applications/utils.py
# def render_string(template_name, **kwargs):
#     with io.open(template_name, mode='r',encoding='UTF-8') as f:
#         html = f.read()
#     template_strings = Template(html)
#     return template_strings.render(context=Context(dict_=kwargs))   


import os
import io
from applications.locale import get_translation
from applications.utils import render_string
    from datetime import datetime

def save_recording(self, settings):
    """
    Handles uploads of session recordings and returns them to the client in a
    self-contained HTML file that will auto-start playback.

    ..note:: The real crux of the code that handles this is in the template.
    """
    #import tornado.template
    now = datetime.now().strftime('%Y%m%d%H%m%S') # e.g. '20120208200222'
    out_dict = {
        'result': 'Success',
        'filename': 'GateOne_recording-%s.html' % now,
        'data': None,
        'mimetype': 'text/html'
    }
    recording = settings["recording"]
    container = settings["container"]
    prefix = settings["prefix"]
    theme_css = settings['theme_css']
    colors_css = settings['colors_css']
    colors_256 = get_256_colors(self)
    templates_path = os.path.join(PLUGIN_PATH, "templates")
    recording_template_path = os.path.join(
        templates_path, "self_contained_recording.html")
    #with open(recording_template_path) as f:
        #recording_template_data = f.read()
    extra_theme_path = os.path.join(templates_path,'themes/black.css')
    with io.open(extra_theme_path, mode='r',encoding='UTF-8') as f:
        extra_theme = f.read()    

# Path: applications/locale.py
# def get_translation(settings_dir=None):
#     return gettext_lazy
# 
# Path: applications/utils.py
# def render_string(template_name, **kwargs):
#     with io.open(template_name, mode='r',encoding='UTF-8') as f:
#         html = f.read()
#     template_strings = Template(html)
#     return template_strings.render(context=Context(dict_=kwargs))   


# Path: applications/plugins/playback/playback.py
import os
import io
from applications.locale import get_translation
from applications.utils import render_string
    from datetime import datetime


def save_recording(self, settings):
    """
    Handles uploads of session recordings and returns them to the client in a
    self-contained HTML file that will auto-start playback.

    ..note:: The real crux of the code that handles this is in the template.
    """
    #import tornado.template
    now = datetime.now().strftime('%Y%m%d%H%m%S') # e.g. '20120208200222'
    out_dict = {
        'result': 'Success',
        'filename': 'GateOne_recording-%s.html' % now,
        'data': None,
        'mimetype': 'text/html'
    }
    recording = settings["recording"]
    container = settings["container"]
    prefix = settings["prefix"]
    theme_css = settings['theme_css']
    colors_css = settings['colors_css']
    colors_256 = get_256_colors(self)
    templates_path = os.path.join(PLUGIN_PATH, "templates")
    recording_template_path = os.path.join(
        templates_path, "self_contained_recording.html")
    #with open(recording_template_path) as f:
        #recording_template_data = f.read()
    extra_theme_path = os.path.join(templates_path,'themes/black.css')
    with io.open(extra_theme_path, mode='r',encoding='UTF-8') as f:
        extra_theme = f.read()    

    rendered_recording = render_string(recording_template_path,**dict(recording=recording,