<gh_stars>1-10
import os
import json

class Resource:
    def __init__(self, path):
        self.path = path
        self.content = None
        self.default = None

        self.load()

    def check(self):
        return (os.path.isfile(self.path))

    def load(self):
        print("[wait] loading {}".format(self.path))
        if (self.check() == True):
            with open(self.path, 'r') as f:
                self.content = json.load(f)
                if (self.default == None):
                    self.default = self.content
            print("[done] {} loaded".format(self.path))
        else:
            print("[fail] '{}' file not found".format(self.path))

    def save(self, content):
        print("[wait] saving {}".format(self.path))
        with open(self.path, 'w+') as f:
            json.dump(content, f)
        print("[done] '{}' saved".format(self.path))

    def restore(self):
        print("\n[wait] restoring {}".format(self.path))
        with open(self.path, 'w+') as f:
            json.dump(self.default, f)
        print("[done] '{}' restored".format(self.path))

class Resources:
    def __init__(self):
        self.hosts = Resource("resources/hosts")
        self.proxies = Resource("resources/proxies")
        self.profile = Resource("resources/profile")
