Execute the parse expression on the given file or filename. If a filename is specified (instead of a file object), the entire file is opened, read, and closed before parsing.
( self, file_or_filename, parseAll=False )
| 2348 | self.checkRecursion( [] ) |
| 2349 | |
| 2350 | def parseFile( self, file_or_filename, parseAll=False ): |
| 2351 | """ |
| 2352 | Execute the parse expression on the given file or filename. |
| 2353 | If a filename is specified (instead of a file object), |
| 2354 | the entire file is opened, read, and closed before parsing. |
| 2355 | """ |
| 2356 | try: |
| 2357 | file_contents = file_or_filename.read() |
| 2358 | except AttributeError: |
| 2359 | with open(file_or_filename, "r") as f: |
| 2360 | file_contents = f.read() |
| 2361 | try: |
| 2362 | return self.parseString(file_contents, parseAll) |
| 2363 | except ParseBaseException as exc: |
| 2364 | if ParserElement.verbose_stacktrace: |
| 2365 | raise |
| 2366 | else: |
| 2367 | # catch and re-raise exception from here, clears out pyparsing internal stack trace |
| 2368 | raise exc |
| 2369 | |
| 2370 | def __eq__(self,other): |
| 2371 | if isinstance(other, ParserElement): |
nothing calls this directly
no test coverage detected