IDF Object Module Documentation¶
- class pyiddidf.idf_objects.IDFObject(tokens, comment_blob=False)
Bases:
object
This class defines a single IDF object. An IDF object is either a comma/semicolon delimited list of actual object data, or a block of line delimited comments. Blocks of comment lines are treated as IDF objects so they can be intelligently written back out to a new IDF file after transition in the same location.
Relevant members are listed here:
- Variables
object_name (str) – IDD Type, or name, of this object
fields ([str]) – A list of strings, one per field, found for this object in the IDF file
Constructor parameters:
- Parameters
tokens ([str]) – A list of tokens defining this idf object, the first token in the list is the object type.
comment_blob (bool) – A signal that this list is comment data, and not an actual IDF object; default is False. indicating it is meaningful IDF data.
- object_string(idd_object=None)
This function creates an intelligently formed IDF object. If the current instance is comment data, it simply writes the comment block out, line delimited, otherwise it writes out proper IDF syntax. If the matching IDD object is passed in as an argument, the field names are matched from that to create a properly commented IDF object.
- Parameters
idd_object (IDDObject) – The IDDObject structure that matches this IDFObject
- Returns
A string representation of the IDF object or comment block
- validate(idd_object)
This function validates the current IDF object instance against standard IDD field tags such as minimum and maximum, etc.
- Parameters
idd_object (IDDObject) – The IDDObject structure that matches this IDFObject
- Returns
A list of ValidationIssue instances, each describing an issue encountered
- write_object(file_object)
This function simply writes out the idf string to a file object
- Parameters
file_object – A file-type object that responds to a write command
- Returns
None
- class pyiddidf.idf_objects.IDFStructure(file_path)
Bases:
object
An IDF structure representation. This includes containing all the IDF objects in the file, as well as meta data such as the version ID for this IDD, and finally providing worker functions for accessing the IDD data
Relevant “public” members are listed here:
- Variables
file_path (str) – The path given when instantiating this IDF, not necessarily an actual path
version_float (float) – The floating point representation of the version of this IDD (for 8.6.0 it is 8.6)
objects ([IDFObject]) – A list of all IDF objects found in the IDF
Constructor parameters:
- Parameters
file_path (str) – A file path for this IDF; not necessarily a valid path as it is never used, just available for bookkeeping purposes.
- get_idf_objects_by_type(type_to_get)
This function returns all objects of a given type found in this IDF structure instance
- Parameters
type_to_get (str) – A case-insensitive object type to retrieve
- Returns
A list of all objects of the given type
- global_swap(dict_of_swaps)
- validate(idd_structure)
This function validates the current IDF structure instance against standard IDD object tags such as required and unique objects.
- Parameters
idd_structure – An IDDStructure instance representing an entire IDD file
- Returns
A list of ValidationIssue instances, each describing an issue encountered
- whole_idf_string(idd_structure=None)
This function returns a string representation of the entire IDF contents. If the idd structure argument is passed in, it is passed along to object worker functions in order to generate an intelligent representation.
- Parameters
idd_structure (IDDStructure) – An optional IDDStructure instance representing an entire IDD file
- Returns
A string of the entire IDF contents, ready to write to a file
- write_idf(idf_path, idd_structure=None)
This function writes the entire IDF contents to a file. If the idd structure argument is passed in, it is passed along to object worker functions in order to generate an intelligent representation.
- Parameters
idf_path (str) – The path to the file to write
idd_structure (IDDStructure) – An optional IDDStructure instance representing an entire IDD file
- Returns
None
- class pyiddidf.idf_objects.ValidationIssue(object_name, severity, message, field_name=None)
Bases:
object
This class stores information about any issue that occurred when reading an IDF file.
- Parameters
object_name (str) – The object type that was being validated when this issue arose
severity (int) – The severity of this issue, from the class constants
message (str) – A descriptive message for this issue
field_name (str) – The field name that was being validated when this issue arose, if available.
- ERROR = 2
- INFORMATION = 0
- WARNING = 1
- static severity_string(severity_integer)
Returns a string version of the severity of this issue
- Parameters
severity_integer (int) – One of the constants defined in this class (INFORMATION, etc.)
- Returns
A string representation of the severity