aboutsummaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorRoman Lacko <backup.rlacko@gmail.com>2012-07-31 16:50:35 +0200
committerRoman Lacko <backup.rlacko@gmail.com>2012-07-31 16:50:35 +0200
commitb73480ba3dede8969f20443bc4b0a140d4b2e8d8 (patch)
tree8c26d0f3f25eb3352fd9294c454cf8a2902624dc /utils.py
parentfb0b8a3fec266077b5b686430bc3f973fafe06f8 (diff)
Introduced new command line options --version and --list-versions
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index 83af2e91..81deedd5 100644
--- a/utils.py
+++ b/utils.py
@@ -9,6 +9,32 @@ import popenasync
import fnmatch
+def has_option(name):
+ try:
+ sys.argv.remove('--%s' % name)
+ return True
+ except ValueError:
+ pass
+ return False
+
+
+def option_value(name):
+ for index, option in enumerate(sys.argv):
+ if option == '--' + name:
+ if index+1 >= len(sys.argv):
+ raise DistutilsOptionError(
+ 'The option %s requires a value' % option)
+ value = sys.argv[index+1]
+ sys.argv[index:index+2] = []
+ return value
+ if option.startswith('--' + name + '='):
+ value = option[len(name)+3:]
+ sys.argv[index:index+1] = []
+ return value
+ env_val = os.getenv(name.upper().replace('-', '_'))
+ return env_val
+
+
def filter_match(name, patterns):
for pattern in patterns:
if pattern is None: