summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-07-19 23:57:55 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-07-19 23:57:55 +0000
commit0bda09b0abc9a2c5cdffc9d73454febaf913575c (patch)
treeeff97af9b0c8fd1d97dc2eb1d3bd6b79ba3001dd
parent0cd619660c83a238bd0192ac5707e1ab591d7408 (diff)
downloadpoezio-0bda09b0abc9a2c5cdffc9d73454febaf913575c.tar.gz
poezio-0bda09b0abc9a2c5cdffc9d73454febaf913575c.tar.bz2
poezio-0bda09b0abc9a2c5cdffc9d73454febaf913575c.tar.xz
poezio-0bda09b0abc9a2c5cdffc9d73454febaf913575c.zip
Don't use argparse if it's not available
-rw-r--r--src/config.py18
1 files 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)