Mercurial > hg > numerics
changeset 151:1d24392ba5f5
cleaning
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 13 Apr 2015 10:32:22 -0700 |
parents | 8a1fe454c98a |
children | abfd4c294f02 |
files | numerics/cleanse.py |
diffstat | 1 files changed, 2 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/numerics/cleanse.py Mon Apr 13 10:17:47 2015 -0700 +++ b/numerics/cleanse.py Mon Apr 13 10:32:22 2015 -0700 @@ -8,38 +8,14 @@ # imports import argparse import os -import subprocess import sys import time -# python requirements -# (key, value) = (module, PyPI name) -requirements = () -for module, package in requirements: - try: - globals()[module] = __import__(module) - except ImportError: - # install requirement and try again - subprocess.check_call(['pip', 'install', package]) - args = [sys.executable] + sys.argv - os.execl(sys.executable, *args) - # module globals -__all__ = ['main', 'Parser'] -here = os.path.dirname(os.path.realpath(__file__)) -string = (str, unicode) - -def ensure_dir(directory): - """ensure a directory exists""" - if os.path.exists(directory): - if not os.path.isdir(directory): - raise OSError("Not a directory: '{}'".format(directory)) - return directory - os.makedirs(directory) - return directory +__all__ = ['main', 'CleanseParser'] -class Parser(argparse.ArgumentParser): +class CleanseParser(argparse.ArgumentParser): """CLI option parser""" def __init__(self, **kwargs): kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter)