<commit_before>#!/usr/bin/env python3

import os
import sqlite3
import time
import urllib
from urllib import error, request


def download_gtfs_zip():
    try:
        output_dir = os.path.dirname(os.path.realpath(__file__)) + "/gtfs.zip"
        zip_url = "http://www.stm.info/sites/default/files/gtfs/gtfs_stm.zip"

        urllib.request.urlretrieve(zip_url, output_dir)

    except urllib.error.HTTPError as err:
        print("Error {0} while trying to downloads stm infos")
        exit(1)


def check_for_update():  # Return True if update is needed, False if not
    curr_date = time.strftime('%Y%m%d')

    # Getting last update date in stm.db
    conn = sqlite3.connect('stm.db')
    c = conn.cursor()
    c.execute('SELECT * FROM calendar_dates WHERE date={0}'.format(curr_date))
    t = c.fetchone()
    conn.close()

    if t is None:
        return True
    else:
        return False
<commit_msg>zip file is now extracted to stm/ and deleted<commit_after>#!/usr/bin/env python3

import os
import sqlite3
import time
import urllib
from urllib import error, request
import zipfile


def download_gtfs_data():
    try:
        output_dir = os.path.dirname(os.path.realpath(__file__)) + "/gtfs.zip"
        zip_url = "http://www.stm.info/sites/default/files/gtfs/gtfs_stm.zip"

        urllib.request.urlretrieve(zip_url, output_dir)

    except urllib.error.HTTPError as err:
        print("Error {0} while trying to downloads stm infos")
        exit(1)

    # Extracting to stm/ and deleting zip
    extract_location = "stm/"

    if not os.path.isdir(extract_location):
        os.makedirs(extract_location)

    zip = zipfile.ZipFile('gtfs.zip')
    zip.extractall(path=extract_location)

    os.unlink("gtfs.zip")


def check_for_update():  # Return True if update is needed, False if not
    curr_date = time.strftime('%Y%m%d')

    # Getting last update date in stm.db
    conn = sqlite3.connect('stm.db')
    c = conn.cursor()
    c.execute('SELECT * FROM calendar_dates WHERE date={0}'.format(curr_date))
    t = c.fetchone()
    conn.close()

    if t is None:
        return True
    else:
        return False

{'fraction_non_alphanumeric': 0.1134020618556701, 'fraction_numerical': 0.005623242736644799, 'mean_word_length': 2.9757914338919926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4051651', 'n_tokens_mistral': 749, 'n_tokens_neox': 721, 'n_words': 182}