Skip to content

Commit

Permalink
Merge pull request #8 from Myoldmopar/TestOrdering
Browse files Browse the repository at this point in the history
Several fix ups
  • Loading branch information
Myoldmopar authored Sep 20, 2017
2 parents 6d72665 + ed13778 commit a2c3a69
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Library Usage
=============

This page will describe the workflow for this library.
This page will describe the work flow for this library.
6 changes: 5 additions & 1 deletion pyiddidf/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
__version__ = 0.5
import idd
import idf

__version__ = 0.6
__all__ = ['idd', 'idf', 'exceptions']
3 changes: 3 additions & 0 deletions pyiddidf/idf/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ def object_string(self, idd_object=None):
else:
if len(self.fields) == 0:
s = self.object_name + ";\n"
elif '\\format' in idd_object.meta_data and 'singleLine' in idd_object.meta_data['\\format']:
field_token_string = ",".join([field for field in self.fields])
s = self.object_name + ',' + field_token_string + ';\n'
else:
idd_fields = idd_object.fields
s = self.object_name + ",\n"
Expand Down
22 changes: 22 additions & 0 deletions test/idf/test_processor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import StringIO
import os
import tempfile
import unittest

from pyiddidf.exceptions import ProcessingException
from pyiddidf.idf.processor import IDFProcessor
from pyiddidf.idd.processor import IDDProcessor


class TestIDFProcessingViaStream(unittest.TestCase):
Expand Down Expand Up @@ -138,3 +140,23 @@ def test_minimal_idf(self):
idf_structure = processor.process_file_given_file_path(idf_path)
self.assertEquals(1, len(idf_structure.objects))
self.assertAlmostEqual(idf_structure.version_float, 1.1, 1)

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)
# soon we'd like to assert that the original and the newly written are the same
# this can't be done right now primarily because the original idf is not "properly" formatted
# the 3 points of vertices on surfaces are on one line which I'm not planning to support
# similar with the schedule:compact objects
# I just need to pick a better idf file to start with

# import filecmp
# filecmp.cmp(idf_path, out_idf_file_path)

0 comments on commit a2c3a69

Please sign in to comment.