IDF Processor Module Documentation¶
- class pyiddidf.idf_processor.IDFProcessor
Bases:
object
The core IDF Processor class. Given an IDF via stream or path, this class has workers to robustly process the IDF into a rich IDFStructure instance.
The constructor takes no arguments but sets up instance variables. Relevant “public” members are listed here:
- Variables
idf (IDFStructure) – The resulting IDFStructure instance after processing the IDF file/stream
file_path (str) – A file path for this IDF, although it may be just a simple descriptor
- process_file()
Internal worker function that reads the IDF stream, whether it was constructed from a file path, stream or string. This processor then processes the file line by line looking for IDF objects and comment blocks, and parsing them into a meaningful structure
- Returns
An IDF structure describing the IDF contents
- Raises
ProcessingException – for any issues encountered during the processing of the idf
- process_file_given_file_path(file_path)
This worker allows processing of an IDF file at a specific path on disk.
- Parameters
file_path – The path to an IDF file on disk.
- Returns
An IDFStructure instance created from processing the IDF file
- Raises
ProcessingException – if the specified file does not exist
- process_file_via_stream(idf_file_stream)
This worker allows processing of an IDF snippet via stream. Most useful for unit testing, but possibly for other situations.
- Parameters
idf_file_stream (file-like-object) – An IDF snippet that responds to typical file-like commands such as read(). A common object would be the StringIO object.
- Returns
An IDFStructure instance created from processing the IDF snippet
- process_file_via_string(idf_string)
This worker allows processing of an IDF snippet string. Most useful for unit testing, but possibly for other situations.
- Parameters
idf_string (str) – An IDF snippet string
- Returns
An IDFStructure instance created from processing the IDF string