diff --git a/oletools/olebrowse.py b/oletools/olebrowse.py index ed387d1..ccfb0a9 100644 --- a/oletools/olebrowse.py +++ b/oletools/olebrowse.py @@ -12,7 +12,7 @@ olebrowse project website: http://www.decalage.info/python/olebrowse olebrowse is part of the python-oletools package: http://www.decalage.info/python/oletools -olebrowse is copyright (c) 2012-2015, Philippe Lagadec (http://www.decalage.info) +olebrowse is copyright (c) 2012-2017, Philippe Lagadec (http://www.decalage.info) All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -36,12 +36,13 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -__version__ = '0.02' - #------------------------------------------------------------------------------ # CHANGELOG: # 2012-09-17 v0.01 PL: - first version # 2014-11-29 v0.02 PL: - use olefile instead of OleFileIO_PL +# 2017-04-26 v0.51 PL: - fixed absolute imports (issue #141) + +__version__ = '0.51' #------------------------------------------------------------------------------ # TODO: @@ -51,10 +52,25 @@ __version__ = '0.02' # - for a stream, display info: size, path, etc # - stream info: magic, entropy, ... ? +# === IMPORTS ================================================================ + import optparse, sys, os -from .thirdparty.easygui import easygui -from .thirdparty import olefile -from . import ezhexviewer + +# IMPORTANT: it should be possible to run oletools directly as scripts +# in any directory without installing them with pip or setup.py. +# In that case, relative imports are NOT usable. +# And to enable Python 2+3 compatibility, we need to use absolute imports, +# so we add the oletools parent folder to sys.path (absolute+normalized path): +_thismodule_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) +# print('_thismodule_dir = %r' % _thismodule_dir) +_parent_dir = os.path.normpath(os.path.join(_thismodule_dir, '..')) +# print('_parent_dir = %r' % _thirdparty_dir) +if not _parent_dir in sys.path: + sys.path.insert(0, _parent_dir) + +from oletools.thirdparty.easygui import easygui +from oletools.thirdparty import olefile +from oletools import ezhexviewer ABOUT = '~ About olebrowse' QUIT = '~ Quit'