1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-24 00:56:15 +01:00

add "osc less", it is "osc cat" + pager

This commit is contained in:
Adrian Schröter 2011-01-12 17:04:22 +01:00
parent f729ea8e38
commit d11e9f8514
2 changed files with 14 additions and 4 deletions

1
NEWS
View File

@ -4,6 +4,7 @@
CHANGE: the --start parameter is now called --offset
- add "createrequest -a add_group" option to create a group request
- add "createrequest -a add_me" shortcut
- add "less" command, doing the same as "osc cat" but with pager
0.130
- new "revert" command to restore the original working copy file (without

View File

@ -5655,6 +5655,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='force expansion of linked packages.')
@cmdln.option('-u', '--unexpand', action='store_true',
help='always work with unexpanded packages.')
@cmdln.alias('less')
def do_cat(self, subcmd, opts, *args):
"""${cmd_name}: Output the content of a file to standard output
@ -5691,15 +5692,23 @@ Please submit there instead, or use --nodevelproject to force direct submission.
query['rev'] = show_upstream_srcmd5(apiurl, args[0], args[1], expand=True, revision=opts.revision)
u = makeurl(apiurl, ['source', args[0], args[1], args[2]], query=query)
try:
for data in streamfile(u):
sys.stdout.write(data)
if subcmd == "less":
f = http_GET(u)
run_pager(''.join(f.readlines()))
else:
for data in streamfile(u):
sys.stdout.write(data)
except urllib2.HTTPError, e:
if e.code == 404 and not opts.expand and not opts.unexpand:
print >>sys.stderr, 'expanding link...'
query['rev'] = show_upstream_srcmd5(apiurl, args[0], args[1], expand=True, revision=opts.revision)
u = makeurl(apiurl, ['source', args[0], args[1], args[2]], query=query)
for data in streamfile(u):
sys.stdout.write(data)
if subcmd == "less":
f = http_GET(u)
run_pager(''.join(f.readlines()))
else:
for data in streamfile(u):
sys.stdout.write(data)
else:
e.osc_msg = 'If linked, try: cat -e'
raise e