<commit_before>import os

import flask
import git

STATIC_FOLDER = os.path.abspath('static')
TEMPLATE_FOLDER = os.path.join(STATIC_FOLDER, 'html')
JSON_FOLDER = os.path.join(STATIC_FOLDER, 'json')
OWNER = '<NAME>'
ALT_NAMES = ['<NAME>']
ORGANIZATIONS = ['Brookhaven National Laboratory', 'Stony Brook University', 'SUSU', 'Applied Technologies',
                 'Rocket Software']
TOPICS = ['science', 'physics', 'chemistry', 'software development', 'Python']
KEYWORDS = '{}, {}, {}, {}'.format(
    OWNER,
    ', '.join(ALT_NAMES),
    ', '.join(ORGANIZATIONS),
    ', '.join(TOPICS),
)
USER = 'Guest'
TITLE = OWNER  # default title


def render_template(*args, **kwargs):
    if 'owner' not in kwargs.keys():
        kwargs['owner'] = OWNER
    if 'keywords' not in kwargs.keys():
        kwargs['keywords'] = KEYWORDS
    if 'title' not in kwargs.keys():
        kwargs['title'] = TITLE
    if 'last_updated' not in kwargs.keys():
        kwargs['last_updated'] = _repo_last_update()
    return flask.render_template(*args, **kwargs)


def _repo_last_update(repo_path='.'):
    try:
        g = git.Git(repo_path)
        last_updated = g.log(-1, '--format=%cd', '--date=iso')
    except:
        last_updated = None
    return last_updated<commit_msg>Last update date fixed for production.<commit_after>import datetime
import os

import flask
import git

STATIC_FOLDER = os.path.abspath('static')
TEMPLATE_FOLDER = os.path.join(STATIC_FOLDER, 'html')
JSON_FOLDER = os.path.join(STATIC_FOLDER, 'json')
OWNER = '<NAME>'
ALT_NAMES = ['<NAME>']
ORGANIZATIONS = ['Brookhaven National Laboratory', 'Stony Brook University', 'SUSU', 'Applied Technologies',
                 'Rocket Software']
TOPICS = ['science', 'physics', 'chemistry', 'software development', 'Python']
KEYWORDS = '{}, {}, {}, {}'.format(
    OWNER,
    ', '.join(ALT_NAMES),
    ', '.join(ORGANIZATIONS),
    ', '.join(TOPICS),
)
USER = 'Guest'
TITLE = OWNER  # default title

# Date format of the last update:
DATE_FORMAT = {
    'iso': '%Y-%m-%d %H:%M:%S %z',
}


def render_template(*args, **kwargs):
    if 'owner' not in kwargs.keys():
        kwargs['owner'] = OWNER
    if 'keywords' not in kwargs.keys():
        kwargs['keywords'] = KEYWORDS
    if 'title' not in kwargs.keys():
        kwargs['title'] = TITLE
    if 'last_updated' not in kwargs.keys():
        kwargs['last_updated'] = _repo_last_update()
    return flask.render_template(*args, **kwargs)


def _repo_last_update(repo_path='.', status_file='updated', date_format='iso'):
    last_updated = None
    if os.path.isfile(status_file):
        with open(status_file) as f:
            last_updated = _validate_date(
                f.read(),
                date_format=DATE_FORMAT[date_format]
            )
    else:
        try:
            g = git.Git(repo_path)
            last_updated = _validate_date(
                g.log(-1, '--format=%cd', '--date={}'.format(date_format)),
                date_format=DATE_FORMAT[date_format]
            )
        except:
            pass
    return last_updated


def _validate_date(date_text, date_format):
    try:
        return datetime.datetime.strptime(date_text, date_format).strftime(date_format)
    except ValueError:
        return None
{'fraction_non_alphanumeric': 0.15173053152039556, 'fraction_numerical': 0.0006180469715698393, 'mean_word_length': 3.160668380462725, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2301753', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1050, 'n_words': 238}