diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-06-19 11:24:00 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-06-19 11:24:00 -0400 |
commit | 869934179f21858b10d4de60d11d3644afcfad74 (patch) | |
tree | 071cfc8f44fbb5048404acf2ccec198f11399274 /src/lib/Bcfg2/Server/Plugins/Probes.py | |
parent | e3131034dd00c61ed5ca4f6a38f74250f0ac5726 (diff) | |
parent | 16a38827b5bb374da6caaf103f9363a45262f745 (diff) | |
download | bcfg2-869934179f21858b10d4de60d11d3644afcfad74.tar.gz bcfg2-869934179f21858b10d4de60d11d3644afcfad74.tar.bz2 bcfg2-869934179f21858b10d4de60d11d3644afcfad74.zip |
merged maint
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Probes.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Probes.py | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index 042146aa7..8ef6c8737 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -41,56 +41,25 @@ class ClientProbeDataSet(dict): dict.__init__(self, *args, **kwargs) -class ProbeData(object): +class ProbeData(str): """ a ProbeData object emulates a str object, but also has .xdata and .json properties to provide convenient ways to use ProbeData objects as XML or JSON data """ + def __new__(cls, data): + return str.__new__(cls, data) + def __init__(self, data): - self.data = data + str.__init__(self) self._xdata = None self._json = None self._yaml = None - def __str__(self): - return str(self.data) - - def __repr__(self): - return repr(self.data) - - def __getattr__(self, name): - """ make ProbeData act like a str object """ - return getattr(self.data, name) - - def __complex__(self): - return complex(self.data) - - def __int__(self): - return int(self.data) - - def __long__(self): - return long(self.data) - - def __float__(self): - return float(self.data) - - def __eq__(self, other): - return str(self) == str(other) - - def __ne__(self, other): - return str(self) != str(other) - - def __gt__(self, other): - return str(self) > str(other) - - def __lt__(self, other): - return str(self) < str(other) - - def __ge__(self, other): - return self > other or self == other - - def __le__(self, other): - return self < other or self == other - + @property + def data(self): + """ provide backwards compatibility with broken ProbeData + object in bcfg2 1.2.0 thru 1.2.2 """ + return str(self) + @property def xdata(self): if self._xdata is None: |