コード例 #1
0
    def __init__(self, file_cacher):
        super().__init__()

        self.file_cacher = file_cacher
        self.jinja2_env = GLOBAL_ENVIRONMENT.overlay(loader=PackageLoader(
            "cms.service", "templates/printing"),
                                                     autoescape=False)
        self.jinja2_env.filters["escape_tex_normal"] = escape_tex_normal
        self.jinja2_env.filters["escape_tex_tt"] = escape_tex_tt
コード例 #2
0
ファイル: PrintingService.py プロジェクト: cms-dev/cms
    def __init__(self, file_cacher):
        super().__init__()

        self.file_cacher = file_cacher
        self.jinja2_env = GLOBAL_ENVIRONMENT.overlay(
            loader=PackageLoader("cms.service", "templates/printing"),
            autoescape=False)
        self.jinja2_env.filters["escape_tex_normal"] = escape_tex_normal
        self.jinja2_env.filters["escape_tex_tt"] = escape_tex_tt
コード例 #3
0
ファイル: jinja2_toolbox.py プロジェクト: cms-dev/cms
def extract_token_params(o):
    return {k[6:]: v
            for k, v in o.__dict__.items() if k.startswith("token_")}


def instrument_cms_toolbox(env):
    env.filters["extract_token_params"] = extract_token_params


@contextfilter
def wrapped_format_token_rules(ctx, tokens, t_type=None):
    translation = ctx["translation"]
    return format_token_rules(tokens, t_type, translation=translation)


def instrument_formatting_toolbox(env):
    env.globals["get_score_class"] = get_score_class

    env.filters["format_token_rules"] = wrapped_format_token_rules


CWS_ENVIRONMENT = GLOBAL_ENVIRONMENT.overlay(
    # Load templates from CWS's package (use package rather than file
    # system as that works even in case of a compressed distribution).
    loader=PackageLoader('cms.server.contest', 'templates'))


instrument_cms_toolbox(CWS_ENVIRONMENT)
instrument_formatting_toolbox(CWS_ENVIRONMENT)
コード例 #4
0
def extract_token_params(o):
    return {
        k[6:]: v
        for k, v in iteritems(o.__dict__) if k.startswith("token_")
    }


def instrument_cms_toolbox(env):
    env.filters["extract_token_params"] = extract_token_params


@contextfilter
def wrapped_format_token_rules(ctx, tokens, t_type=None):
    translation = ctx["translation"]
    return format_token_rules(tokens, t_type, translation=translation)


def instrument_formatting_toolbox(env):
    env.globals["get_score_class"] = get_score_class

    env.filters["format_token_rules"] = wrapped_format_token_rules


CWS_ENVIRONMENT = GLOBAL_ENVIRONMENT.overlay(
    # Load templates from CWS's package (use package rather than file
    # system as that works even in case of a compressed distribution).
    loader=PackageLoader('cms.server.contest', 'templates'))

instrument_cms_toolbox(CWS_ENVIRONMENT)
instrument_formatting_toolbox(CWS_ENVIRONMENT)
コード例 #5
0

def instrument_cms_toolbox(env):
    env.filters["extract_token_params"] = extract_token_params

    env.tests["contest_visible"] = contest_visible


@contextfilter
def wrapped_format_token_rules(ctx, tokens, t_type=None):
    translation = ctx["translation"]
    return format_token_rules(tokens, t_type, translation=translation)


def instrument_formatting_toolbox(env):
    env.globals["get_score_class"] = get_score_class

    env.filters["format_token_rules"] = wrapped_format_token_rules


CWS_ENVIRONMENT = GLOBAL_ENVIRONMENT.overlay(
    # Load templates from CWS's package (use package rather than file
    # system as that works even in case of a compressed distribution).
    loader=ChoiceLoader([
        PackageLoader('cms.server.contest', 'templates'),
        FileSystemLoader('/var/local/lib/cms/templates')
    ]))

instrument_cms_toolbox(CWS_ENVIRONMENT)
instrument_formatting_toolbox(CWS_ENVIRONMENT)