""" Created on Mar 23, 2017 @author: jvazquez """ from helix.constants.file_validation_error import FileValidationMessage from helix.models.dxf.dxf_error import OldDxfFormatException class DXFLayerValidator(object): """ In 2017, Aurora changed the format of their DXF files to meet new specifications. The old-style DXF files will not be supported, and this class will screen for old files. Most noticably, old files used "Roofs" section headers while new files use "Buildings" """ def __init__(self): self.layers = set() self.new_aurora_format = False def add_layer(self, layer): """Add a layer in a set param layer (string) """ self.layers.add(layer) def determine_file(self): """Based on the layers of the dxf, we will determine if is a "new" file format or is the "old" format. Bare in mind that we are assuming this based on an assumption. There's no drastic visible difference in the files if you inspect them with a text editor. The whole difference comes from the space in the panels. The width remains the same, but there is a gap in the middle in the new format. At this moment, this is the simplest format we know on how to determine this. """ try: assert "Buildings" in self.layers and "Roofs" not in self.layers self.new_aurora_format = True except AssertionError: error = FileValidationMessage.OldDxfFormat.value raise OldDxfFormatException(error) def is_new_aurora_format(self): """ return boolean """ return self.new_aurora_format