/usr/share/pyshared/rope/base/prefs.py is in python-rope 0.9.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | class Prefs(object):
def __init__(self):
self.prefs = {}
self.callbacks = {}
def set(self, key, value):
"""Set the value of `key` preference to `value`."""
if key in self.callbacks:
self.callbacks[key](value)
else:
self.prefs[key] = value
def add(self, key, value):
"""Add an entry to a list preference
Add `value` to the list of entries for the `key` preference.
"""
if not key in self.prefs:
self.prefs[key] = []
self.prefs[key].append(value)
def get(self, key, default=None):
"""Get the value of the key preference"""
return self.prefs.get(key, default)
def add_callback(self, key, callback):
"""Add `key` preference with `callback` function
Whenever `key` is set the callback is called with the
given `value` as parameter.
"""
self.callbacks[key] = callback
def __setitem__(self, key, value):
self.set(key, value)
def __getitem__(self, key):
return self.get(key)
|