pyifc.compress
Compress and pack .ifc files.
- exception pyifc.compress.FileExtensionError
Raised when extension of the file is not correct.
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- pyifc.compress.compress(input_filepath, output_dir, output_filename)
Compress ifc file and return path to the compressed file.
The core of the algorithm is toposort_flatten function which allows to sort topologically instances from the ifc file. Two dictionaries are used to store data from file: dict_map_instance and dict_info_id.
The first step is to check if info of the instance is in dict_info_id. If so, the dictionary of mapped instances is used dict_map_instance. Instance is mapped to another instance that appeared earlier. In this way, the instances will not be duplicated.
If the instance with given attrs did not appeared earlier, the instance and its info is added to dict_info_id and added to new ifc file with attrs obtained with map_references_to_instances function which recursively traverse attrs of the instance.
- Parameters
input_filepath (str) – path to ifc file to be compressed.
output_dir (str) – path to output directory, where compressed file will be saved.
output_filename (str) – filename with ‘.ifc’ extension.
- Returns
path to the compressed file.
- Return type
str
- pyifc.compress.compress_and_tar(input_filepath, output_dir, output_filename)
Compress and write file to .tar.gz archive.
- Parameters
input_filepath (str) – path to the .ifc file to be compressed and archived.
output_dir (str) – path to the output directory, where archived file will be saved.
output_filename (str) – filename with .tar.gz extension.
- Returns
path to the archived file.
- Return type
str
- pyifc.compress.compress_and_zip(input_filepath, output_dir, output_filename)
Compress and write file to .zip archive.
- Parameters
input_filepath (str) – path to the .ifc file to be compressed and archived.
output_dir (str) – path to the output directory, where archived file will be saved.
output_filename (str) – filename with .zip extension.
- Returns
path to the archived file.
- Return type
str
- pyifc.compress.existence_validator(path)
Validate whether the path exists.
- Parameters
path (str) – path to be checked.
- Raises
FileNotFoundError – if path does not exist.
- pyifc.compress.extension_validator(filepath, extension, variable)
Validate whether the filepath has correct extension.
- Parameters
filepath (str) – path to file to be checked.
extension (str) – extension that file should have.
variable (str) – name of variable of filepath.
- Raises
FileExtensionError – if filen does not have extension extension.