<commit_before>import requests
import datetime


def calculateTimeToLookForInSchedule(date):
    minute = date.minute
    hour = date.hour
    if minute == 0:
        return formatTime(hour, 0)
    elif minute > 30:
        return formatTime(hour + 1, 0)
    else:
        return formatTime(hour, 30)


def sendNotificationToSlackFor(entries):
    text = reduce(lambda x, y: x + '\n' + y,
                  map(lambda x: x['loc'][0] + ": " + x['title'], entries)
                  )
    text = "*Now starting*:\n" + text
    requests.post('https://hooks.slack.com/services/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',
                      data='{"text":"' + text + '"}')


def formatTime(hour, minute):
    return '{num:02d}'.format(num=hour) + ':' + '{num:02d}'.format(num=minute)


now = datetime.datetime.now()
r = requests.get('http://swacamp.org/schedule/program.json')

minute = now.minute
#timeToLookFor = calculateTimeToLookForInSchedule(now)
dateToLookFor = str(datetime.date.today())
timeToLookFor="10:30"


json = r.json()
forDay = filter(lambda x: x['date'] == dateToLookFor, json)
forTime = filter(lambda x: x['time'] == timeToLookFor, forDay)

print dateToLookFor + " " + timeToLookFor + ": found:" + str(forTime)<commit_msg>Update to final script used at SwaCamp 2017<commit_after>import requests
import datetime
from urllib import quote

def calculateTimeToLookForInSchedule(date):
    minute = date.minute
    hour = date.hour
    if minute == 0:
        return formatTime(hour, 0)
    elif minute > 30:
        return formatTime(hour + 1, 0)
    else:
        return formatTime(hour, 30)


def sendNotificationToSlackFor(entries, day, time):
    text = reduce(lambda x, y: x + '\n' + y,
                  map(lambda x: x['loc'][0] + ": " + x['title'], entries)
                  )
    text = "@channel *Now starting " + day + " " + time + "*\n" + text
    r = requests.post('$$$ADD_URL$$$',
                      data='{"text":"' + text.encode('utf-8') + '"}')


def formatTime(hour, minute):
    return '{num:02d}'.format(num=hour) + ':' + '{num:02d}'.format(num=minute)


now = datetime.datetime.now()
r = requests.get('https://raw.githubusercontent.com/swacamp/web/gh-pages/schedule/program.json')

minute = now.minute
timeToLookFor = calculateTimeToLookForInSchedule(now)
#timeToLookFor="15:00"
dateToLookFor = str(datetime.date.today())
json = r.json()
forDay = filter(lambda x: x['date'] == dateToLookFor, json)
forTime = filter(lambda x: x['time'] == timeToLookFor, forDay)

print forDay
print forTime
if len(forTime) > 0:
    sendNotificationToSlackFor(forTime, dateToLookFor, timeToLookFor)

{'fraction_non_alphanumeric': 0.155284242655475, 'fraction_numerical': 0.018695154521175122, 'mean_word_length': 3.482051282051282, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 2, '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': '4006964', 'n_tokens_mistral': 926, 'n_tokens_neox': 878, 'n_words': 190}