Ejemplo n.º 1
0
        for k in self.values:
            yield k

    def get(self, key):
        return self.values[key]

    def set(self, key, value):
        self.values[key] = value
        self.save()

    __getitem__ = get
    __setitem__ = set

    def __contains__(self, key):
        """ Returns true if there is such value """
        return key in self.values


def serializer(obj):
    """ Handles serialization where json can't do it by itself """
    if hasattr(obj, "isoformat"):
        # datetime object
        return obj.isoformat()
    raise TypeError("Can't serialize object of type %s" % (type(obj), ))


Configuration = _Configuration
if IS_WINDOWS:
    from syncthing_gtk.windows import WinConfiguration
    Configuration = WinConfiguration()
Ejemplo n.º 2
0
def Configuration(*a, **b):
    if IS_WINDOWS and not is_portable():
        from syncthing_gtk.windows import WinConfiguration
        return WinConfiguration(*a, **b)
    return _Configuration(*a, **b)