Skip to content

Commit

Permalink
Adds validate() inside the to_json() method
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelduchesne committed Jun 26, 2020
1 parent e3f579d commit 963b758
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions archetypal/template/building_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ def _graph_reduce(self, G):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["Core"] = self.Core.to_dict()
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/conditioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ def from_json(cls, *args, **kwargs):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/dhw.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def from_json(cls, *args, **kwargs):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/gas_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def from_json(cls, *args, **kwargs):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/glazing_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def combine(self, other, weights=None):
return new_obj

def to_json(self):
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def from_json(cls, *args, **kwargs):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/opaque_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ def _surface_layers(cls, epbunch):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/opaque_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def combine(self, other, weights=None):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def to_json(self):
used when generating the json file. Only Year-Week- and DaySchedule
classes are used
"""
self.validate() # Validate object before trying to get json format

pass

def to_dict(self):
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def from_json(cls, *args, **kwargs):
return sd

def to_json(self):
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/ventilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def from_json(cls, *args, **kwargs):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
2 changes: 2 additions & 0 deletions archetypal/template/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def from_epbunch(cls, Construction, **kwargs):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down
4 changes: 4 additions & 0 deletions archetypal/template/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ def _domestichotwater(self):
)

def to_json(self):
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down Expand Up @@ -957,6 +959,8 @@ def from_json(cls, *args, **kwargs):

def to_json(self):
"""Convert class properties to dict"""
self.validate() # Validate object before trying to get json format

data_dict = collections.OrderedDict()

data_dict["$id"] = str(self.id)
Expand Down

0 comments on commit 963b758

Please sign in to comment.