diff options
author | Gianluca Montecchi <gian@grys.it> | 2009-10-02 23:46:24 +0200 |
---|---|---|
committer | Gianluca Montecchi <gian@grys.it> | 2009-10-02 23:46:24 +0200 |
commit | b0b3c9473e3a4b728ea72a2876e39fe41284a9ed (patch) | |
tree | 533a389e877b4b1a9c4099bb419eb221b2f12ada /interfaces/web/Bugs-Everywhere-Web/libbe/cmdutil.py | |
parent | 071fef7c351c4fc23696aa6db693411b78da2edb (diff) | |
download | bugseverywhere-b0b3c9473e3a4b728ea72a2876e39fe41284a9ed.tar.gz |
Merged with Trevor's -rr branch
Diffstat (limited to 'interfaces/web/Bugs-Everywhere-Web/libbe/cmdutil.py')
-rw-r--r-- | interfaces/web/Bugs-Everywhere-Web/libbe/cmdutil.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/interfaces/web/Bugs-Everywhere-Web/libbe/cmdutil.py b/interfaces/web/Bugs-Everywhere-Web/libbe/cmdutil.py index 853a75a..9b64142 100644 --- a/interfaces/web/Bugs-Everywhere-Web/libbe/cmdutil.py +++ b/interfaces/web/Bugs-Everywhere-Web/libbe/cmdutil.py @@ -15,6 +15,11 @@ # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +""" +Define assorted utilities to make command-line handling easier. +""" + import glob import optparse import os @@ -70,10 +75,11 @@ def get_command(command_name): return cmd -def execute(cmd, args): +def execute(cmd, args, manipulate_encodings=True): enc = encoding.get_encoding() cmd = get_command(cmd) - ret = cmd.execute([a.decode(enc) for a in args]) + ret = cmd.execute([a.decode(enc) for a in args], + manipulate_encodings=manipulate_encodings) if ret == None: ret = 0 return ret @@ -206,6 +212,15 @@ def underlined(instring): return "%s\n%s" % (instring, "="*len(instring)) +def bug_from_shortname(bdir, shortname): + """ + Exception translation for the command-line interface. + """ + try: + bug = bdir.bug_from_shortname(shortname) + except (bugdir.MultipleBugMatches, bugdir.NoBugMatches), e: + raise UserError(e.message) + return bug def _test(): import doctest |