<commit_before>import json
import urllib.request
from urllib.error import URLError


DEPARTURE_LINK = 'http://widgets.vvo-online.de/abfahrtsmonitor/Abfahrten.do?ort={ort}&hst={hst}'


def get_departures(station, city, nextStopCount):
    link = DEPARTURE_LINK.format(ort=city, hst=station)

    try:
        ret = urllib.request.urlopen(link)
        next_stops = json.loads(ret.read().decode("UTF-8"))
    except URLError:
        return []

    formatted_stops = [{'number': stop[0], 'name': stop[1], 'minutes': stop[2]}
                       for stop in next_stops[:nextStopCount]]

    return {station.lower().replace('%20', ''): formatted_stops}


def all_departures():
    all_stops = {}
    all_stops.update(crop_departures(get_departures('Helmholtzstrasse', 'Dresden', 6), 3))
    all_stops.update(crop_departures(get_departures('Muenchner%20Platz',
                                                    'Dresden', 6), 3, 7))
    all_stops.update(crop_departures(get_departures('Technische%20Universitaet', 'Dresden', 6), 3, 1))

    return all_stops


def crop_departures(all_departures, nextStopCount, minutes=None):
    departure_list = []
    key = sorted(all_departures.keys())[:1][0]
    for departure in all_departures[key]:
        if departure['minutes'] != '':
            if minutes is not None:
                if int(departure['minutes']) >= minutes:
                    departure_list.append(departure)
            else:
                departure_list.append(departure)
    new_departures = {key: departure_list[:nextStopCount]}

    return new_departures<commit_msg>simplify vvo api handling, thanks @dirkonet<commit_after>import json
import urllib.request
from urllib.error import URLError


DEPARTURE_LINK = 'http://widgets.vvo-online.de/abfahrtsmonitor/Abfahrten.do?ort\
={ort}&hst={hst}&vz={minutes}&lim={count}'


def get_departures(station, city='Dresden', min_minutes=None, nextStopCount=3):
    link = DEPARTURE_LINK.format(
        ort=city, hst=station, minutes=min_minutes, count=nextStopCount)

    try:
        ret = urllib.request.urlopen(link)
        next_stops = json.loads(ret.read().decode("UTF-8"))
    except URLError:
        return []

    formatted_stops = [{'number': stop[0], 'name': stop[1], 'minutes': stop[2]}
                       for stop in next_stops]

    return {station.lower().replace('%20', ''): formatted_stops}


def all_departures():
    all_stops = {}
    all_stops.update(get_departures('Helmholtzstrasse'))
    all_stops.update(get_departures('Muenchner%20Platz', min_minutes=7))
    all_stops.update(get_departures(
        'Technische%20Universitaet', min_minutes=1))

    return all_stops
{'fraction_non_alphanumeric': 0.1343115124153499, 'fraction_numerical': 0.012415349887133182, 'mean_word_length': 3.522108843537415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6851850', 'n_tokens_mistral': 955, 'n_tokens_neox': 903, 'n_words': 146}