Пример #1
0
    def is_cached(self):
        import os
        from kodiwrapper import KodiWrapper

        path = KodiWrapper.get_addon_data_path()

        if not os.path.isfile(os.path.join(path, self.EPG_CACHE_FILE_NAME)):
            return False
        return True
def get_from_cache(key):
    import json
    import os
    from kodiwrapper import KodiWrapper

    path = KodiWrapper.get_addon_data_path()

    with open(os.path.join(path, CACHE_FILE_NAME), "r") as json_file:
        data = json.load(json_file)

    return data.get(key)
def is_in_cache(key):
    import json
    import os
    from kodiwrapper import KodiWrapper

    path = KodiWrapper.get_addon_data_path()

    if not os.path.isfile(os.path.join(path, CACHE_FILE_NAME)):
        return False

    with open(os.path.join(path, CACHE_FILE_NAME), "r") as json_file:
        data = json.load(json_file)

    return key in data
Пример #4
0
    def get_from_cache(cls):
        import json
        import os
        from kodiwrapper import KodiWrapper

        path = KodiWrapper.get_addon_data_path()

        try:
            with open(os.path.join(path, cls.EPG_CACHE_FILE_NAME),
                      "r") as json_file:
                data = json.load(json_file)
                return data

        except IOError:
            return {}
def cache_to_file(json_data):
    import json
    import os
    from kodiwrapper import KodiWrapper

    path = KodiWrapper.get_addon_data_path()

    if not os.path.exists(path):
        os.mkdir(path, 0o775)

    data = {}
    if os.path.isfile(os.path.join(path, CACHE_FILE_NAME)):
        with open(os.path.join(path, CACHE_FILE_NAME), "r") as json_file:
            data = json.load(json_file)

    data.update(json_data)

    with open(os.path.join(path, CACHE_FILE_NAME), "w") as json_file:
        json.dump(data, json_file)