Create a message structure from the data in a binary file. Reads all the data from the file and returns the root of the message structure. Optional headersonly is a flag specifying whether to stop parsing after reading the headers or not. The default is False, mean
(self, fp, headersonly=False)
| 93 | self.parser = Parser(*args, **kw) |
| 94 | |
| 95 | def parse(self, fp, headersonly=False): |
| 96 | """Create a message structure from the data in a binary file. |
| 97 | |
| 98 | Reads all the data from the file and returns the root of the message |
| 99 | structure. Optional headersonly is a flag specifying whether to stop |
| 100 | parsing after reading the headers or not. The default is False, |
| 101 | meaning it parses the entire contents of the file. |
| 102 | """ |
| 103 | fp = TextIOWrapper(fp, encoding='ascii', errors='surrogateescape') |
| 104 | try: |
| 105 | return self.parser.parse(fp, headersonly) |
| 106 | finally: |
| 107 | fp.detach() |
| 108 | |
| 109 | |
| 110 | def parsebytes(self, text, headersonly=False): |
nothing calls this directly
no test coverage detected