def load_data(data_file, key_name = None, local_file = False, format = 'json'):
    """
    Load a JSON data file

    :param data_file:
    :param key_name:
    :param local_file:
    :return:
    """
    if local_file:
        if data_file.startswith('/'):
            src_file = data_file
        else:
            src_dir = os.getcwd()
            src_file = os.path.join(src_dir, data_file)
    else:
        src_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data')
        if not os.path.isdir(src_dir):
            src_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../data')
        src_file = os.path.join(src_dir, data_file)
    with open(src_file) as f:
        if format == 'json':
            data = json.load(f)
        elif format == 'yaml':
            data = yaml.load(f)
        elif format not in ['json', 'yaml'] and not key_name:
            data = f.read()
        else:
            printError('Error, argument \'key_name\' may not be used with data in %s format.' % format)
            return None
    if key_name:
        data = data[key_name]
    return data
Load a JSON data file

    :param data_file:
    :param key_name:
    :param local_file:
    :return: