def list()

in source/api/chalicelib/efs_lambda.py [0:0]


def list(event):
    # get path to list
    try:
        path = event['path']
    except KeyError:
        raise Exception('Missing required parameter in event: "path"')

    try:
        # TODO: Mucchhhh better thinking around listing directories
        dir_items = []
        file_items = []
        for (dirpath, dirnames, filenames) in walk(path):
            dir_items.extend(dirnames)
            file_items.extend(filenames)
            break
    # TODO: narrower exception scope and proper debug output
    except Exception as error:
        print(error)
        raise Exception(error)
    else:
        return {"path": path, "directiories": dir_items, "files": file_items, "statusCode": 200}