<commit_before>from __future__ import unicode_literals

from datetime import datetime
import os
import sys

from dateutil.relativedelta import relativedelta
import requests

bases = {'r\xf8sslyngen': 59,
         'myrulla': 61}

login_url = 'http://bukkesprangetnatur.barnehage.no/LogOn'
ics_url = ('http://bukkesprangetnatur.barnehage.no/Ukeplan/'
           'PlanMonthAsICalendar/{base}?year={year}&month={month}')


def stdin_decode(data):
    if sys.stdin.encoding is not None:
        return data.decode(sys.stdin.encoding)
    else:
        # Just assume we're modern if nothing else is specified
        return data.decode('utf-8')


def stdout_encode(data):
    if sys.stdout.encoding is not None:
        return data.encode(sys.stdout.encoding)
    else:
        # Just assume we're modern if nothing else is specified
        return data.encode('utf-8')


def main():
    base, user, password = (
        stdin_decode(os.environ['BASE']), os.environ['USER'],
        os.environ['PASSWORD'])
    session = requests.Session()
    response = session.post(
        login_url, data={'UserName': user, 'Password': password})
    response.raise_for_status()
    now = datetime.now()
    next = now + relativedelta(month=1)
    head = (
        session.get(ics_url.format(
            base=bases[base], year=now.year, month=now.month))
        .content.decode('utf-8'))
    tail = (
        session.get(
            ics_url.format(
                base=bases[base], year=next.year, month=next.month))
        .content.decode('utf-8'))

    # Stitch together the two ics files
    print(stdout_encode('\n'.join(head.split('\n')[:-3])
                        + '\n'.join(tail.split('\n')[3:])))
<commit_msg>Don't snip too much off the first file<commit_after>from __future__ import unicode_literals

from datetime import datetime
import os
import sys

from dateutil.relativedelta import relativedelta
import requests

bases = {'r\xf8sslyngen': 59,
         'myrulla': 61}

login_url = 'http://bukkesprangetnatur.barnehage.no/LogOn'
ics_url = ('http://bukkesprangetnatur.barnehage.no/Ukeplan/'
           'PlanMonthAsICalendar/{base}?year={year}&month={month}')


def stdin_decode(data):
    if sys.stdin.encoding is not None:
        return data.decode(sys.stdin.encoding)
    else:
        # Just assume we're modern if nothing else is specified
        return data.decode('utf-8')


def stdout_encode(data):
    if sys.stdout.encoding is not None:
        return data.encode(sys.stdout.encoding)
    else:
        # Just assume we're modern if nothing else is specified
        return data.encode('utf-8')


def main():
    base, user, password = (
        stdin_decode(os.environ['BASE']), os.environ['USER'],
        os.environ['PASSWORD'])
    session = requests.Session()
    response = session.post(
        login_url, data={'UserName': user, 'Password': password})
    response.raise_for_status()
    now = datetime.now()
    next = now + relativedelta(month=1)
    head = (
        session.get(ics_url.format(
            base=bases[base], year=now.year, month=now.month))
        .content.decode('utf-8'))
    tail = (
        session.get(
            ics_url.format(
                base=bases[base], year=next.year, month=next.month))
        .content.decode('utf-8'))

    # Stitch together the two ics files
    print(stdout_encode('\n'.join(head.split('\n')[:-1])
                        + '\n'.join(tail.split('\n')[3:])))

{'fraction_non_alphanumeric': 0.1363768537365513, 'fraction_numerical': 0.006978772899098575, 'mean_word_length': 2.8307349665924275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1258225', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1093, 'n_words': 235}