<commit_before># coding=utf8
"""
find_updates.py - Update checking module for Willie.

This is separated from version.py, so that it can be easily overridden by
distribution packagers, and they can check their repositories rather than the
Willie website.
"""
# Copyright 2014, <NAME>, embolalia.net
# Licensed under the Eiffel Forum License 2.
from __future__ import unicode_literals

import json
import re

import willie
import willie.module
import willie.web

wait_time = 24 * 60 * 60  # check once per day
startup_check_run = False
version_url = 'http://willie.dftba.net/latest.json'
message = (
    'A new Willie version, {}, is available. I am running {}. Please update ' +
    'me. Full release notes at {}.'
)


def parse_version(version):
    return re.match('(\d+)\.(\d+)\.(\d+)(?:-\S+)?', version).groups()


@willie.module.event('001')
@willie.module.event('251')
@willie.module.rule('.*')
def startup_version_check(bot, trigger):
    if not startup_check_run:
        startup_check_run = True
        check_version(bot)


@willie.module.interval(wait_time)
def check_version(bot):
    version = parse_version(willie.__version__)

    info = json.loads(willie.web.get(version_url))
    latest = info['version']
    notes = info['release_notes']
    latest_version = parse_version(latest)

    if version < latest_version:
        bot.msg(bot.config.core.owner,
                message.format(latest, willie.__version__, notes))<commit_msg>[find_updates] Fix unbound variable error on startup<commit_after># coding=utf8
"""
find_updates.py - Update checking module for Willie.

This is separated from version.py, so that it can be easily overridden by
distribution packagers, and they can check their repositories rather than the
Willie website.
"""
# Copyright 2014, <NAME>, embolalia.net
# Licensed under the Eiffel Forum License 2.
from __future__ import unicode_literals

import json
import re

import willie
import willie.module
import willie.web

wait_time = 24 * 60 * 60  # check once per day
startup_check_run = False
version_url = 'http://willie.dftba.net/latest.json'
message = (
    'A new Willie version, {}, is available. I am running {}. Please update ' +
    'me. Full release notes at {}.'
)


def parse_version(version):
    return re.match('(\d+)\.(\d+)\.(\d+)(?:-\S+)?', version).groups()


@willie.module.event('001')
@willie.module.event('251')
@willie.module.rule('.*')
def startup_version_check(bot, trigger):
    global startup_check_run
    if not startup_check_run:
        startup_check_run = True
        check_version(bot)


@willie.module.interval(wait_time)
def check_version(bot):
    version = parse_version(willie.__version__)

    info = json.loads(willie.web.get(version_url))
    latest = info['version']
    notes = info['release_notes']
    latest_version = parse_version(latest)

    if version < latest_version:
        bot.msg(bot.config.core.owner,
                message.format(latest, willie.__version__, notes))
{'fraction_non_alphanumeric': 0.12061994609164421, 'fraction_numerical': 0.012129380053908356, 'mean_word_length': 3.9731993299832498, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4868094', 'n_tokens_mistral': 973, 'n_tokens_neox': 917, 'n_words': 257}