Commits

Andy Mikhailenko  committed 7542c1e

Added support for Python 2.5 (this fixes issue #5).

  • Participants
  • Parent commits 93e974b

Comments (0)

Files changed (5)

-version = '0.8.0'
+version = '0.8.1'

File argh/__init__.py

    :members:
 
 """
-from .exceptions import *
-from .helpers import *
-from .decorators import *
+from exceptions import *
+from helpers import *
+from decorators import *

File argh/helpers.py

 import sys
 from types import GeneratorType
 
-from .exceptions import CommandError
+from argh.exceptions import CommandError
 
 
 __all__ = ['ArghParser', 'add_commands', 'dispatch', 'confirm']
                     print(line.encode(encoding))
         else:
             return result
-    except CommandError as e:
+    except CommandError, e:
         if intercept:
             return str(e)
         else:
             False: ('y','N'),
         }
         y, n = defaults[default]
-        prompt = u'{action}? ({y}/{n})'.format(**locals()).encode('utf-8')
+        prompt = (u'%(action)s? (%(y)s/%(n)s)' % locals()).encode('utf-8')
         choice = None
         try:
             if default is None:
     # technical info
     version  = version,
     packages = ['argh'],
-    requires = ['python (>= 2.6)', 'argparse (>=1.1)'],
+    requires = ['python (>= 2.5)', 'argparse (>=1.1)'],
     provides = ['argh'],
 
     # copyright
 @arg('--twice', default=False, help='repeat twice')
 def echo(args):
     repeat = 2 if args.twice else 1
-    return u'you said {0}'.format(args.text) * repeat
+    return (u'you said %s' % args.text) * repeat
 
 @arg('text')
 @plain_signature
 def plain_echo(text):
-    return u'you said {0}'.format(text)
+    return u'you said %s' % text
 
 @arg('--name', default='world')
 def hello(args):
-    return u'Hello {0}!'.format(args.name or 'world')
+    return u'Hello %s!' % (args.name or 'world')
 
 @arg('buddy')
 def howdy(args):
-    return u'Howdy {0}?'.format(args.buddy)
+    return u'Howdy %s?' % args.buddy
 
 @alias('aliased')
 def do_aliased(args):
     def assert_cmd_exits(self, command_string, message_regex=None):
         "When a command forces exit, it *may* fail, but may just print help."
         message_regex = str(message_regex)  # make sure None -> "None"
-        with self.assertRaisesRegexp(SystemExit, message_regex):
-            self.parser.dispatch(command_string.split())
+        f = lambda: self.parser.dispatch(command_string.split())
+        self.assertRaisesRegexp(SystemExit, message_regex, f)
 
     def assert_cmd_fails(self, command_string, message_regex):
         "exists with a message = fails"