Commit 9c682df7d6d1a3e1f22b8cf8e2c896e45b0bb55c

Authored by decalage2
1 parent 838535f8

tablestream: fixed issue #57, bug when importing colorclass 2.x

oletools/thirdparty/tablestream/tablestream.py
... ... @@ -42,6 +42,7 @@ License: BSD, see source code or documentation
42 42 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 43 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 44  
  45 +from __future__ import print_function
45 46  
46 47 #------------------------------------------------------------------------------
47 48 # CHANGELOG:
... ... @@ -49,8 +50,9 @@ License: BSD, see source code or documentation
49 50 # 2016-01-01 v0.02 PL: - added styles, color support
50 51 # 2016-04-19 v0.03 PL: - enable colorclass on Windows, fixed issue #39
51 52 # 2016-05-25 v0.04 PL: - updated for colorclass 2.2.0 (now a package)
  53 +# 2016-07-29 v0.05 PL: - fixed oletools issue #57, bug when importing colorclass
52 54  
53   -__version__ = '0.04'
  55 +__version__ = '0.05'
54 56  
55 57 #------------------------------------------------------------------------------
56 58 # TODO:
... ... @@ -65,7 +67,16 @@ __version__ = '0.04'
65 67 import textwrap
66 68 import sys, os
67 69  
68   -from thirdparty import colorclass
  70 +# add the thirdparty subfolder to sys.path (absolute+normalized path):
  71 +_thismodule_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
  72 +# print('_thismodule_dir = %r' % _thismodule_dir)
  73 +# assumption: this module is in a subfolder of thirdparty:
  74 +_thirdparty_dir = os.path.normpath(os.path.join(_thismodule_dir, '..'))
  75 +# print('_thirdparty_dir = %r' % _thirdparty_dir)
  76 +if not _thirdparty_dir in sys.path:
  77 + sys.path.insert(0, _thirdparty_dir)
  78 +
  79 +import colorclass
69 80  
70 81 # On Windows, colorclass needs to be enabled:
71 82 if os.name == 'nt':
... ...