コード例 #1
0
def test_ExplicitlyFormattedLogicalRecord_eq():
    ld = LogicalData(LOGICAL_BYTES_FROM_STANDARD)
    eflr_a = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    ld.rewind()
    eflr_b = EFLR.ExplicitlyFormattedLogicalRecord(3, ld)
    assert eflr_a == eflr_b
    assert eflr_a != 1
コード例 #2
0
ファイル: EFLR.py プロジェクト: jimogaos/TotalDepth
 def __init__(self, lr_type: int, ld: LogicalData):
     self.lr_type: int = lr_type
     ld.rewind()
     self.set: Set = Set(ld)
     self.template: Template = Template()
     # This object list contains all objects not including duplicates.
     self.objects: typing.List[Object] = []
     # This is the final object name map after de-duplication depending on the de-duplication strategy.
     # TODO: Perfomance. Use self.object_name_map throughout then don't need to rebuild it if there are duplicates
     #  to remove.
     self.object_name_map: typing.Dict[RepCode.ObjectName, int] = {}
     temp_object_name_map: typing.Dict[RepCode.ObjectName, int] = {}
     dupes_to_remove: typing.List[int] = []
     if ld:
         self.template.read(ld)
         while ld:
             obj = Object(ld, self.template)
             if obj.name not in temp_object_name_map:
                 temp_object_name_map[obj.name] = len(self.objects)
                 self.objects.append(obj)
             else:
                 self._handle_duplicate_object(obj, temp_object_name_map, dupes_to_remove)
     # Clear out any duplicates then index those remaining.
     dupes_to_remove.sort()
     for i in reversed(dupes_to_remove):
         self.DUPE_OBJECT_LOGGER(f'Cleaning table by removing duplicate object:\n{self.objects[i]}')
         del self.objects[i]
     assert len(self.object_name_map) == 0
     for i, obj in enumerate(self.objects):
         self.object_name_map[obj.name] = i
     self.logical_data_consumed = ld.index
コード例 #3
0
ファイル: IFLR.py プロジェクト: jimogaos/TotalDepth
 def __init__(self, lr_type: int, ld: File.LogicalData):
     self.lr_type: int = lr_type
     ld.rewind()
     # [RP66V1 Section 3.3 Indirectly Formatted Logical Record]
     self.object_name: RepCode.ObjectName = RepCode.OBNAME(ld)
     # [RP66V1 Section 5.6.1 Frames]
     self.frame_number = RepCode.UVARI(ld)
     self.preamble_length = ld.index
     self.remain = ld.remain
     # Frame numbers start from 1 but there are many observed cases of IFLRs that have a 0 frame number and zero
     # remaining data. Here we only warn if the frame number is zero and the remaining data is non-zero.
     # We warn rather than raising in the spirit of optimism.
     if self.frame_number == 0 and self.remain != 0:
         logger.warning(
             f'Frame number needs to be >= 1, not {self.frame_number} [RP66V1 Section 5.6.1 Frames] (there is data remaining)'
         )