diff options
author | Sylvain <syt@logilab.fr> | 2006-09-23 13:08:05 +0200 |
---|---|---|
committer | Sylvain <syt@logilab.fr> | 2006-09-23 13:08:05 +0200 |
commit | f37c5c58eb862c65b379ff19a38414273e48b29d (patch) | |
tree | 0f0d30d30391891b36ca478b99d176de878896cb /optik_ext.py | |
parent | e8dda7d5ec96f726f95d443e3236d173ba9333de (diff) | |
download | logilab-common-f37c5c58eb862c65b379ff19a38414273e48b29d.tar.gz |
make it works if mx.DateTime is not installed
Diffstat (limited to 'optik_ext.py')
-rw-r--r-- | optik_ext.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/optik_ext.py b/optik_ext.py index 43bdf17..431f60d 100644 --- a/optik_ext.py +++ b/optik_ext.py @@ -28,8 +28,6 @@ It also defines three new types for optik/optparse command line parser : """ -__revision__ = '$Id: optik_ext.py,v 1.16 2006-03-28 10:34:54 syt Exp $' - import re import sys import time @@ -50,7 +48,12 @@ except ImportError: except: NO_DEFAULT = [] -from mx import DateTime +try: + from mx import DateTime + HAS_MX_DATETIME = True +except ImportError: + HAS_MX_DATETIME = False + OPTPARSE_FORMAT_DEFAULT = sys.version_info >= (2, 4) @@ -158,7 +161,7 @@ import types class Option(BaseOption): """override optik.Option to add some new option types """ - TYPES = BaseOption.TYPES + ('regexp', 'csv', 'yn', 'date', 'named', 'password', + TYPES = BaseOption.TYPES + ('regexp', 'csv', 'yn', 'named', 'password', 'multiple_choice', 'file', 'font', 'color') TYPE_CHECKER = copy(BaseOption.TYPE_CHECKER) TYPE_CHECKER['regexp'] = check_regexp @@ -169,7 +172,9 @@ class Option(BaseOption): TYPE_CHECKER['file'] = check_file TYPE_CHECKER['color'] = check_color TYPE_CHECKER['password'] = check_password - TYPE_CHECKER['date'] = check_date + if HAS_MX_DATETIME: + TYPES += ('date',) + TYPE_CHECKER['date'] = check_date def _check_choice(self): """FIXME: need to override this due to optik misdesign""" |