From 0bda09b0abc9a2c5cdffc9d73454febaf913575c Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Mon, 19 Jul 2010 23:57:55 +0000 Subject: Don't use argparse if it's not available --- src/config.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/config.py b/src/config.py index d4005852..2a550af3 100644 --- a/src/config.py +++ b/src/config.py @@ -26,7 +26,11 @@ from/to the config file from ConfigParser import RawConfigParser, NoOptionError from os import environ, makedirs, path from shutil import copy2 -import argparse +try: + import argparse + HAVE_ARGPARSE = True +except ImportError: + HAVE_ARGPARSE = False class Config(RawConfigParser): """ @@ -123,8 +127,12 @@ except OSError: if not path.isfile(CONFIG_PATH+'poezio.cfg'): copy2('../data/default_config.cfg', CONFIG_PATH+'poezio.cfg') -parser = argparse.ArgumentParser(prog="poezio", description='An XMPP ncurses client.') -parser.add_argument('-f', '--file', default=CONFIG_PATH+'poezio.cfg', help='the config file you want to use', metavar="FILE") -args = parser.parse_args() +if HAVE_ARGPARSE: + parser = argparse.ArgumentParser(prog="poezio", description='An XMPP ncurses client.') + parser.add_argument('-f', '--file', default=CONFIG_PATH+'poezio.cfg', help='the config file you want to use', metavar="FILE") + args = parser.parse_args() + filename = args.file +else: + filename = CONFIG_PATH+'poezio.cfg' -config = Config(args.file) +config = Config(filename) -- cgit v1.2.3