Changeset 19ee734 in ammosreader


Ignore:
Timestamp:
07/22/22 10:52:18 (3 years ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
AmmosSource, guix
Children:
dbcb255
Parents:
aebe4a1
Message:

return None if there is a problem when reading all frames left

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ammosreader/PPDWReader.py

    raebe4a1 r19ee734  
    1515
    1616    def read_all_frames_left(self):
    17         while self.cursor <= len(self.content) - 32:
    18             current_bytes = self.content[self.cursor:self.cursor+32]
    19             assert len(current_bytes) == 32
    20             if not current_bytes:
    21                 # print('End of file detected')
    22                 break
    23             if self.cursor + 32 >= len(self.content):
    24                 # print('Can not read all 32 bytes of next PDW')
    25                 break
    26             self.container.add(PDW.from_bytes(current_bytes))
    27             self.cursor += 32
     17        try:
     18            while self.cursor <= len(self.content) - 32:
     19                current_bytes = self.content[self.cursor:self.cursor+32]
     20                assert len(current_bytes) == 32
     21                if not current_bytes:
     22                    # print('End of file detected')
     23                    break
     24                if self.cursor + 32 >= len(self.content):
     25                    # print('Can not read all 32 bytes of next PDW')
     26                    break
     27                self.container.add(PDW.from_bytes(current_bytes))
     28                self.cursor += 32
     29        except Exception:
     30            return None
    2831        return self.container
Note: See TracChangeset for help on using the changeset viewer.