cliff/demoapp/cliffdemo/list.py

20 lines
396 B
Python

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('.')),
)