MCPcopy Index your code
hub / github.com/clips/pattern / set_parser

Method set_parser

pattern/web/pdf/pdfparser.py:311–337  ·  view source on GitHub ↗

Set the document to use a given PDFParser object.

(self, parser)

Source from the content-addressed store, hash-verified

309 return
310
311 def set_parser(self, parser):
312 "Set the document to use a given PDFParser object."
313 if self._parser: return
314 self._parser = parser
315 # Retrieve the information of each header that was appended
316 # (maybe multiple times) at the end of the document.
317 self.xrefs = parser.read_xref()
318 for xref in self.xrefs:
319 trailer = xref.get_trailer()
320 if not trailer: continue
321 # If there's an encryption info, remember it.
322 if 'Encrypt' in trailer:
323 #assert not self.encryption
324 self.encryption = (list_value(trailer['ID']),
325 dict_value(trailer['Encrypt']))
326 if 'Info' in trailer:
327 self.info.append(dict_value(trailer['Info']))
328 if 'Root' in trailer:
329 # Every PDF file must have exactly one /Root dictionary.
330 self.catalog = dict_value(trailer['Root'])
331 break
332 else:
333 raise PDFSyntaxError('No /Root object! - Is this really a PDF?')
334 if self.catalog.get('Type') is not LITERAL_CATALOG:
335 if STRICT:
336 raise PDFSyntaxError('Catalog not found!')
337 return
338
339 # initialize(password='')
340 # Perform the initialization with a given password.

Callers 1

process_pdfFunction · 0.95

Calls 7

list_valueFunction · 0.90
dict_valueFunction · 0.90
PDFSyntaxErrorClass · 0.85
read_xrefMethod · 0.80
get_trailerMethod · 0.45
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected