summaryrefslogtreecommitdiff
path: root/fs/commands/fsinfo.py
diff options
context:
space:
mode:
Diffstat (limited to 'fs/commands/fsinfo.py')
-rw-r--r--fs/commands/fsinfo.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/fs/commands/fsinfo.py b/fs/commands/fsinfo.py
index 943a28f..5cdbbac 100644
--- a/fs/commands/fsinfo.py
+++ b/fs/commands/fsinfo.py
@@ -4,10 +4,10 @@ import sys
from datetime import datetime
class FSInfo(Command):
-
+
usage = """fsinfo [OPTION]... [PATH]
Display information regarding an FS resource"""
-
+
def get_optparse(self):
optparse = super(FSInfo, self).get_optparse()
optparse.add_option('-k', '--key', dest='keys', action='append', default=[],
@@ -20,12 +20,12 @@ Display information regarding an FS resource"""
help="list directories only", metavar="DIRSONLY")
optparse.add_option('-f', '--filesonly', dest='filesonly', action="store_true", default=False,
help="list files only", metavar="FILESONLY")
- return optparse
-
-
+ return optparse
+
+
def do_run(self, options, args):
-
- def wrap_value(val):
+
+ def wrap_value(val):
if val.rstrip() == '\0':
return self.wrap_error('... missing ...')
return val
@@ -40,41 +40,41 @@ Display information regarding an FS resource"""
except:
text = repr(text)
return text
-
-
+
+
keys = options.keys or None
for fs, path, is_dir in self.get_resources(args,
files_only=options.filesonly,
- dirs_only=options.dirsonly):
+ dirs_only=options.dirsonly):
if not options.omit:
- if options.simple:
+ if options.simple:
file_line = u'%s\n' % self.wrap_filename(path)
else:
file_line = u'[%s] %s\n' % (self.wrap_filename(path), self.wrap_faded(fs.desc(path)))
- self.output(file_line)
+ self.output(file_line)
info = fs.getinfo(path)
-
+
for k, v in info.items():
if k.startswith('_'):
del info[k]
elif not isinstance(v, (basestring, int, long, float, bool, datetime)):
- del info[k]
-
- if keys:
+ del info[k]
+
+ if keys:
table = [(k, make_printable(info.get(k, '\0'))) for k in keys]
else:
keys = sorted(info.keys())
table = [(k, make_printable(info[k])) for k in sorted(info.keys())]
-
+
if options.simple:
for row in table:
self.output(row[-1] + '\n')
- else:
- self.output_table(table, {0:self.wrap_table_header, 1:wrap_value})
+ else:
+ self.output_table(table, {0:self.wrap_table_header, 1:wrap_value})
+
-
def run():
- return FSInfo().run()
-
+ return FSInfo().run()
+
if __name__ == "__main__":
- sys.exit(run())
+ sys.exit(run())