Make info command show VCS URLs properly.
This commit is contained in:
parent
2e2e720a2a
commit
525344aa85
@ -26,6 +26,7 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
from llnl.util.tty.colify import colify
|
from llnl.util.tty.colify import colify
|
||||||
import spack
|
import spack
|
||||||
|
import spack.fetch_strategy as fs
|
||||||
|
|
||||||
description = "Get detailed information on a particular package"
|
description = "Get detailed information on a particular package"
|
||||||
|
|
||||||
@ -34,40 +35,41 @@ def setup_parser(subparser):
|
|||||||
|
|
||||||
|
|
||||||
def info(parser, args):
|
def info(parser, args):
|
||||||
package = spack.db.get(args.name)
|
pkg = spack.db.get(args.name)
|
||||||
print "Package: ", package.name
|
print "Package: ", pkg.name
|
||||||
print "Homepage: ", package.homepage
|
print "Homepage: ", pkg.homepage
|
||||||
|
|
||||||
print
|
print
|
||||||
print "Safe versions: "
|
print "Versions: "
|
||||||
|
|
||||||
if not package.versions:
|
if not pkg.versions:
|
||||||
print("None.")
|
print("None.")
|
||||||
else:
|
else:
|
||||||
maxlen = max(len(str(v)) for v in package.versions)
|
maxlen = max(len(str(v)) for v in pkg.versions)
|
||||||
fmt = "%%-%ss" % maxlen
|
fmt = "%%-%ss" % maxlen
|
||||||
for v in reversed(sorted(package.versions)):
|
for v in reversed(sorted(pkg.versions)):
|
||||||
print " " + (fmt % v) + " " + package.url_for_version(v)
|
f = fs.for_package_version(pkg, v)
|
||||||
|
print " " + (fmt % v) + " " + str(f)
|
||||||
|
|
||||||
print
|
print
|
||||||
print "Dependencies:"
|
print "Dependencies:"
|
||||||
if package.dependencies:
|
if pkg.dependencies:
|
||||||
colify(package.dependencies, indent=4)
|
colify(pkg.dependencies, indent=4)
|
||||||
else:
|
else:
|
||||||
print " None"
|
print " None"
|
||||||
|
|
||||||
print
|
print
|
||||||
print "Virtual packages: "
|
print "Virtual pkgs: "
|
||||||
if package.provided:
|
if pkg.provided:
|
||||||
for spec, when in package.provided.items():
|
for spec, when in pkg.provided.items():
|
||||||
print " %s provides %s" % (when, spec)
|
print " %s provides %s" % (when, spec)
|
||||||
else:
|
else:
|
||||||
print " None"
|
print " None"
|
||||||
|
|
||||||
print
|
print
|
||||||
print "Description:"
|
print "Description:"
|
||||||
if package.__doc__:
|
if pkg.__doc__:
|
||||||
doc = re.sub(r'\s+', ' ', package.__doc__)
|
doc = re.sub(r'\s+', ' ', pkg.__doc__)
|
||||||
lines = textwrap.wrap(doc, 72)
|
lines = textwrap.wrap(doc, 72)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
print " " + line
|
print " " + line
|
||||||
|
@ -240,7 +240,7 @@ def __str__(self):
|
|||||||
if self.url:
|
if self.url:
|
||||||
return self.url
|
return self.url
|
||||||
else:
|
else:
|
||||||
return "URLFetchStrategy<no url>"
|
return "[no url]"
|
||||||
|
|
||||||
|
|
||||||
class VCSFetchStrategy(FetchStrategy):
|
class VCSFetchStrategy(FetchStrategy):
|
||||||
@ -293,7 +293,7 @@ def archive(self, destination, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.url
|
return "VCS: %s" % self.url
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -396,6 +396,10 @@ def reset(self):
|
|||||||
self.git('clean', '-f')
|
self.git('clean', '-f')
|
||||||
|
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "[git] %s" % self.url
|
||||||
|
|
||||||
|
|
||||||
class SvnFetchStrategy(VCSFetchStrategy):
|
class SvnFetchStrategy(VCSFetchStrategy):
|
||||||
"""Fetch strategy that gets source code from a subversion repository.
|
"""Fetch strategy that gets source code from a subversion repository.
|
||||||
Use like this in a package:
|
Use like this in a package:
|
||||||
@ -469,6 +473,11 @@ def reset(self):
|
|||||||
self.svn('revert', '.', '-R')
|
self.svn('revert', '.', '-R')
|
||||||
|
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "[svn] %s" % self.url
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class HgFetchStrategy(VCSFetchStrategy):
|
class HgFetchStrategy(VCSFetchStrategy):
|
||||||
"""Fetch strategy that gets source code from a Mercurial repository.
|
"""Fetch strategy that gets source code from a Mercurial repository.
|
||||||
Use like this in a package:
|
Use like this in a package:
|
||||||
@ -543,6 +552,10 @@ def reset(self):
|
|||||||
self.stage.chdir_to_source()
|
self.stage.chdir_to_source()
|
||||||
|
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "[hg] %s" % self.url
|
||||||
|
|
||||||
|
|
||||||
def from_url(url):
|
def from_url(url):
|
||||||
"""Given a URL, find an appropriate fetch strategy for it.
|
"""Given a URL, find an appropriate fetch strategy for it.
|
||||||
Currently just gives you a URLFetchStrategy that uses curl.
|
Currently just gives you a URLFetchStrategy that uses curl.
|
||||||
@ -630,5 +643,3 @@ class NoStageError(FetchError):
|
|||||||
def __init__(self, method):
|
def __init__(self, method):
|
||||||
super(NoStageError, self).__init__(
|
super(NoStageError, self).__init__(
|
||||||
"Must call FetchStrategy.set_stage() before calling %s" % method.__name__)
|
"Must call FetchStrategy.set_stage() before calling %s" % method.__name__)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user