From 525344aa85199d6ceb6a25af4b454a5096ae369e Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 27 Oct 2014 00:55:25 -0700 Subject: Make info command show VCS URLs properly. --- lib/spack/spack/cmd/info.py | 32 +++++++++++++++++--------------- lib/spack/spack/fetch_strategy.py | 19 +++++++++++++++---- 2 files changed, 32 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/info.py b/lib/spack/spack/cmd/info.py index bb147b30f5..a1c35269be 100644 --- a/lib/spack/spack/cmd/info.py +++ b/lib/spack/spack/cmd/info.py @@ -26,6 +26,7 @@ import re 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 diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index f79051c500..779cd76bae 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -240,7 +240,7 @@ class URLFetchStrategy(FetchStrategy): if self.url: return self.url else: - return "URLFetchStrategy" + return "[no url]" class VCSFetchStrategy(FetchStrategy): @@ -293,7 +293,7 @@ class VCSFetchStrategy(FetchStrategy): def __str__(self): - return self.url + return "VCS: %s" % self.url def __repr__(self): @@ -396,6 +396,10 @@ class GitFetchStrategy(VCSFetchStrategy): 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 @@ class SvnFetchStrategy(VCSFetchStrategy): 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 @@ class HgFetchStrategy(VCSFetchStrategy): 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__) - - -- cgit v1.2.3-70-g09d2