Skip to content

Commit

Permalink
Use canonical_channel_name in conda list
Browse files Browse the repository at this point in the history
  • Loading branch information
asmeurer committed Apr 2, 2014
1 parent d181096 commit 377a7d8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
13 changes: 13 additions & 0 deletions conda/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,16 @@ def stdout_json(d):
sys.stdout.write('\n')

root_no_rm = 'python', 'pycosat', 'pyyaml', 'conda'

def canonical_channel_name(channel):
if channel is None:
return '<unknown>'
channel_alias = config.rc.get('channel_alias', config.DEFAULT_CHANNEL_ALIAS)
if channel.startswith(channel_alias):
return channel.split(channel_alias, 1)[1].split('/')[0]
elif any(channel.startswith(i) for i in config.get_default_urls()):
return 'defaults'
elif channel.startswith('http://filer/'):
return 'filer'
else:
return channel
2 changes: 1 addition & 1 deletion conda/cli/main_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def list_packages(prefix, regex=None, format='human', piplist=False):
disp = '%(name)-25s %(version)-15s %(build)15s' % info
disp += ' %s' % common.disp_features(features)
if config.show_channel_urls:
disp += ' %s' % info.get('url', '?')
disp += ' %s' % common.canonical_channel_name(info.get('url'))
print(disp)
except: # (IOError, KeyError, ValueError):
print('%-25s %-15s %15s' % tuple(dist.rsplit('-', 2)))
Expand Down
17 changes: 1 addition & 16 deletions conda/cli/main_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,12 @@ def configure_parser(sub_parsers):
common.add_parser_channels(p)
p.set_defaults(func=execute)


# XXX: Should this go in the library code somewhere:
def canonical_channel_name(channel):
if channel is None:
return '<unknown>'
channel_alias = config.rc.get('channel_alias', config.DEFAULT_CHANNEL_ALIAS)
if channel.startswith(channel_alias):
return channel.split(channel_alias, 1)[1].split('/')[0]
elif any(channel.startswith(i) for i in config.get_default_urls()):
return 'defaults'
elif channel.startswith('http://filer/'):
return 'filer'
else:
return channel

def execute(args, parser):
import re

from conda.api import get_index
from conda.resolve import MatchSpec, Resolve

from conda.common import canonical_channel_name

if args.regex:
pat = re.compile(args.regex, re.I)
Expand Down

0 comments on commit 377a7d8

Please sign in to comment.