diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-06-13 16:15:58 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-06-13 16:15:58 -0400 |
commit | 7480e8f11d991b75fe5ece33323734451defc7bd (patch) | |
tree | 36ef67490923b15bd3e59f051943d5bb7ca389bf /src | |
parent | f379b0e43cfa0137379ad0f78f48223eba7db61a (diff) | |
download | bcfg2-7480e8f11d991b75fe5ece33323734451defc7bd.tar.gz bcfg2-7480e8f11d991b75fe5ece33323734451defc7bd.tar.bz2 bcfg2-7480e8f11d991b75fe5ece33323734451defc7bd.zip |
fixed ProbeData object to actually be a str, not just try (and fail) to imitate one
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Plugins/Probes.py | 50 |
1 files changed, 8 insertions, 42 deletions
diff --git a/src/lib/Server/Plugins/Probes.py b/src/lib/Server/Plugins/Probes.py index 2c24d6cc4..59f7e30bd 100644 --- a/src/lib/Server/Plugins/Probes.py +++ b/src/lib/Server/Plugins/Probes.py @@ -41,56 +41,22 @@ 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 __init__(self, data): - self.data = data + str.__init__(self, data) 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: |