Esempio n. 1
0
class Config(object):
    def __init__(self, filepath):
        self.filepath = filepath
        self.config = Properties()
        with open(filepath) as file:
            self.config.load(file)

    def get_property(self, key):
        return self.config[key]

    def has_property(self, key):
        return key in self.config.propertyNames()
Esempio n. 2
0
class Config(object):
    def __init__(self, filepath):
        self.filepath = filepath
        self.config = Properties()
        with open(filepath) as file:
            self.config.load(file)

    def get_property(self, key):
        return self.config[key]

    def has_property(self, key):
        return key in self.config.propertyNames()
Esempio n. 3
0
    def __setattr__(self, name, value):
        # For each property assigned to the instance object, we write it to the
        #file, If it doesn't exist we add it.
        app_properties = Properties()
        with open(APP_PROP_FILE, "r") as app_property_file:
            app_properties.load(app_property_file)
            current_properties = app_properties.propertyNames()

        if name not in current_properties or value != app_properties.get(name):
            with open(APP_PROP_FILE, "w") as app_property_file:
                app_properties[name] = value
                app_properties.store(app_property_file)

        super(MyAppProperties, self).__setattr__(name, value)