comparison numerics/manipulate.py @ 58:537fba7c9def

stubbing
author Jeff Hammel <k0scist@gmail.com>
date Tue, 20 Jan 2015 16:44:56 -0800
parents f16d5f013739
children e3c3ee7b5ccf
comparison
equal deleted inserted replaced
57:f16d5f013739 58:537fba7c9def
13 13
14 # module globals 14 # module globals
15 __all__ = ['main', 'Parser'] 15 __all__ = ['main', 'Parser']
16 here = os.path.dirname(os.path.realpath(__file__)) 16 here = os.path.dirname(os.path.realpath(__file__))
17 string = (str, unicode) 17 string = (str, unicode)
18
19 def ensure_dir(directory):
20 """ensure a directory exists"""
21 if os.path.exists(directory):
22 if not os.path.isdir(directory):
23 raise OSError("Not a directory: '{}'".format(directory))
24 return directory
25 os.makedirs(directory)
26 return directory
27
28 18
29 class Parser(argparse.ArgumentParser): 19 class Parser(argparse.ArgumentParser):
30 """CLI option parser""" 20 """CLI option parser"""
31 def __init__(self, **kwargs): 21 def __init__(self, **kwargs):
32 kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter) 22 kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter)