diff options
author | W. Trevor King <wking@drexel.edu> | 2009-12-06 00:44:22 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-12-06 00:44:22 -0500 |
commit | 61010c1c6b055ef8fd33b01c088e3d095914e89a (patch) | |
tree | e967aadbc99dee314b5fc3deb8036369e79a4c99 /libbe/cmdutil.py | |
parent | af8bd49a6215029c08676a3d4a59cfcab1d80976 (diff) | |
parent | ff1ca79e6781447dbad6279d6c4cdad44fad5cdd (diff) | |
download | bugseverywhere-61010c1c6b055ef8fd33b01c088e3d095914e89a.tar.gz |
Merged be.target-as-bug
Highlights:
* targets are now a special type of bug (severity 'target'), so you
can do all the things you do with normal bugs to them as well
(e.g. comment on them, link them into dependency trees, etc.)
* new command `be due` to get/set bug due dates.
* changes to `be depend`
* added options --status, --severity
* changes to `be list`
* added blacklist capability to --status, --severity, --assigned
* removed options --target, --cur-target
Replace:
'be list --target TARGET' with
'be depend --status -closed,fixed,wontfix --severity -target \
$(be target --resolve TARGET)'
'be list --cur-target' with
'be depend --status -closed,fixed,wontfix --severity -target \
$(be target --resolve)'
* changes to `be target`
* added option --resolve
* removed option --list
Replace:
'be target --list' with 'be list --status all --severity target'
* new function cmdutil.select_values() for whitelist/blacklist selection.
* assorted cleanups and bugfixes
Diffstat (limited to 'libbe/cmdutil.py')
-rw-r--r-- | libbe/cmdutil.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py index dcd4ca9..b892bde 100644 --- a/libbe/cmdutil.py +++ b/libbe/cmdutil.py @@ -217,6 +217,59 @@ def underlined(instring): return "%s\n%s" % (instring, "="*len(instring)) +def select_values(string, possible_values, name="unkown"): + """ + This function allows the user to select values from a list of + possible values. The default is to select all the values: + + >>> select_values(None, ['abc', 'def', 'hij']) + ['abc', 'def', 'hij'] + + The user selects values with a comma-separated limit_string. + Prepending a minus sign to such a list denotes blacklist mode: + + >>> select_values('-abc,hij', ['abc', 'def', 'hij']) + ['def'] + + Without the leading -, the selection is in whitelist mode: + + >>> select_values('abc,hij', ['abc', 'def', 'hij']) + ['abc', 'hij'] + + In either case, appropriate errors are raised if on of the + user-values is not in the list of possible values. The name + parameter lets you make the error message more clear: + + >>> select_values('-xyz,hij', ['abc', 'def', 'hij'], name="foobar") + Traceback (most recent call last): + ... + UserError: Invalid foobar xyz + ['abc', 'def', 'hij'] + >>> select_values('xyz,hij', ['abc', 'def', 'hij'], name="foobar") + Traceback (most recent call last): + ... + UserError: Invalid foobar xyz + ['abc', 'def', 'hij'] + """ + possible_values = list(possible_values) # don't alter the original + if string == None: + pass + elif string.startswith('-'): + blacklisted_values = set(string[1:].split(',')) + for value in blacklisted_values: + if value not in possible_values: + raise UserError('Invalid %s %s\n %s' + % (name, value, possible_values)) + possible_values.remove(value) + else: + whitelisted_values = string.split(',') + for value in whitelisted_values: + if value not in possible_values: + raise UserError('Invalid %s %s\n %s' + % (name, value, possible_values)) + possible_values = whitelisted_values + return possible_values + def restrict_file_access(bugdir, path): """ Check that the file at path is inside bugdir.root. This is |