patch
thanks
This small patch adds an optional option [FILE] to the ls command.
It does not modify the way the ls command is already working: it should
still be possible to give None, one or several generation arguments.
ls command summary would become:
obnam [options] ls [GENERATION]... [FILE]
regards,
Damien
--- /tmp/bzr-diff-7g90EY/old/obnamlib/plugins/show_plugin.py 2012-05-24 17:27:45.000000000 +0200
+++ /home/damien/src/read_only/obnam/obnamlib/plugins/show_plugin.py 2012-06-28 22:02:38.000000000 +0200
@@ -129,15 +129,28 @@
def ls(self, args):
'''List contents of a generation.'''
self.open_repository()
+
+ if self.__is_generation(args[-1]):
+ show_file = '/'
+ else:
+ # a trailing slash makes the ls command fail...
+ show_file = args.pop().rstrip('/')
+
for gen in args or [self.app.settings['generation']] or ["latest"]:
gen = self.repo.genspec(gen)
started, ended = self.repo.client.get_generation_times(gen)
started = self.format_time(started)
ended = self.format_time(ended)
print 'Generation %s (%s - %s)' % (gen, started, ended)
- self.show_objects(gen, '/')
+ self.show_objects(gen, show_file)
self.repo.fs.close()
+ def __is_generation(self, gen):
+ try:
+ int(gen)
+ return True
+ except ValueError:
+ return False
+
def format_time(self, timestamp):
return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp))