diff options
Diffstat (limited to 'demoapp/cliffdemo')
-rw-r--r-- | demoapp/cliffdemo/__init__.py | 0 | ||||
-rw-r--r-- | demoapp/cliffdemo/encoding.py | 23 | ||||
-rw-r--r-- | demoapp/cliffdemo/list.py | 18 | ||||
-rw-r--r-- | demoapp/cliffdemo/main.py | 37 | ||||
-rw-r--r-- | demoapp/cliffdemo/show.py | 31 | ||||
-rw-r--r-- | demoapp/cliffdemo/simple.py | 24 |
6 files changed, 0 insertions, 133 deletions
diff --git a/demoapp/cliffdemo/__init__.py b/demoapp/cliffdemo/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/demoapp/cliffdemo/__init__.py +++ /dev/null diff --git a/demoapp/cliffdemo/encoding.py b/demoapp/cliffdemo/encoding.py deleted file mode 100644 index 6c6c751..0000000 --- a/demoapp/cliffdemo/encoding.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- encoding: utf-8 -*- - -import logging - -from cliff.lister import Lister - - -class Encoding(Lister): - """Show some unicode text - """ - - log = logging.getLogger(__name__) - - def take_action(self, parsed_args): - messages = [ - u'pi: π', - u'GB18030:鼀丅㐀ٸཌྷᠧꌢ€', - ] - return ( - ('UTF-8', 'Unicode'), - [(repr(t.encode('utf-8')), t) - for t in messages], - ) diff --git a/demoapp/cliffdemo/list.py b/demoapp/cliffdemo/list.py deleted file mode 100644 index 3dcee4a..0000000 --- a/demoapp/cliffdemo/list.py +++ /dev/null @@ -1,18 +0,0 @@ -import logging -import os - -from cliff.lister import Lister - - -class Files(Lister): - """Show a list of files in the current directory. - - The file name and size are printed by default. - """ - - log = logging.getLogger(__name__) - - def take_action(self, parsed_args): - return (('Name', 'Size'), - ((n, os.stat(n).st_size) for n in os.listdir('.')) - ) diff --git a/demoapp/cliffdemo/main.py b/demoapp/cliffdemo/main.py deleted file mode 100644 index 85807c8..0000000 --- a/demoapp/cliffdemo/main.py +++ /dev/null @@ -1,37 +0,0 @@ -import logging -import sys - -from cliff.app import App -from cliff.commandmanager import CommandManager - - -class DemoApp(App): - - log = logging.getLogger(__name__) - - def __init__(self): - super(DemoApp, self).__init__( - description='cliff demo app', - version='0.1', - command_manager=CommandManager('cliff.demo'), - ) - - def initialize_app(self, argv): - self.log.debug('initialize_app') - - def prepare_to_run_command(self, cmd): - self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__) - - def clean_up(self, cmd, result, err): - self.log.debug('clean_up %s', cmd.__class__.__name__) - if err: - self.log.debug('got an error: %s', err) - - -def main(argv=sys.argv[1:]): - myapp = DemoApp() - return myapp.run(argv) - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/demoapp/cliffdemo/show.py b/demoapp/cliffdemo/show.py deleted file mode 100644 index 9351148..0000000 --- a/demoapp/cliffdemo/show.py +++ /dev/null @@ -1,31 +0,0 @@ -import logging -import os - -from cliff.show import ShowOne - - -class File(ShowOne): - "Show details about a file" - - log = logging.getLogger(__name__) - - def get_parser(self, prog_name): - parser = super(File, self).get_parser(prog_name) - parser.add_argument('filename', nargs='?', default='.') - return parser - - def take_action(self, parsed_args): - stat_data = os.stat(parsed_args.filename) - columns = ('Name', - 'Size', - 'UID', - 'GID', - 'Modified Time', - ) - data = (parsed_args.filename, - stat_data.st_size, - stat_data.st_uid, - stat_data.st_gid, - stat_data.st_mtime, - ) - return (columns, data) diff --git a/demoapp/cliffdemo/simple.py b/demoapp/cliffdemo/simple.py deleted file mode 100644 index 3800514..0000000 --- a/demoapp/cliffdemo/simple.py +++ /dev/null @@ -1,24 +0,0 @@ -import logging - -from cliff.command import Command - - -class Simple(Command): - "A simple command that prints a message." - - log = logging.getLogger(__name__) - - def take_action(self, parsed_args): - self.log.info('sending greeting') - self.log.debug('debugging') - self.app.stdout.write('hi!\n') - - -class Error(Command): - "Always raises an error" - - log = logging.getLogger(__name__) - - def take_action(self, parsed_args): - self.log.info('causing error') - raise RuntimeError('this is the expected exception') |