From: Christopher Lenz Date: Fri, 11 Apr 2008 12:51:12 +0000 (+0000) Subject: Make dependency on the parser module optional. X-Git-Tag: 1.0~349 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5adbb870492e76996a5cddb15ae9bf8a65539585;p=thirdparty%2Fbabel.git Make dependency on the parser module optional. --- diff --git a/babel/util.py b/babel/util.py index 2ef92d65..195e538f 100644 --- a/babel/util.py +++ b/babel/util.py @@ -16,7 +16,6 @@ import codecs from datetime import timedelta, tzinfo import os -import parser import re try: set @@ -75,8 +74,9 @@ def parse_encoding(fp): m = PYTHON_MAGIC_COMMENT_re.match(line1) if not m: try: + import parser parser.suite(line1) - except SyntaxError: + except ImportError, SyntaxError: # Either it's a real syntax error, in which case the source is # not valid python source, or line2 is a continuation of line1, # in which case we don't want to scan line2 for a magic