mirror of
https://github.com/gsi-upm/senpy
synced 2025-08-23 18:12:20 +00:00
Added Model string representation
This should help with performance issues with models that have large private variables.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
0.7.0-dev1
|
0.7.0-dev2
|
||||||
|
@@ -147,6 +147,9 @@ class SenpyMixin(object):
|
|||||||
obj = obj.jsonld()
|
obj = obj.jsonld()
|
||||||
jsonschema.validate(obj, self.schema)
|
jsonschema.validate(obj, self.schema)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.to_JSON())
|
||||||
|
|
||||||
|
|
||||||
class SenpyModel(SenpyMixin, dict):
|
class SenpyModel(SenpyMixin, dict):
|
||||||
|
|
||||||
@@ -198,7 +201,8 @@ class SenpyModel(SenpyMixin, dict):
|
|||||||
|
|
||||||
def _plain_dict(self):
|
def _plain_dict(self):
|
||||||
d = {k: v for (k, v) in self.items() if k[0] != "_"}
|
d = {k: v for (k, v) in self.items() if k[0] != "_"}
|
||||||
d["@id"] = d.pop('id')
|
if 'id' in d:
|
||||||
|
d["@id"] = d.pop('id')
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
@@ -100,5 +100,16 @@ class ModelsTest(TestCase):
|
|||||||
logging.debug(c)
|
logging.debug(c)
|
||||||
p.validate()
|
p.validate()
|
||||||
|
|
||||||
|
def test_str(self):
|
||||||
|
"""The string representation shouldn't include private variables"""
|
||||||
|
r = Results()
|
||||||
|
p = SenpyPlugin({"name": "STR test", "version": 0})
|
||||||
|
p._testing = 0
|
||||||
|
s = str(p)
|
||||||
|
assert "_testing" not in s
|
||||||
|
r.analysis.append(p)
|
||||||
|
s = str(r)
|
||||||
|
assert "_testing" not in s
|
||||||
|
|
||||||
def test_frame_response(self):
|
def test_frame_response(self):
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user