Fix descriptors

This commit is contained in:
Matt Martz 2014-04-30 09:09:37 -05:00
parent f689af0fc6
commit 3695acb020
1 changed files with 14 additions and 9 deletions

View File

@ -359,17 +359,17 @@ class HTTPUploader(threading.Thread):
class DataDescriptor(object): class DataDescriptor(object):
def __init__(self, value=None): def __init__(self, default=None):
self.value = value self.value = self.default = default
def __get__(self, instance, cls): def __get__(self, instance, cls):
return self.value return self.value
def __set__(self, value): def __set__(self, instance, value):
self.value = value self.value = value
def __delete__(self): def __delete__(self):
self.value = 0 self.value = self.default
class SpeedtestResults(object): class SpeedtestResults(object):
@ -385,13 +385,18 @@ class SpeedtestResults(object):
to get a share results image link. to get a share results image link.
""" """
download = DataDescriptor(0)
upload = DataDescriptor(0)
ping = DataDescriptor(0)
server = DataDescriptor(dict())
_share = DataDescriptor(None)
def __init__(self, download=0, upload=0, ping=0, server=dict()): def __init__(self, download=0, upload=0, ping=0, server=dict()):
self.download = DataDescriptor(download) self.download = download
self.upload = DataDescriptor(upload) self.upload = upload
self.ping = DataDescriptor(ping) self.ping = ping
self.server = DataDescriptor(server) self.server = server
self.share = DataDescriptor(None) self._share = None
def dict(self): def dict(self):
"""Return dictionary of result data""" """Return dictionary of result data"""