<commit_before>#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import urllib2
from datetime import datetime, timedelta
from bs4 import BeautifulSoup

from plugins.plugin import Plugin
from time import time

from bytebot_config import BYTEBOT_HTTP_TIMEOUT, BYTEBOT_HTTP_MAXSIZE
from bytebot_config import BYTEBOT_PLUGIN_CONFIG


class station(Plugin):

    def __init__(self):
        pass

    def registerCommand(self, irc):
        irc.registerCommand('!station', 'Haltestelle')

    def _get_public_traffic(self, station, number_of_results):
        url = "http://vmt.hafas.de/bin/stboard.exe/dn?"

        today = datetime.now()
        tomorrow = datetime.now() + timedelta(hours=24)

        today_formated = '{:%d.%m.%y}'.format(today)
        tomorrow_formated = '{:%d.%m.%y}'.format(tomorrow)
        hour = '{:%H}'.format(today)
        minute = '{:%M}'.format(today)

        data = 'input=' + station + \
            '&selectDate=today&dateBegin=' + str(today_formated) + \
            '&dateEnd=' + str(tomorrow_formated) + \
            '&time=' + str(hour) + '%3A' + str(minute) + \
            '&timeselect=W%E4hlen' +\
            '&boardType=dep' +\
            '&REQProduct_list=1%3A1111111111111111' +\
            '&maxJourneys=' + str(number_of_results) + \
            '&start=Anzeigen'

        req = urllib2.Request(url, data)
        response = urllib2.urlopen(req)

        soup = BeautifulSoup(response.read(), 'html.parser')

        station_name = soup.find_all('span', {"class": "output"})
        time = soup.find_all('td', {"class": "time"})
        product = soup.find_all('td', {"class": "product"})
        timetable = soup.find_all('td', {"class": "timetable"})

        name = station_name[0].text.encode('utf-8').strip()
        ret = []

        for i in range(number_of_results):
            try:
                ret.append({'time': time[i].text.encode('utf-8').strip(),
                            'product': product[i].text.encode('utf-8').strip().replace("    ", " "),
                            'timetable': timetable[i].find('a').text.encode('utf-8').strip()})
            except Exception as e:
                #Ups should not happen, if e happens just do nothing brobot

        return name, ret

    def onPrivmsg(self, irc, msg, channel, user):
        if msg.find('!station') == -1:
            return

        self.irc = irc
        self.channel = channel

        try:
            last_station = irc.last_station
        except Exception as e:
            last_station = 0

        if last_station < (time() - 60):<commit_msg>adding bug fix<commit_after>#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import urllib2
from datetime import datetime, timedelta
from bs4 import BeautifulSoup

from plugins.plugin import Plugin
from time import time

from bytebot_config import BYTEBOT_HTTP_TIMEOUT, BYTEBOT_HTTP_MAXSIZE
from bytebot_config import BYTEBOT_PLUGIN_CONFIG


class station(Plugin):

    def __init__(self):
        pass

    def registerCommand(self, irc):
        irc.registerCommand('!station', 'Haltestelle')

    def _get_public_traffic(self, station, number_of_results):
        url = "http://vmt.hafas.de/bin/stboard.exe/dn?"

        today = datetime.now()
        tomorrow = datetime.now() + timedelta(hours=24)

        today_formated = '{:%d.%m.%y}'.format(today)
        tomorrow_formated = '{:%d.%m.%y}'.format(tomorrow)
        hour = '{:%H}'.format(today)
        minute = '{:%M}'.format(today)

        data = 'input=' + station + \
            '&selectDate=today&dateBegin=' + str(today_formated) + \
            '&dateEnd=' + str(tomorrow_formated) + \
            '&time=' + str(hour) + '%3A' + str(minute) + \
            '&timeselect=W%E4hlen' +\
            '&boardType=dep' +\
            '&REQProduct_list=1%3A1111111111111111' +\
            '&maxJourneys=' + str(number_of_results) + \
            '&start=Anzeigen'

        req = urllib2.Request(url, data)
        response = urllib2.urlopen(req)

        soup = BeautifulSoup(response.read(), 'html.parser')

        station_name = soup.find_all('span', {"class": "output"})
        time = soup.find_all('td', {"class": "time"})
        product = soup.find_all('td', {"class": "product"})
        timetable = soup.find_all('td', {"class": "timetable"})

        name = station_name[0].text.encode('utf-8').strip()
        ret = []

        for i in range(number_of_results):
            ret.append({'time': time[i].text.encode('utf-8').strip(),
                        'product': product[i].text.encode('utf-8').strip().replace("    ", " "),
                        'timetable': timetable[i].find('a').text.encode('utf-8').strip()})

        return name, ret

    def onPrivmsg(self, irc, msg, channel, user):
        if msg.find('!station') == -1:
            return

        self.irc = irc
        self.channel = channel

        try:
            last_station = irc.last_station
        except Exception as e:
            last_station = 0

        if last_station < (time() - 60):
{'fraction_non_alphanumeric': 0.15455088627763394, 'fraction_numerical': 0.014738099980083649, 'mean_word_length': 2.3547094188376754, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5787637', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1572, 'n_words': 307}