1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-28 07:26:15 +01:00

osc ls: be able to list a single file (osc ls <project> <package> <file>) (requested by darix)

This commit is contained in:
Marcus Hüwe 2008-11-20 12:56:16 +00:00
parent 2bea1ad2df
commit b6b4550ae7

View File

@ -158,6 +158,7 @@ class Osc(cmdln.Cmdln):
ls Apache # list packages in a project ls Apache # list packages in a project
ls -b Apache # list all binaries of a project ls -b Apache # list all binaries of a project
ls Apache apache2 # list source files of package of a project ls Apache apache2 # list source files of package of a project
ls Apache apache2 <file> # list <file> if this file exists
ls -v Apache apache2 # verbosely list source files of package ls -v Apache apache2 # verbosely list source files of package
With --verbose, the following fields will be shown for each item: With --verbose, the following fields will be shown for each item:
@ -174,9 +175,14 @@ class Osc(cmdln.Cmdln):
if len(args) == 1: if len(args) == 1:
project = args[0] project = args[0]
elif len(args) == 2: elif len(args) == 2 or len(args) == 3:
project = args[0] project = args[0]
package = args[1] package = args[1]
fname = None
if len(args) == 3:
fname = args[2]
elif len(args) > 3:
raise oscerr.WrongArgs('Too many arguments')
if opts.binaries and (not opts.repo or not opts.arch): if opts.binaries and (not opts.repo or not opts.arch):
raise oscerr.WrongOptions('Sorry, -r <repo> -a <arch> missing\n' raise oscerr.WrongOptions('Sorry, -r <repo> -a <arch> missing\n'
@ -208,15 +214,25 @@ class Osc(cmdln.Cmdln):
print '\n'.join(meta_get_packagelist(conf.config['apiurl'], project)) print '\n'.join(meta_get_packagelist(conf.config['apiurl'], project))
elif len(args) == 2: elif len(args) == 2 or len(args) == 3:
l = meta_get_filelist(conf.config['apiurl'], l = meta_get_filelist(conf.config['apiurl'],
project, project,
package, package,
verbose=opts.verbose) verbose=opts.verbose)
if opts.verbose: if opts.verbose:
for i in l: out = [ '%s %7d %9d %s %s' % (i.md5, i.rev, i.size, shorttime(i.mtime), i.name) \
print '%s %7d %9d %s %s' \ for i in l if not fname or fname == i.name ]
% (i.md5, i.rev, i.size, shorttime(i.mtime), i.name) if len(out) == 0:
if fname:
print 'file \'%s\' does not exist' % fname
else:
print '\n'.join(out)
else:
if fname:
if fname in l:
print fname
else:
print 'file \'%s\' does not exist' % fname
else: else:
print '\n'.join(l) print '\n'.join(l)