Imported Upstream version 0.2r183

parent a5cf494d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# http://peepdf.eternal-todo.com # http://peepdf.eternal-todo.com
# By Jose Miguel Esparza <jesparza AT eternal-todo.com> # By Jose Miguel Esparza <jesparza AT eternal-todo.com>
# #
# Copyright (C) 2012 Jose Miguel Esparza # Copyright (C) 2011-2013 Jose Miguel Esparza
# #
# This file is part of peepdf. # This file is part of peepdf.
# #
...@@ -53,6 +53,7 @@ FILE_ADD = 2 ...@@ -53,6 +53,7 @@ FILE_ADD = 2
VAR_WRITE = 3 VAR_WRITE = 3
VAR_ADD = 4 VAR_ADD = 4
newLine = os.linesep newLine = os.linesep
errorsFile = 'errors.txt'
filter2RealFilterDict = {'b64':'base64','base64':'base64','asciihex':'/ASCIIHexDecode','ahx':'/ASCIIHexDecode','ascii85':'/ASCII85Decode','a85':'/ASCII85Decode','lzw':'/LZWDecode','flatedecode':'/FlateDecode','fl':'/FlateDecode','runlength':'/RunLengthDecode','rl':'/RunLengthDecode','ccittfax':'/CCITTFaxDecode','ccf':'/CCITTFaxDecode','jbig2':'/JBIG2Decode','dct':'/DCTDecode','jpx':'/JPXDecode'} filter2RealFilterDict = {'b64':'base64','base64':'base64','asciihex':'/ASCIIHexDecode','ahx':'/ASCIIHexDecode','ascii85':'/ASCII85Decode','a85':'/ASCII85Decode','lzw':'/LZWDecode','flatedecode':'/FlateDecode','fl':'/FlateDecode','runlength':'/RunLengthDecode','rl':'/RunLengthDecode','ccittfax':'/CCITTFaxDecode','ccf':'/CCITTFaxDecode','jbig2':'/JBIG2Decode','dct':'/DCTDecode','jpx':'/JPXDecode'}
warningColor = Fore.YELLOW warningColor = Fore.YELLOW
errorColor = Fore.RED errorColor = Fore.RED
...@@ -68,6 +69,7 @@ class PDFConsole(cmd.Cmd): ...@@ -68,6 +69,7 @@ class PDFConsole(cmd.Cmd):
''' '''
Class of the peepdf interactive console. To see details about commands: http://code.google.com/p/peepdf/wiki/Commands Class of the peepdf interactive console. To see details about commands: http://code.google.com/p/peepdf/wiki/Commands
''' '''
def __init__(self, pdfFile, outputColors = False, stdin = None): def __init__(self, pdfFile, outputColors = False, stdin = None):
cmd.Cmd.__init__(self, stdin = stdin) cmd.Cmd.__init__(self, stdin = stdin)
if COLORIZED_OUTPUT: if COLORIZED_OUTPUT:
...@@ -88,6 +90,7 @@ class PDFConsole(cmd.Cmd): ...@@ -88,6 +90,7 @@ class PDFConsole(cmd.Cmd):
self.loggingFile = None self.loggingFile = None
self.output = None self.output = None
self.redirect = None self.redirect = None
self.leaving = False
self.outputVarName = None self.outputVarName = None
self.outputFileName = None self.outputFileName = None
self.avoidOutputColors = outputColors self.avoidOutputColors = outputColors
...@@ -101,6 +104,10 @@ class PDFConsole(cmd.Cmd): ...@@ -101,6 +104,10 @@ class PDFConsole(cmd.Cmd):
else: else:
return line return line
def postloop(self):
print newLine + 'Leaving the Peepdf interactive console...Bye! ;)' + newLine
self.leaving = True
def do_bytes(self, argv): def do_bytes(self, argv):
if self.pdfFile == None: if self.pdfFile == None:
message = '*** Error: You must open a file!!' message = '*** Error: You must open a file!!'
...@@ -2287,11 +2294,13 @@ class PDFConsole(cmd.Cmd): ...@@ -2287,11 +2294,13 @@ class PDFConsole(cmd.Cmd):
object = self.pdfFile.getObject(id, v) object = self.pdfFile.getObject(id, v)
objectType = object.getType() objectType = object.getType()
if objectType == 'dictionary' or objectType == 'stream': if objectType == 'dictionary' or objectType == 'stream':
type = object.getElementByName('/Type').getValue() subType = object.getElementByName('/Type')
if type == '/Metadata': if subType != []:
value = object.getValue() subType = subType.getValue()
if value != '': if subType == '/Metadata':
output += 'Object '+str(id)+' in version '+str(v)+':' + newLine*2+value+newLine*2 value = object.getValue()
if value != '':
output += 'Object '+str(id)+' in version '+str(v)+':' + newLine*2+value+newLine*2
self.log_output('metadata ' + argv, output, storeOutput = True) self.log_output('metadata ' + argv, output, storeOutput = True)
else: else:
message = '*** No metadata found!!' message = '*** No metadata found!!'
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment