Locator for use with the ExpatParser class. This uses a weak reference to the parser object to avoid creating a circular reference between the parser and the content handler.
| 41 | # --- ExpatLocator |
| 42 | |
| 43 | class ExpatLocator(xmlreader.Locator): |
| 44 | """Locator for use with the ExpatParser class. |
| 45 | |
| 46 | This uses a weak reference to the parser object to avoid creating |
| 47 | a circular reference between the parser and the content handler. |
| 48 | """ |
| 49 | def __init__(self, parser): |
| 50 | self._ref = _mkproxy(parser) |
| 51 | |
| 52 | def getColumnNumber(self): |
| 53 | parser = self._ref |
| 54 | if parser._parser is None: |
| 55 | return None |
| 56 | return parser._parser.ErrorColumnNumber |
| 57 | |
| 58 | def getLineNumber(self): |
| 59 | parser = self._ref |
| 60 | if parser._parser is None: |
| 61 | return 1 |
| 62 | return parser._parser.ErrorLineNumber |
| 63 | |
| 64 | def getPublicId(self): |
| 65 | parser = self._ref |
| 66 | if parser is None: |
| 67 | return None |
| 68 | return parser._source.getPublicId() |
| 69 | |
| 70 | def getSystemId(self): |
| 71 | parser = self._ref |
| 72 | if parser is None: |
| 73 | return None |
| 74 | return parser._source.getSystemId() |
| 75 | |
| 76 | |
| 77 | # --- ExpatParser |
no outgoing calls
no test coverage detected
searching dependent graphs…