Example #1
0
def test_copyidfintoidf():
    """py.test for copyidfintoidf"""
    tonames = ["a", "b", "c"]
    fromnames = ["d", "e"]
    allnames = ["a", "b", "c", "d", "e"]
    toidf = IDF(StringIO(""))
    toidf.newidfobject("building".upper(), Name="a")
    toidf.newidfobject("building".upper(), Name="b")
    toidf.newidfobject("Site:Location".upper(), Name="c")
    result = idf_helpers.getidfobjectlist(toidf)
    assert [res.Name for res in result] == tonames
    fromidf = IDF(StringIO(""))
    fromidf.newidfobject("ScheduleTypeLimits".upper(), Name="d")
    fromidf.newidfobject("ScheduleTypeLimits".upper(), Name="e")
    result = idf_helpers.getidfobjectlist(fromidf)
    assert [res.Name for res in result] == fromnames
    idf_helpers.copyidfintoidf(toidf, fromidf)
    result = idf_helpers.getidfobjectlist(toidf)
    assert [res.Name for res in result] == allnames
Example #2
0
def test_getidfobjectlist():
    """py.test for getidfobjectlist"""
    names = ["a", "b", "c", "d", "e"]
    idf = IDF(StringIO(""))
    idf.newidfobject("building".upper(), Name="a")
    idf.newidfobject("building".upper(), Name="b")
    idf.newidfobject("Site:Location".upper(), Name="c")
    idf.newidfobject("ScheduleTypeLimits".upper(), Name="d")
    idf.newidfobject("ScheduleTypeLimits".upper(), Name="e")
    result = idf_helpers.getidfobjectlist(idf)
    assert [res.Name for res in result] == names
Example #3
0
    def get_all_objects(self):
        """ returns all the idf file objects

        Returns
        -------
        Iterable
            list of idf objects as dictionaries

        """
        objects = []
        for obj in getidfobjectlist(self.idf):
            one_obj = list(zip(obj.fieldnames, obj.fieldvalues))
            # TODO: prior to Python 3.6 Dicts are not ordered and cannot be forced to be
            #  alt solution :   one_obj = OrderedDict(one_obj)
            #  but we'll need to find a way to dump it into JSON for the ui to be ordered
            dict_obj = {}
            for (k, v) in one_obj:
                dict_obj[k] = v
            objects.append(dict_obj)
        return objects