Ejemplo n.º 1
0
    def setUp(self):
        idd_string = """
    !IDD_Version 13.9.0
    !IDD_BUILD abcdef1018
    \group MyGroup
    Version,
      A1;  \\field VersionID

    MyObject,
           \\min-fields 5
      A1,  \\field Name
           \\required-field
      A2,  \\field Zone Name
           \\required-field
      N1,  \\field A
           \\required-field
           \\units m
      N2,  \\field B
           \\required-field
      N3;  \\field C
           \\default 0.8
           \\required-field
            """
        self.idd_structure = IDDProcessor().process_file_via_string(idd_string)
        self.idd_object = self.idd_structure.get_object_by_type('MyObject')
Ejemplo n.º 2
0
 def test_missing_version(self):
     idd_string = """
     !IDD_BUILD abcdef0111
     \group MyGroup
     MyObject,
       N1;  \\field NumericFieldA
     """
     with self.assertRaises(ProcessingException):
         IDDProcessor().process_file_via_string(idd_string)
Ejemplo n.º 3
0
 def test_missing_build(self):
     idd_string = """
     !IDD_Version 1.2.0
     \group MyGroup
     MyObject,
       N1;  \\field NumericFieldA
     """
     with self.assertRaises(ProcessingException):
         IDDProcessor().process_file_via_string(idd_string)
Ejemplo n.º 4
0
 def test_bad_non_numeric_metadata(self):
     idd_string = """
     !IDD_Version 122.6.0
     !IDD_BUILD abcdef1000
     \group MyGroup
     MyObject,
       \\min-fields Q
       N1;  \\field NumericFieldA
     """
     with self.assertRaises(ProcessingException):
         IDDProcessor().process_file_via_string(idd_string)
Ejemplo n.º 5
0
 def test_rewriting_idf(self):
     idf_path = os.path.join(self.support_file_dir, "1ZoneEvapCooler.idf")
     idf_processor = IDFProcessor()
     idf_structure = idf_processor.process_file_given_file_path(idf_path)
     self.assertEquals(80, len(idf_structure.objects))
     idd_path = os.path.join(self.support_file_dir, "Energy+.idd")
     idd_processor = IDDProcessor()
     idd_structure = idd_processor.process_file_given_file_path(idd_path)
     out_idf_file_path = tempfile.mktemp(suffix=".idf")
     # print("Writing new idf to: " + out_idf_file_path)
     idf_structure.write_idf(out_idf_file_path, idd_structure)
Ejemplo n.º 6
0
    def test_invalid_idd_obj_lookup(self):
        idd_object = """
!IDD_Version 1.2.0
!IDD_BUILD abcdef0100
\\group Stuff
Version,A1;
"""
        processor = IDDProcessor()
        ret_value = processor.process_file_via_stream(
            StringIO.StringIO(idd_object))
        bad_obj = ret_value.get_object_by_type("noObjecT")
        self.assertIsNone(bad_obj)
Ejemplo n.º 7
0
    def setUp(self):
        idd_string = """
    !IDD_Version 87.11.0
    !IDD_BUILD abcdef1011
    \group MyGroup
    Version,
      A1;  \\field VersionID

    ObjectU,
      A1;  \\field My field name
            """
        self.idd_structure = IDDProcessor().process_file_via_string(idd_string)
Ejemplo n.º 8
0
    def test_single_line_obj_lookup(self):
        idd_object = """
!IDD_Version 1.2.0
!IDD_BUILD abcdef0011
Simulation Input;
\\group Stuff
Version,A1;
"""
        processor = IDDProcessor()
        ret_value = processor.process_file_via_stream(
            StringIO.StringIO(idd_object))
        bad_obj = ret_value.get_object_by_type("simulation input")
        self.assertTrue(bad_obj)
Ejemplo n.º 9
0
 def test_invalid_idd_metadata(self):
     idd_string = """
     !IDD_Version 1.2.0
     !IDD_BUILD abcdef0110
     \group MyGroup
     MyObject,
       N1,  \\field NumericFieldA
       N2;  \\field NumericFieldB
            \\autosizQble
             """
     with self.assertRaises(ProcessingException):
         IDDProcessor().process_file_via_string(
             idd_string).get_object_by_type('MyObject')
Ejemplo n.º 10
0
 def test_valid_single_token_object_with_idd(self):
     idd_string = """
     !IDD_Version 1.2.0
     !IDD_BUILD abcdef1001
     \group MyGroup
     SingleLineObject;"""
     idd_object = IDDProcessor().process_file_via_string(
         idd_string).get_object_by_type('SingleLineObject')
     tokens = ["SingleLineObject"]
     obj = IDFObject(tokens)
     self.assertEquals("SingleLineObject", obj.object_name)
     self.assertEquals(0, len(obj.fields))
     s = obj.object_string(idd_object)
     self.assertEquals("SingleLineObject;\n", s)
Ejemplo n.º 11
0
    def test_single_line_validation(self):
        idd_string = """
        !IDD_Version 56.1.0
        !IDD_BUILD abcdef1011
        \group MyGroup
        Version,
        A1; \\field VersionID

        Object;"""
        idd_object = IDDProcessor().process_file_via_string(
            idd_string).get_object_by_type('Object')
        idf_string = "Version,23.1;Object;"
        idf_object = IDFProcessor().process_file_via_string(
            idf_string).get_idf_objects_by_type('Object')[0]
        issues = idf_object.validate(idd_object)
        self.assertEqual(len(issues), 0)
Ejemplo n.º 12
0
    def setUp(self):
        idd_string = """
!IDD_Version 8.1.0
!IDD_BUILD abcdef1011
\group MyGroup
Version,
  A1;  \\field VersionID

ObjectU,
  \\unique-object
  \\required-object
  N1;  \\field NumericFieldA

OtherObject,
  N1;  \\field Again
        """
        self.idd_structure = IDDProcessor().process_file_via_string(idd_string)
Ejemplo n.º 13
0
    def test_proper_idd_indented(self):
        idd_object = """
    !IDD_Version 1.2.0
    !IDD_BUILD abcdef0001
    \\group Simulation Parameters

    Version,
          \\memo Specifies the EnergyPlus version of the IDF file.
          \\unique-object
          \format singleLine
      A1 ; \\field Version Identifier
          \\default 8.6
    """
        processor = IDDProcessor()
        ret_value = processor.process_file_via_stream(
            StringIO.StringIO(idd_object))
        self.assertEquals(1, len(ret_value.groups))
        self.assertEquals(1, len(ret_value.groups[0].objects))
Ejemplo n.º 14
0
    def test_new_reference_class_name(self):
        idd_object = """
!IDD_Version 0.1.4
!IDD_BUILD abcded0810
\\group Simulation Parameters
NewObject,
  A1;  \\field Name
       \\required-field
       \\type alpha
       \\reference-class-name validBranchEquipmentTypes
       \\reference validBranchEquipmentNames
        """
        processor = IDDProcessor()
        ret_value = processor.process_file_via_stream(
            StringIO.StringIO(idd_object))
        self.assertEquals(1, len(ret_value.groups))
        self.assertEquals(1, len(ret_value.groups[0].objects))
        version_obj = ret_value.get_object_by_type("NewObject")
        self.assertEquals(1, len(version_obj.fields))
Ejemplo n.º 15
0
    def test_repeated_object_meta_idd(self):
        idd_object = """
!IDD_Version 0.1.0
!IDD_BUILD abcdef0010
\\group Simulation Parameters

Version,
      \\memo Specifies the EnergyPlus version of the IDF file.
      \\memo Some additional memo line
      \\unique-object
      \\format singleLine
  A1 ; \\field Version Identifier
      \\default 8.6

"""
        processor = IDDProcessor()
        ret_value = processor.process_file_via_stream(
            StringIO.StringIO(idd_object))
        self.assertEquals(1, len(ret_value.groups))
        self.assertEquals(1, len(ret_value.groups[0].objects))
        version_obj = ret_value.get_object_by_type("version")
        self.assertEquals(1, len(version_obj.fields))
Ejemplo n.º 16
0
    def setUp(self):
        idd_string = """
!IDD_Version 12.9.0
!IDD_BUILD abcdef1010
\group MyGroup
Version,
  A1;  \\field VersionID

MyObject,
  N1,  \\field NumericFieldA
       \\minimum 0
       \\maximum 2
       \\required-field
  N2,  \\field NumericFieldB
       \\minimum> 0
       \\maximum< 2
       \\autosizable
  N3;  \\field NumericFieldB
       \\minimum> 0
       \\maximum< 2
       \\autocalculatable
        """
        self.idd_structure = IDDProcessor().process_file_via_string(idd_string)
        self.idd_object = self.idd_structure.get_object_by_type('MyObject')
from pyiddidf.idd_processor import IDDProcessor

file_path = '/home/edwin/Projects/energyplus/repos/4eplus/idd/V8-9-0-Energy+.idd'

idd_processor = IDDProcessor().process_file_given_file_path(file_path)
object_names = []
first_letters = set()
for group in idd_processor.groups:
    for object in group.objects:
        object_names.append(object.name)
        first_letters.add(object.name[0].upper())
found_letters_set = first_letters
full_alphabet_set = set(
    [chr(i).upper() for i in range(ord('a'),
                                   ord('z') + 1)])
missing_letters = full_alphabet_set - found_letters_set
sorted(missing_letters)
print(missing_letters)
Ejemplo n.º 18
0
 def test_valid_idd(self):  # pragma: no cover
     cur_dir = os.path.dirname(os.path.realpath(__file__))
     idd_path = os.path.join(cur_dir, "..", "support_files", "Energy+.idd")
     processor = IDDProcessor()
     ret_value = processor.process_file_given_file_path(idd_path)
     self.assertEquals(57, len(ret_value.groups))