| 213 | __slots__ = '_opener', |
| 214 | |
| 215 | def resolveEntity(self, publicId, systemId): |
| 216 | assert systemId is not None |
| 217 | source = DOMInputSource() |
| 218 | source.publicId = publicId |
| 219 | source.systemId = systemId |
| 220 | source.byteStream = self._get_opener().open(systemId) |
| 221 | |
| 222 | # determine the encoding if the transport provided it |
| 223 | source.encoding = self._guess_media_encoding(source) |
| 224 | |
| 225 | # determine the base URI is we can |
| 226 | import posixpath, urllib.parse |
| 227 | parts = urllib.parse.urlparse(systemId) |
| 228 | scheme, netloc, path, params, query, fragment = parts |
| 229 | # XXX should we check the scheme here as well? |
| 230 | if path and not path.endswith("/"): |
| 231 | path = posixpath.dirname(path) + "/" |
| 232 | parts = scheme, netloc, path, params, query, fragment |
| 233 | source.baseURI = urllib.parse.urlunparse(parts) |
| 234 | |
| 235 | return source |
| 236 | |
| 237 | def _get_opener(self): |
| 238 | try: |