import logging
import json


def is_newformat(filename):
    """
    Check if app is new format (with FolderDefinition as top object)
    :param filename
    :return: True if new format, throws exception otherwise
    """
    with open(filename, 'r') as mf:
        logging.info("Reading file: " + filename)
        content_obj = json.load(mf)
        if ((not ('type' in content_obj)) or not (
                content_obj['type'] == "FolderSyncDefinition" or content_obj['type'] == "Folder")):
            raise Exception("Invalid app file format")
        else:
            if content_obj['type'] == "FolderSyncDefinition":
                return True
            else:
                return False