# Buggy code
def get_index(
    channel_urls=(),
    prepend=True,
    platform=None,
    use_local=False,
    use_cache=False,
    unknown=False,
    offline=False,
    prefix=None,
):
    """
    Return the index of packages available on the channels

    If prepend=False, only the channels passed in as arguments are used.
    If platform=None, then the current platform is used.
    If prefix is supplied, then the packages installed in that prefix are added.
    """
    if use_local:
        channel_urls = ["local"] + list(channel_urls)
    channel_urls = normalize_urls(channel_urls, platform, offline)
    if prepend:
        pri0 = (
            max(itervalues(channel_urls), key=itemgetter(1))[1] if channel_urls else 0
        )
        for url, rec in iteritems(get_channel_urls(platform, offline)):
            channel_urls[url] = (rec[0], rec[1] + pri0)
    index = fetch_index(channel_urls, use_cache=use_cache, unknown=unknown)
    if prefix:
        priorities = {c: p for c, p in itervalues(channel_urls)}
        for dist, info in iteritems(install.linked_data(prefix)):
            fn = info["fn"]
            schannel = info["schannel"]
            prefix = "" if schannel == "defaults" else schannel + "::"
            priority = priorities.get(schannel, 0)
            key = prefix + fn
            if key in index:
                # Copy the link information so the resolver knows this is installed
                index[key]["link"] = info.get("link")
            else:
                # only if the package in not in the repodata, use local
                # conda-meta (with 'depends' defaulting to [])
                info.setdefault("depends", [])
                info["priority"] = priority
                index[key] = info
    return index


# Traceback (TypeError)
Fetching package metadata ....Traceback (most recent call last):
File "/Users/ilan/python/bin/constructor", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/ilan/constructor/bin/constructor", line 6, in <module>
sys.exit(main())
File "/Users/ilan/constructor/constructor/main.py", line 146, in main
verbose=opts.verbose)
File "/Users/ilan/constructor/constructor/main.py", line 81, in main_build
fcp.main(info, verbose=verbose)
File "/Users/ilan/constructor/constructor/fcp.py", line 170, in main
for url in info['channels']))
File "/Users/ilan/python/lib/python2.7/site-packages/conda/fetch.py", line 276, in fetch_index
url_s, priority = channel_urls[channel]
TypeError: 'int' object is not iterable

# Fixed code
def get_index(
    channel_urls=(),
    prepend=True,
    platform=None,
    use_local=False,
    use_cache=False,
    unknown=False,
    offline=False,
    prefix=None,
):
    """
    Return the index of packages available on the channels

    If prepend=False, only the channels passed in as arguments are used.
    If platform=None, then the current platform is used.
    If prefix is supplied, then the packages installed in that prefix are added.
    """
    if use_local:
        channel_urls = ["local"] + list(channel_urls)
    channel_urls = normalize_urls(channel_urls, platform, offline)
    if prepend:
        channel_urls.extend(get_channel_urls(platform, offline))
    channel_urls = prioritize_channels(channel_urls)
    index = fetch_index(channel_urls, use_cache=use_cache, unknown=unknown)
    if prefix:
        priorities = {c: p for c, p in itervalues(channel_urls)}
        for dist, info in iteritems(install.linked_data(prefix)):
            fn = info["fn"]
            schannel = info["schannel"]
            prefix = "" if schannel == "defaults" else schannel + "::"
            priority = priorities.get(schannel, 0)
            key = prefix + fn
            if key in index:
                # Copy the link information so the resolver knows this is installed
                index[key]["link"] = info.get("link")
            else:
                # only if the package in not in the repodata, use local
                # conda-meta (with 'depends' defaulting to [])
                info.setdefault("depends", [])
                info["priority"] = priority
                index[key] = info
    return index