Make info command show VCS URLs properly.

This commit is contained in:
Todd Gamblin 2014-10-27 00:55:25 -07:00
parent 2e2e720a2a
commit 525344aa85
2 changed files with 32 additions and 19 deletions

View file

@ -26,6 +26,7 @@
import textwrap
from llnl.util.tty.colify import colify
import spack
import spack.fetch_strategy as fs
description = "Get detailed information on a particular package"
@ -34,40 +35,41 @@ def setup_parser(subparser):
def info(parser, args):
package = spack.db.get(args.name)
print "Package: ", package.name
print "Homepage: ", package.homepage
pkg = spack.db.get(args.name)
print "Package: ", pkg.name
print "Homepage: ", pkg.homepage
print
print "Safe versions: "
print "Versions: "
if not package.versions:
if not pkg.versions:
print("None.")
else:
maxlen = max(len(str(v)) for v in package.versions)
maxlen = max(len(str(v)) for v in pkg.versions)
fmt = "%%-%ss" % maxlen
for v in reversed(sorted(package.versions)):
print " " + (fmt % v) + " " + package.url_for_version(v)
for v in reversed(sorted(pkg.versions)):
f = fs.for_package_version(pkg, v)
print " " + (fmt % v) + " " + str(f)
print
print "Dependencies:"
if package.dependencies:
colify(package.dependencies, indent=4)
if pkg.dependencies:
colify(pkg.dependencies, indent=4)
else:
print " None"
print
print "Virtual packages: "
if package.provided:
for spec, when in package.provided.items():
print "Virtual pkgs: "
if pkg.provided:
for spec, when in pkg.provided.items():
print " %s provides %s" % (when, spec)
else:
print " None"
print
print "Description:"
if package.__doc__:
doc = re.sub(r'\s+', ' ', package.__doc__)
if pkg.__doc__:
doc = re.sub(r'\s+', ' ', pkg.__doc__)
lines = textwrap.wrap(doc, 72)
for line in lines:
print " " + line

View file

@ -240,7 +240,7 @@ def __str__(self):
if self.url:
return self.url
else:
return "URLFetchStrategy<no url>"
return "[no url]"
class VCSFetchStrategy(FetchStrategy):
@ -293,7 +293,7 @@ def archive(self, destination, **kwargs):
def __str__(self):
return self.url
return "VCS: %s" % self.url
def __repr__(self):
@ -396,6 +396,10 @@ def reset(self):
self.git('clean', '-f')
def __str__(self):
return "[git] %s" % self.url
class SvnFetchStrategy(VCSFetchStrategy):
"""Fetch strategy that gets source code from a subversion repository.
Use like this in a package:
@ -469,6 +473,11 @@ def reset(self):
self.svn('revert', '.', '-R')
def __str__(self):
return "[svn] %s" % self.url
class HgFetchStrategy(VCSFetchStrategy):
"""Fetch strategy that gets source code from a Mercurial repository.
Use like this in a package:
@ -543,6 +552,10 @@ def reset(self):
self.stage.chdir_to_source()
def __str__(self):
return "[hg] %s" % self.url
def from_url(url):
"""Given a URL, find an appropriate fetch strategy for it.
Currently just gives you a URLFetchStrategy that uses curl.
@ -630,5 +643,3 @@ class NoStageError(FetchError):
def __init__(self, method):
super(NoStageError, self).__init__(
"Must call FetchStrategy.set_stage() before calling %s" % method.__name__)