python: ConfigInfo: return None from constructor if not available.

This commit is contained in:
Martin Ling 2013-12-17 13:01:11 +00:00
parent 8593c8e30d
commit 14e8eb3353
1 changed files with 8 additions and 3 deletions

View File

@ -525,9 +525,14 @@ class Output(object):
class ConfigInfo(object):
def __init__(self, key):
self.key = key
self.struct = sr_config_info_get(key.id)
def __new__(cls, key):
struct = sr_config_info_get(key.id)
if not struct:
return None
obj = super(ConfigInfo, cls).__new__(cls)
obj.key = key
obj.struct = struct
return obj
@property
def datatype(self):