mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-27 05:21:10 -05:00
PkgInfo: condense 'pkg XYZ --depends' output by showing lists of each dependency type
This commit is contained in:
parent
310b14c2ed
commit
f9ec36cfd8
@ -164,26 +164,35 @@ class PkgInfo(callbacks.Plugin):
|
|||||||
# If we're using the --depends option, handle that separately.
|
# If we're using the --depends option, handle that separately.
|
||||||
if 'depends' in opts:
|
if 'depends' in opts:
|
||||||
items = soup.find('div', {'id': 'pdeps'}).find_all('dt')
|
items = soup.find('div', {'id': 'pdeps'}).find_all('dt')
|
||||||
res = []
|
# Store results by type and name, but in an ordered fashion: show dependencies first,
|
||||||
|
# followed by recommends, suggests, and enhances.
|
||||||
|
res = OrderedDict((deptype+':', []) for deptype in ('dep', 'rec', 'sug', 'enh'))
|
||||||
for item in items:
|
for item in items:
|
||||||
# Get package name and related versions and architectures:
|
# Get package name and related versions and architectures:
|
||||||
# <packagename> (>= 1.0) [arch1, arch2]
|
# <packagename> (>= 1.0) [arch1, arch2]
|
||||||
try:
|
try:
|
||||||
deptype = item.span.text if item.find('span') else ''
|
deptype = item.span.text if item.find('span') else ''
|
||||||
name = '%s %s %s' % (deptype, ircutils.bold(item.a.text),
|
if deptype not in res:
|
||||||
|
continue # Ignore unsupported fields
|
||||||
|
|
||||||
|
name = '%s %s' % (ircutils.bold(item.a.text),
|
||||||
item.a.next_sibling.replace('\n', '').strip())
|
item.a.next_sibling.replace('\n', '').strip())
|
||||||
name = utils.str.normalizeWhitespace(name).strip()
|
name = utils.str.normalizeWhitespace(name).strip()
|
||||||
if item.find('span'):
|
if item.find('span'):
|
||||||
res.append(name)
|
res[deptype].append(name)
|
||||||
else:
|
else:
|
||||||
# OR dependency
|
# OR dependency; format accordingly
|
||||||
res[-1] += " or %s" % name
|
res[deptype][-1] += " or %s" % name
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
if res:
|
if res:
|
||||||
s = format("Package \x02%s\x02 dependencies: %s, View more at %u", pkg,
|
s = format("Package \x02%s\x02 dependencies: ", pkg)
|
||||||
', '.join(res), url)
|
for deptype, packages in res.items():
|
||||||
s = self._dependencyColor(s)
|
if packages:
|
||||||
|
deptype = self._dependencyColor(deptype)
|
||||||
|
s += format("%s %L; ", deptype, packages)
|
||||||
|
s += format("%u", url)
|
||||||
|
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
else:
|
else:
|
||||||
irc.error("%s doesn't seem to have any dependencies." % pkg)
|
irc.error("%s doesn't seem to have any dependencies." % pkg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user