From 330b09dcd5d353b4e3b73d1d5c2aba0c85843e9f Mon Sep 17 00:00:00 2001 From: Will Roberts Date: Fri, 17 Apr 2015 21:00:52 +0200 Subject: [PATCH] relax strict requirement of `future` and `pyparsing` packages --- nltk_tgrep/tests/test_tgrep.py | 8 ++++++-- nltk_tgrep/tgrep.py | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/nltk_tgrep/tests/test_tgrep.py b/nltk_tgrep/tests/test_tgrep.py index a5d0d13..055976b 100644 --- a/nltk_tgrep/tests/test_tgrep.py +++ b/nltk_tgrep/tests/test_tgrep.py @@ -7,8 +7,12 @@ (c) 16 March, 2013 Will Roberts ''' -from __future__ import unicode_literals -from builtins import range +from __future__ import print_function, unicode_literals +try: + from builtins import range +except ImportError: + print('Warning: nltk_tgrep may not work correctly on Python 2.* without the ') + print('`future` package installed.') from nltk.tree import ParentedTree from .. import tgrep import unittest diff --git a/nltk_tgrep/tgrep.py b/nltk_tgrep/tgrep.py index ef09e56..40639fe 100644 --- a/nltk_tgrep/tgrep.py +++ b/nltk_tgrep/tgrep.py @@ -60,11 +60,19 @@ macro definitions to `m` and initialises `l` to an empty dictionary. ''' -from __future__ import unicode_literals -from builtins import bytes, range, str +from __future__ import print_function, unicode_literals +try: + from builtins import bytes, range, str +except ImportError: + print('Warning: nltk_tgrep may not work correctly on Python 2.* without the') + print('`future` package installed.') import functools import nltk.tree -import pyparsing +try: + import pyparsing +except ImportError: + print('Warning: nltk_tgrep will not work without the `pyparsing` package') + print('installed.') import re class TgrepException(Exception):