Commit aeba6ed90827829fac211b3ace2a8952f7441d60

Authored by decalage2
1 parent c555887b

ppt_parser: fixed olefile import for Python 2+3

Showing 1 changed file with 12 additions and 3 deletions
oletools/ppt_parser.py
... ... @@ -3,7 +3,7 @@
3 3 Based on olefile, parse the ppt-specific info
4 4  
5 5 Code much influenced by olevba._extract_vba but much more object-oriented
6   -(possibly slightly excessivly so)
  6 +(possibly slightly excessively so)
7 7  
8 8 Currently quite narrowly focused on extracting VBA from ppt files, no slides or
9 9 stuff, but built to be extended to parsing more/all of the file
... ... @@ -26,18 +26,27 @@ References:
26 26 # CHANGELOG:
27 27 # 2016-05-04 v0.01 CH: - start parsing "Current User" stream
28 28 # 2016-07-20 v0.50 SL: - added Python 3 support
  29 +# 2016-09-13 PL: - fixed olefile import for Python 2+3
29 30  
30 31 __version__ = '0.50'
31 32  
32 33  
33   -#--- IMPORTS ------------------------------------------------------------------
  34 +# --- IMPORTS ------------------------------------------------------------------
  35 +
34 36 import sys
35 37 import logging
36 38 import struct
37 39 import traceback
38 40 import os
39 41  
40   -import oletools.thirdparty.olefile as olefile
  42 +try:
  43 + # absolute import when oletools is installed
  44 + import oletools.thirdparty.olefile as olefile
  45 +except:
  46 + # relative import otherwise
  47 + import thirdparty.olefile as olefile
  48 +
  49 +# TODO: fix zlib import for Python 2.6
41 50 import zlib
42 51  
43 52  
... ...