<commit_before>import lib.cmd
import datetime
import urllib.error
import urllib.request
import xml.etree.ElementTree
import xml.parsers.expat


API_URI = ('http://www.akafoe.de/gastronomie/mensen/ruhr-universitaet-bochum/'
           '?mid=1&tx_akafoespeiseplan_mensadetails%5Baction%5D=feed&tx_akafo'
           'espeiseplan_mensadetails%5Bcontroller%5D=AtomFeed&cHash=131da6102'
           'c27a372087f39f4c47be1e9')


NS = {
    'atom': 'http://www.w3.org/2005/Atom',
    'xhtml': 'http:/www.w3.org/1999/xhtml',
}


def _to_weekday(n):
    return ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag'][n]


@lib.cmd.command(private=False)
def mensa(msg=None):
    """Zeigt den derzeitigen Speiseplan der RUB Mensa."""
    tree = xml.etree.ElementTree.ElementTree()
    with urllib.request.urlopen(API_URI) as h:
        tree.parse(h)
    desired_date = datetime.datetime.now()
    if desired_date.hour > 15:  # after 15:00: show next day
        desired_date += datetime.timedelta(days=1)
    if desired_date.weekday() >= 5:  # saturday and sunday: show monday
        desired_date += datetime.timedelta(days=desired_date.weekday() - 5)
    day_name = _to_weekday(desired_date.weekday())
    desired_date_str = '%02d.%02d.' % (desired_date.day, desired_date.month)
    for entry in tree.findall('{%(atom)s}entry' % NS):
        title = entry.findtext('{%(atom)s}title' % NS)
        if desired_date_str in title:
            areas = {}
            current_area = ''
            for element in entry.iter():
                if element.tag == '{%(xhtml)s}strong' % NS:
                    current_area = element.text
                    areas[current_area] = []
                if element.tag == '{%(xhtml)s}li' % NS:
                    areas[current_area].append(element.text.strip())
            return '%s, der %s: %s' % (<commit_msg>Fix days until monday.<commit_after>import lib.cmd
import datetime
import urllib.error
import urllib.request
import xml.etree.ElementTree
import xml.parsers.expat


API_URI = ('http://www.akafoe.de/gastronomie/mensen/ruhr-universitaet-bochum/'
           '?mid=1&tx_akafoespeiseplan_mensadetails%5Baction%5D=feed&tx_akafo'
           'espeiseplan_mensadetails%5Bcontroller%5D=AtomFeed&cHash=131da6102'
           'c27a372087f39f4c47be1e9')


NS = {
    'atom': 'http://www.w3.org/2005/Atom',
    'xhtml': 'http:/www.w3.org/1999/xhtml',
}


def _to_weekday(n):
    return ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag'][n]


@lib.cmd.command(private=False)
def mensa(msg=None):
    """Zeigt den derzeitigen Speiseplan der RUB Mensa."""
    tree = xml.etree.ElementTree.ElementTree()
    with urllib.request.urlopen(API_URI) as h:
        tree.parse(h)
    desired_date = datetime.datetime.now()
    if desired_date.hour > 15:  # after 15:00: show next day
        desired_date += datetime.timedelta(days=1)
    if desired_date.weekday() >= 5:  # saturday and sunday: show monday
        days_to_monday = 2 - (desired_date.weekday() % 5)
        desired_date += datetime.timedelta(days=days_to_monday)
    day_name = _to_weekday(desired_date.weekday())
    desired_date_str = '%02d.%02d.' % (desired_date.day, desired_date.month)
    for entry in tree.findall('{%(atom)s}entry' % NS):
        title = entry.findtext('{%(atom)s}title' % NS)
        if desired_date_str in title:
            areas = {}
            current_area = ''
            for element in entry.iter():
                if element.tag == '{%(xhtml)s}strong' % NS:
                    current_area = element.text
                    areas[current_area] = []
                if element.tag == '{%(xhtml)s}li' % NS:
                    areas[current_area].append(element.text.strip())
            return '%s, der %s: %s' % (
{'fraction_non_alphanumeric': 0.14133048356932942, 'fraction_numerical': 0.026983702912102593, 'mean_word_length': 2.891891891891892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 6}, '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': '4285867', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1348, 'n_words': 228}