Skip to content

Commit 3e5c66b

Browse files
author
Matthias Koeppe
committed
sage --package properties: Add option --format, change default to 'plain'
1 parent eadb3d5 commit 3e5c66b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

build/sage_bootstrap/app.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def list_cls(self, *package_classes, **filters):
7777
for pkg_name in pc.names:
7878
print(pkg_name)
7979

80-
def properties(self, *package_classes, props=['path', 'version_with_patchlevel', 'type', 'source', 'trees']):
80+
def properties(self, *package_classes, props=['path', 'version_with_patchlevel', 'type', 'source', 'trees'],
81+
format='plain'):
8182
"""
8283
Show the properties of given packages
8384
@@ -92,14 +93,19 @@ def properties(self, *package_classes, props=['path', 'version_with_patchlevel',
9293
pc = PackageClass(*package_classes)
9394
for package_name in pc.names:
9495
package = Package(package_name)
96+
if format == 'plain':
97+
print("{0}:".format(package_name))
9598
for p in props:
9699
value = getattr(package, p)
97100
if value is None:
98101
if p.startswith('version'):
99102
value = 'none'
100103
else:
101104
value = ''
102-
print("{0}_{1}='{2}'".format(p, package_name, value))
105+
if format == 'plain':
106+
print(" {0:28} {1}".format(p + ":", value))
107+
else:
108+
print("{0}_{1}='{2}'".format(p, package_name, value))
103109

104110
def name(self, tarball_filename):
105111
"""

build/sage_bootstrap/cmdline.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ def make_parser():
278278
type=str, nargs='+',
279279
help=('package name or designator for all packages of a given type '
280280
'(one of :all:, :standard:, :optional:, and :experimental:)'))
281+
parser_properties.add_argument(
282+
'--format', type=str, default='plain',
283+
help='output format (one of plain and shell; default: plain)')
281284

282285
parser_name = subparsers.add_parser(
283286
'name', epilog=epilog_name,
@@ -427,7 +430,7 @@ def run():
427430
include_dependencies=args.include_dependencies,
428431
exclude_dependencies=args.exclude_dependencies)
429432
elif args.subcommand == 'properties':
430-
app.properties(*args.package_class)
433+
app.properties(*args.package_class, format=args.format)
431434
elif args.subcommand == 'name':
432435
app.name(args.tarball_filename)
433436
elif args.subcommand == 'tarball':

0 commit comments

Comments
 (0)