<commit_before>#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# vim: fenc=utf-8
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
#

"""
File name: report.py
Author: dhilipsiva <<EMAIL>>
Date created: 2017-03-15
"""

from os import environ

from django import template
from django.conf import settings
from django.template import Template, Context
from django.template.engine import Engine

from ak_vendor.utils import dict2obj
from ak_vendor.seed import file_data
from ak_vendor.constants import REPORT_PATH, OUTPUT_PATH
from ak_vendor.enums import RiskEnum

settings.configure(DEBUG=False)
register = template.Library()
file = dict2obj(file_data)
pwd = environ['PWD']
content = ""

@register.filter(name="hash")
def hash(dictionary, key):
    return dictionary.get(key)

with open(REPORT_PATH, "r") as input_file:
    template_string = input_file.read()
    template = Template(template_string, engine=Engine())
    context = Context(dict(
        file=file, RiskEnum=RiskEnum))
    content = template.render(context)

with open(OUTPUT_PATH, "w") as output_file:
    output_file.write(content)<commit_msg>Fix flake errors<commit_after>from os import environ

from django import template
from django.conf import settings
from django.template import Template, Context
from django.template.engine import Engine

from ak_vendor.utils import dict2obj
from ak_vendor.seed import file_data
from ak_vendor.constants import REPORT_PATH, OUTPUT_PATH
from ak_vendor.enums import RiskEnum

settings.configure(DEBUG=False)
register = template.Library()
file = dict2obj(file_data)
pwd = environ['PWD']
content = ""


@register.filter(name="hash")
def hash(dictionary, key):
    return dictionary.get(key)


with open(REPORT_PATH, "r") as input_file:
    template_string = input_file.read()
    template = Template(template_string, engine=Engine())
    context = Context(dict(
        file=file, RiskEnum=RiskEnum))
    content = template.render(context)

with open(OUTPUT_PATH, "w") as output_file:
    output_file.write(content)
{'fraction_non_alphanumeric': 0.1037037037037037, 'fraction_numerical': 0.008395061728395062, 'mean_word_length': 5.33125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5857703', 'n_tokens_mistral': 638, 'n_tokens_neox': 625, 'n_words': 170}