<commit_before>import logging
import json
import os
import boto3

dynamodb = boto3.resource('dynamodb')

def build_response(message):
    return {
        "dialogAction":  {
            "type": "Close",
            "fulfillmentState": "Fulfilled",
            "message": {
                    "contentType": "PlainText",
                    "content": message
            }
        }
    }

def get_office_hours(event, context):
    #debug print for lex event data
    print(event)
    table    = dynamodb.Table(os.environ['DYNAMODB_TABLE'])
    team     = event['currentIntent']['slots']['GetTeam']

    try:
        response = table.get_item(
            Key={
                'team': team
            }
        )
    except ClientError as e:
        print(e.response['Error']['Message'])
    else:
        item = response['Item']
        print("GetItem succeeded:")
        return build_response("""{0} is holding office hours on {1} at {2}.
            Office hours starts at {3} and ends at {4}""".format(
                team, item['day'],
                item['OfficeHoursLocation'], item['SetOfficeHoursStart'],
                item['SetOfficeHoursEnd']))<commit_msg>Add a response if office hours for a team not set (#3)<commit_after>import logging
import json
import os
import boto3

dynamodb = boto3.resource('dynamodb')

def build_response(message):
    return {
        "dialogAction":  {
            "type": "Close",
            "fulfillmentState": "Fulfilled",
            "message": {
                    "contentType": "PlainText",
                    "content": message
            }
        }
    }

def get_office_hours(event, context):
    #debug print for lex event data
    print(event)
    table    = dynamodb.Table(os.environ['DYNAMODB_TABLE'])
    team     = event['currentIntent']['slots']['GetTeam']

    try:
        response = table.get_item(
            Key={
                'team': team
            }
        )
    except ClientError as e:
        print(e.response['Error']['Message'])
    else:
        try:
            item = response['Item']
            print("GetItem succeeded:")
        except KeyError as e:
            print(e)
            print("GetItem item not found:")
            return build_response("Office hours not set for this team presently")
        else:
            return build_response("""{0} is holding office hours on {1} at {2}.
                Office hours starts at {3} and ends at {4}""".format(
                team,
                item['day'],
                item['OfficeHoursLocation'],
                item['SetOfficeHoursStart'],
                item['SetOfficeHoursEnd']))
{'fraction_non_alphanumeric': 0.11989409984871408, 'fraction_numerical': 0.0056732223903177, 'mean_word_length': 1.8379828326180256, 'pattern_counts': {'":': 12, '<': 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': '4302319', 'n_tokens_mistral': 755, 'n_tokens_neox': 714, 'n_words': 184}