예제 #1
0
def mirror_create(args):
    """Create a directory to be used as a spack mirror, and fill it with
       package archives."""
    mirror_specs = _determine_specs_to_mirror(args)

    mirror = spack.mirror.Mirror(args.directory
                                 or spack.config.get('config:source_cache'))

    directory = url_util.format(mirror.push_url)

    existed = web_util.url_exists(directory)

    # Actually do the work to create the mirror
    present, mirrored, error = spack.mirror.create(directory, mirror_specs,
                                                   args.skip_unstable_versions)
    p, m, e = len(present), len(mirrored), len(error)

    verb = "updated" if existed else "created"
    tty.msg("Successfully %s mirror in %s" % (verb, directory),
            "Archive stats:", "  %-4d already present" % p, "  %-4d added" % m,
            "  %-4d failed to fetch." % e)
    if error:
        tty.error("Failed downloads:")
        tty.colify(s.cformat("{name}{@version}") for s in error)
        sys.exit(1)
예제 #2
0
def print_text_info(pkg):
    """Print out a plain text description of a package."""
    print "Package:   ", pkg.name
    print "Homepage:  ", pkg.homepage

    print
    print "Safe versions:  "

    if not pkg.versions:
        print("    None")
    else:
        pad = padder(pkg.versions, 4)
        for v in reversed(sorted(pkg.versions)):
            f = fs.for_package_version(pkg, v)
            print "    %s%s" % (pad(v), str(f))

    print
    print "Variants:"
    if not pkg.variants:
        print "    None"
    else:
        pad = padder(pkg.variants, 4)

        maxv = max(len(v) for v in sorted(pkg.variants))
        fmt = "%%-%ss%%-10s%%s" % (maxv + 4)

        print "    " + fmt % ('Name',   'Default',   'Description')
        print
        for name in sorted(pkg.variants):
            v = pkg.variants[name]
            default = 'on' if v.default else 'off'

            lines = textwrap.wrap(v.description)
            lines[1:] = ["      " + (" " * maxv) + l for l in lines[1:]]
            desc = "\n".join(lines)

            print "    " + fmt % (name, default, desc)

    print
    print "Dependencies:"
    if pkg.dependencies:
        colify(pkg.dependencies, indent=4)
    else:
        print "    None"

    print
    print "Virtual packages: "
    if pkg.provided:
        for spec, when in pkg.provided.items():
            print "    %s provides %s" % (when, spec)
    else:
        print "    None"

    print
    print "Description:"
    if pkg.__doc__:
        print pkg.format_doc(indent=4)
    else:
        print "    None"
예제 #3
0
파일: find.py 프로젝트: d-tk/spack
def display_specs(specs, **kwargs):
    mode = kwargs.get('mode', 'short')
    hashes = kwargs.get('long', False)
    namespace = kwargs.get('namespace', False)

    hlen = 7
    if kwargs.get('very_long', False):
        hashes = True
        hlen = None

    # Make a dict with specs keyed by architecture and compiler.
    index = index_by(specs, ('architecture', 'compiler'))

    # Traverse the index and print out each package
    for i, (architecture, compiler) in enumerate(sorted(index)):
        if i > 0: print

        header = "%s{%s} / %s{%s}" % (
            spack.spec.architecture_color, architecture,
            spack.spec.compiler_color, compiler)
        tty.hline(colorize(header), char='-')

        specs = index[(architecture,compiler)]
        specs.sort()

        nfmt = '.' if namespace else '_'
        abbreviated = [s.format('$%s$@$+' % nfmt, color=True) for s in specs]
        if mode == 'paths':
            # Print one spec per line along with prefix path
            width = max(len(s) for s in abbreviated)
            width += 2
            format = "    %%-%ds%%s" % width

            for abbrv, spec in zip(abbreviated, specs):
                if hashes:
                    print gray_hash(spec, hlen),
                print format % (abbrv, spec.prefix)

        elif mode == 'deps':
            for spec in specs:
                print spec.tree(
                    format='$%s$@$+' % nfmt,
                    color=True,
                    indent=4,
                    prefix=(lambda s: gray_hash(s, hlen)) if hashes else None)

        elif mode == 'short':
            def fmt(s):
                string = ""
                if hashes:
                    string += gray_hash(s, hlen) + ' '
                string += s.format('$-%s$@$+' % nfmt, color=True)

                return string
            colify(fmt(s) for s in specs)

        else:
            raise ValueError(
                "Invalid mode for display_specs: %s. Must be one of (paths, deps, short)." % mode)
예제 #4
0
파일: find.py 프로젝트: tobbez/spack
def display_specs(specs, **kwargs):
    mode = kwargs.get('mode', 'short')
    hashes = kwargs.get('long', False)
    namespace = kwargs.get('namespace', False)

    hlen = 7
    if kwargs.get('very_long', False):
        hashes = True
        hlen = None

    # Make a dict with specs keyed by architecture and compiler.
    index = index_by(specs, ('architecture', 'compiler'))

    # Traverse the index and print out each package
    for i, (architecture, compiler) in enumerate(sorted(index)):
        if i > 0: print

        header = "%s{%s} / %s{%s}" % (
            spack.spec.architecture_color, architecture,
            spack.spec.compiler_color, compiler)
        tty.hline(colorize(header), char='-')

        specs = index[(architecture,compiler)]
        specs.sort()

        nfmt = '.' if namespace else '_'
        abbreviated = [s.format('$%s$@$+' % nfmt, color=True) for s in specs]
        if mode == 'paths':
            # Print one spec per line along with prefix path
            width = max(len(s) for s in abbreviated)
            width += 2
            format = "    %%-%ds%%s" % width

            for abbrv, spec in zip(abbreviated, specs):
                if hashes:
                    print gray_hash(spec, hlen),
                print format % (abbrv, spec.prefix)

        elif mode == 'deps':
            for spec in specs:
                print spec.tree(
                    format='$%s$@$+' % nfmt,
                    color=True,
                    indent=4,
                    prefix=(lambda s: gray_hash(s, hlen)) if hashes else None)

        elif mode == 'short':
            def fmt(s):
                string = ""
                if hashes:
                    string += gray_hash(s, hlen) + ' '
                string += s.format('$-%s$@$+' % nfmt, color=True)

                return string
            colify(fmt(s) for s in specs)

        else:
            raise ValueError(
                "Invalid mode for display_specs: %s. Must be one of (paths, deps, short)." % mode)
예제 #5
0
파일: find.py 프로젝트: wnissen/spack
def display_specs(specs, **kwargs):
    mode = kwargs.get('mode', 'short')

    # Make a dict with specs keyed by architecture and compiler.
    index = index_by(specs, ('architecture', 'compiler'))

    # Traverse the index and print out each package
    for i, (architecture, compiler) in enumerate(sorted(index)):
        if i > 0: print

        header = "%s{%s} / %s{%s}" % (spack.spec.architecture_color,
                                      architecture, spack.spec.compiler_color,
                                      compiler)
        tty.hline(colorize(header), char='-')

        specs = index[(architecture, compiler)]
        specs.sort()

        abbreviated = [s.format('$_$@$+', color=True) for s in specs]
        if mode == 'paths':
            # Print one spec per line along with prefix path
            width = max(len(s) for s in abbreviated)
            width += 2
            format = "    %-{}s%s".format(width)

            for abbrv, spec in zip(abbreviated, specs):
                print format % (abbrv, spec.prefix)

        elif mode == 'deps':
            for spec in specs:
                print spec.tree(indent=4, format='$_$@$+$#', color=True),

        elif mode in ('short', 'long'):
            fmt = '$-_$@$+'
            if mode == 'long':
                fmt += '$#'
            colify(s.format(fmt, color=True) for s in specs)

        else:
            raise ValueError(
                "Invalid mode for display_specs: %s. Must be one of (paths, deps, short)."
                % mode)
예제 #6
0
파일: find.py 프로젝트: AaronTHolt/spack
def display_specs(specs, **kwargs):
    mode = kwargs.get('mode', 'short')

    # Make a dict with specs keyed by architecture and compiler.
    index = index_by(specs, ('architecture', 'compiler'))

    # Traverse the index and print out each package
    for i, (architecture, compiler) in enumerate(sorted(index)):
        if i > 0: print

        header = "%s{%s} / %s{%s}" % (
            spack.spec.architecture_color, architecture,
            spack.spec.compiler_color, compiler)
        tty.hline(colorize(header), char='-')

        specs = index[(architecture,compiler)]
        specs.sort()

        abbreviated = [s.format('$_$@$+', color=True) for s in specs]
        if mode == 'paths':
            # Print one spec per line along with prefix path
            width = max(len(s) for s in abbreviated)
            width += 2
            format = "    %-{}s%s".format(width)

            for abbrv, spec in zip(abbreviated, specs):
                print format % (abbrv, spec.prefix)

        elif mode == 'deps':
            for spec in specs:
                print spec.tree(indent=4, format='$_$@$+$#', color=True),

        elif mode in ('short', 'long'):
            fmt = '$-_$@$+'
            if mode == 'long':
                fmt += '$#'
            colify(s.format(fmt, color=True) for s in specs)

        else:
            raise ValueError(
                "Invalid mode for display_specs: %s. Must be one of (paths, deps, short)." % mode)
예제 #7
0
def info_text(pkg):
    """Print out a plain text description of a package."""
    print "Package:   ", pkg.name
    print "Homepage:  ", pkg.homepage

    print
    print "Safe versions:  "

    if not pkg.versions:
        print("None.")
    else:
        maxlen = max(len(str(v)) for v in pkg.versions)
        fmt = "%%-%ss" % maxlen
        for v in reversed(sorted(pkg.versions)):
            f = fs.for_package_version(pkg, v)
            print "    " + (fmt % v) + "    " + str(f)

    print
    print "Dependencies:"
    if pkg.dependencies:
        colify(pkg.dependencies, indent=4)
    else:
        print "    None"

    print
    print "Virtual packages: "
    if pkg.provided:
        for spec, when in pkg.provided.items():
            print "    %s provides %s" % (when, spec)
    else:
        print "    None"

    print
    print "Description:"
    if pkg.__doc__:
        print format_doc(pkg, indent=4)
    else:
        print "    None"
예제 #8
0
파일: info.py 프로젝트: AaronTHolt/spack
def print_text_info(pkg):
    """Print out a plain text description of a package."""
    print "Package:   ", pkg.name
    print "Homepage:  ", pkg.homepage

    print
    print "Safe versions:  "

    if not pkg.versions:
        print("None.")
    else:
        maxlen = max(len(str(v)) for v in pkg.versions)
        fmt = "%%-%ss" % maxlen
        for v in reversed(sorted(pkg.versions)):
            f = fs.for_package_version(pkg, v)
            print "    " + (fmt % v) + "    " + str(f)

    print
    print "Dependencies:"
    if pkg.dependencies:
        colify(pkg.dependencies, indent=4)
    else:
        print "    None"

    print
    print "Virtual packages: "
    if pkg.provided:
        for spec, when in pkg.provided.items():
            print "    %s provides %s" % (when, spec)
    else:
        print "    None"

    print
    print "Description:"
    if pkg.__doc__:
        print pkg.format_doc(indent=4)
    else:
        print "    None"
예제 #9
0
def display_specs(specs, **kwargs):
    mode = kwargs.get('mode', 'short')
    hashes = kwargs.get('long', False)
    namespace = kwargs.get('namespace', False)

    hlen = 7
    if kwargs.get('very_long', False):
        hashes = True
        hlen = None

    nfmt = '.' if namespace else '_'
    format_string = '$%s$@$+' % nfmt
    flags = kwargs.get('show_flags', False)
    if flags:
        format_string = '$%s$@$%%+$+' % nfmt

    # Make a dict with specs keyed by architecture and compiler.
    index = index_by(specs, ('architecture', 'compiler'))

    # Traverse the index and print out each package
    for i, (architecture, compiler) in enumerate(sorted(index)):
        if i > 0:
            print

        header = "%s{%s} / %s{%s}" % (spack.spec.architecture_color,
                                      architecture, spack.spec.compiler_color,
                                      compiler)
        tty.hline(colorize(header), char='-')

        specs = index[(architecture, compiler)]
        specs.sort()

        abbreviated = [s.format(format_string, color=True) for s in specs]
        if mode == 'paths':
            # Print one spec per line along with prefix path
            width = max(len(s) for s in abbreviated)
            width += 2
            format = "    %%-%ds%%s" % width

            for abbrv, spec in zip(abbreviated, specs):
                if hashes:
                    print(gray_hash(spec, hlen), )
                print(format % (abbrv, spec.prefix))

        elif mode == 'deps':
            for spec in specs:
                print(
                    spec.tree(format=format_string,
                              color=True,
                              indent=4,
                              prefix=(lambda s: gray_hash(s, hlen))
                              if hashes else None))

        elif mode == 'short':
            # Print columns of output if not printing flags
            if not flags:

                def fmt(s):
                    string = ""
                    if hashes:
                        string += gray_hash(s, hlen) + ' '
                    string += s.format('$-%s$@$+' % nfmt, color=True)

                    return string

                colify(fmt(s) for s in specs)
            # Print one entry per line if including flags
            else:
                for spec in specs:
                    # Print the hash if necessary
                    hsh = gray_hash(spec, hlen) + ' ' if hashes else ''
                    print(hsh + spec.format(format_string, color=True) + '\n')

        else:
            raise ValueError(
                "Invalid mode for display_specs: %s. Must be one of (paths,"
                "deps, short)." % mode)  # NOQA: ignore=E501
def print_text_info(pkg):
    """Print out a plain text description of a package."""

    header = section_title('{0}:   ').format(pkg.build_system_class) + pkg.name
    color.cprint(header)

    color.cprint('')
    color.cprint(section_title('Description:'))
    if pkg.__doc__:
        color.cprint(pkg.format_doc(indent=4))
    else:
        color.cprint("    None")

    color.cprint(section_title('Homepage: ') + pkg.homepage)

    if len(pkg.maintainers) > 0:
        mnt = " ".join(['@@' + m for m in pkg.maintainers])
        color.cprint('')
        color.cprint(section_title('Maintainers: ') + mnt)

    color.cprint('')
    color.cprint(section_title("Tags: "))
    if hasattr(pkg, 'tags'):
        tags = sorted(pkg.tags)
        colify(tags, indent=4)
    else:
        color.cprint("    None")

    color.cprint('')
    color.cprint(section_title('Preferred version:  '))

    if not pkg.versions:
        color.cprint(version('    None'))
        color.cprint('')
        color.cprint(section_title('Safe versions:  '))
        color.cprint(version('    None'))
    else:
        pad = padder(pkg.versions, 4)

        # Here we sort first on the fact that a version is marked
        # as preferred in the package, then on the fact that the
        # version is not develop, then lexicographically
        l = [(value.get('preferred', False), not key.isdevelop(), key)
             for key, value in pkg.versions.items()]
        l = sorted(l)
        _, _, preferred = l.pop()

        f = fs.for_package_version(pkg, preferred)
        line = version('    {0}'.format(pad(preferred))) + str(f)
        color.cprint(line)
        color.cprint('')
        color.cprint(section_title('Safe versions:  '))

        for v in reversed(sorted(pkg.versions)):
            f = fs.for_package_version(pkg, v)
            line = version('    {0}'.format(pad(v))) + str(f)
            color.cprint(line)

    color.cprint('')
    color.cprint(section_title('Variants:'))

    formatter = VariantFormatter(pkg.variants)
    for line in formatter.lines:
        color.cprint(line)

    color.cprint('')
    color.cprint(section_title('Installation Phases:'))
    phase_str = ''
    for phase in pkg.phases:
        phase_str += "    {0}".format(phase)
    color.cprint(phase_str)

    for deptype in ('build', 'link', 'run'):
        color.cprint('')
        color.cprint(section_title('%s Dependencies:' % deptype.capitalize()))
        deps = sorted(pkg.dependencies_of_type(deptype))
        if deps:
            colify(deps, indent=4)
        else:
            color.cprint('    None')

    color.cprint('')
    color.cprint(section_title('Virtual Packages: '))
    if pkg.provided:
        inverse_map = {}
        for spec, whens in pkg.provided.items():
            for when in whens:
                if when not in inverse_map:
                    inverse_map[when] = set()
                inverse_map[when].add(spec)
        for when, specs in reversed(sorted(inverse_map.items())):
            line = "    %s provides %s" % (when.colorized(), ', '.join(
                s.colorized() for s in specs))
            print(line)

    else:
        color.cprint("    None")

    color.cprint('')
예제 #11
0
def display_specs(specs, **kwargs):
    mode = kwargs.get('mode', 'short')
    hashes = kwargs.get('long', False)
    namespace = kwargs.get('namespace', False)
    flags = kwargs.get('show_flags', False)
    variants = kwargs.get('variants', False)

    hlen = 7
    if kwargs.get('very_long', False):
        hashes = True
        hlen = None

    nfmt = '.' if namespace else '_'
    ffmt = '$%+' if flags else ''
    vfmt = '$+' if variants else ''
    format_string = '$%s$@%s%s' % (nfmt, ffmt, vfmt)

    # Make a dict with specs keyed by architecture and compiler.
    index = index_by(specs, ('architecture', 'compiler'))

    # Traverse the index and print out each package
    for i, (architecture, compiler) in enumerate(sorted(index)):
        if i > 0:
            print

        header = "%s{%s} / %s{%s}" % (spack.spec.architecture_color,
                                      architecture, spack.spec.compiler_color,
                                      compiler)
        tty.hline(colorize(header), char='-')

        specs = index[(architecture, compiler)]
        specs.sort()

        abbreviated = [s.format(format_string, color=True) for s in specs]
        if mode == 'paths':
            # Print one spec per line along with prefix path
            width = max(len(s) for s in abbreviated)
            width += 2
            format = "    %%-%ds%%s" % width

            for abbrv, spec in zip(abbreviated, specs):
                prefix = gray_hash(spec, hlen) if hashes else ''
                print prefix + (format % (abbrv, spec.prefix))

        elif mode == 'deps':
            for spec in specs:
                print(spec.tree(
                    format=format_string,
                    color=True,
                    indent=4,
                    prefix=(lambda s: gray_hash(s, hlen)) if hashes else None))

        elif mode == 'short':
            # Print columns of output if not printing flags
            if not flags:

                def fmt(s):
                    string = ""
                    if hashes:
                        string += gray_hash(s, hlen) + ' '
                    string += s.format('$-%s$@%s' % (nfmt, vfmt), color=True)

                    return string

                colify(fmt(s) for s in specs)
            # Print one entry per line if including flags
            else:
                for spec in specs:
                    # Print the hash if necessary
                    hsh = gray_hash(spec, hlen) + ' ' if hashes else ''
                    print(hsh + spec.format(format_string, color=True) + '\n')

        else:
            raise ValueError(
                "Invalid mode for display_specs: %s. Must be one of (paths,"
                "deps, short)." % mode)
예제 #12
0
def rst_table(elts):
    """Print out a RST-style table."""
    cols = StringIO()
    ncol, widths = colify(elts, output=cols, tty=True)
    header = " ".join("=" * (w-1) for w in widths)
    return "%s\n%s%s" % (header, cols.getvalue(), header)
예제 #13
0
def print_text_info(pkg):
    """Print out a plain text description of a package."""
    header = "{0}:   ".format(pkg.build_system_class)

    print header, pkg.name
    whitespaces = ''.join([' '] * (len(header) - len("Homepage: ")))
    print "Homepage:", whitespaces, pkg.homepage

    print
    print "Safe versions:  "

    if not pkg.versions:
        print("    None")
    else:
        pad = padder(pkg.versions, 4)
        for v in reversed(sorted(pkg.versions)):
            f = fs.for_package_version(pkg, v)
            print "    %s%s" % (pad(v), str(f))

    print
    print "Variants:"
    if not pkg.variants:
        print "    None"
    else:
        pad = padder(pkg.variants, 4)

        maxv = max(len(v) for v in sorted(pkg.variants))
        fmt = "%%-%ss%%-10s%%s" % (maxv + 4)

        print "    " + fmt % ('Name', 'Default', 'Description')
        print
        for name in sorted(pkg.variants):
            v = pkg.variants[name]
            default = 'on' if v.default else 'off'

            lines = textwrap.wrap(v.description)
            lines[1:] = ["      " + (" " * maxv) + l for l in lines[1:]]
            desc = "\n".join(lines)

            print "    " + fmt % (name, default, desc)

    print
    print "Installation Phases:"
    phase_str = ''
    for phase in pkg.phases:
        phase_str += "    {0}".format(phase)
    print phase_str

    for deptype in ('build', 'link', 'run'):
        print
        print "%s Dependencies:" % deptype.capitalize()
        deps = sorted(pkg.dependencies_of_type(deptype))
        if deps:
            colify(deps, indent=4)
        else:
            print "    None"

    print
    print "Virtual Packages: "
    if pkg.provided:
        for spec, when in pkg.provided.items():
            print "    %s provides %s" % (when, spec)
    else:
        print "    None"

    print
    print "Description:"
    if pkg.__doc__:
        print pkg.format_doc(indent=4)
    else:
        print "    None"
예제 #14
0
def print_text_info(pkg):
    """Print out a plain text description of a package."""
    header = "{0}:   ".format(pkg.build_system_class)

    print header, pkg.name
    whitespaces = ''.join([' '] * (len(header) - len("Homepage: ")))
    print "Homepage:", whitespaces, pkg.homepage

    print
    print "Safe versions:  "

    if not pkg.versions:
        print("    None")
    else:
        pad = padder(pkg.versions, 4)
        for v in reversed(sorted(pkg.versions)):
            f = fs.for_package_version(pkg, v)
            print "    %s%s" % (pad(v), str(f))

    print
    print "Variants:"
    if not pkg.variants:
        print "    None"
    else:
        pad = padder(pkg.variants, 4)

        maxv = max(len(v) for v in sorted(pkg.variants))
        fmt = "%%-%ss%%-10s%%s" % (maxv + 4)

        print "    " + fmt % ('Name',   'Default',   'Description')
        print
        for name in sorted(pkg.variants):
            v = pkg.variants[name]
            default = 'on' if v.default else 'off'

            lines = textwrap.wrap(v.description)
            lines[1:] = ["      " + (" " * maxv) + l for l in lines[1:]]
            desc = "\n".join(lines)

            print "    " + fmt % (name, default, desc)

    print
    print "Installation Phases:"
    phase_str = ''
    for phase in pkg.phases:
        phase_str += "    {0}".format(phase)
    print phase_str

    for deptype in ('build', 'link', 'run'):
        print
        print "%s Dependencies:" % deptype.capitalize()
        deps = sorted(pkg.dependencies_of_type(deptype))
        if deps:
            colify(deps, indent=4)
        else:
            print "    None"

    print
    print "Virtual Packages: "
    if pkg.provided:
        inverse_map = {}
        for spec, whens in pkg.provided.items():
            for when in whens:
                if when not in inverse_map:
                    inverse_map[when] = set()
                inverse_map[when].add(spec)
        for when, specs in reversed(sorted(inverse_map.items())):
            print "    %s provides %s" % (
                when, ', '.join(str(s) for s in specs))
    else:
        print "    None"

    print
    print "Description:"
    if pkg.__doc__:
        print pkg.format_doc(indent=4)
    else:
        print "    None"
예제 #15
0
def print_text_info(pkg):
    """Print out a plain text description of a package."""
    header = "{0}:   ".format(pkg.build_system_class)

    print(header, pkg.name)
    whitespaces = ''.join([' '] * (len(header) - len("Homepage: ")))
    print("Homepage:", whitespaces, pkg.homepage)

    print()
    print("Safe versions:  ")

    if not pkg.versions:
        print("    None")
    else:
        pad = padder(pkg.versions, 4)
        for v in reversed(sorted(pkg.versions)):
            f = fs.for_package_version(pkg, v)
            print("    %s%s" % (pad(v), str(f)))

    print()
    print("Variants:")

    formatter = VariantFormatter(pkg.variants)
    for line in formatter.lines:
        print(line)

    print()
    print("Installation Phases:")
    phase_str = ''
    for phase in pkg.phases:
        phase_str += "    {0}".format(phase)
    print(phase_str)

    for deptype in ('build', 'link', 'run'):
        print()
        print("%s Dependencies:" % deptype.capitalize())
        deps = sorted(pkg.dependencies_of_type(deptype))
        if deps:
            colify(deps, indent=4)
        else:
            print("    None")

    print()
    print("Virtual Packages: ")
    if pkg.provided:
        inverse_map = {}
        for spec, whens in pkg.provided.items():
            for when in whens:
                if when not in inverse_map:
                    inverse_map[when] = set()
                inverse_map[when].add(spec)
        for when, specs in reversed(sorted(inverse_map.items())):
            print("    %s provides %s" % (
                when, ', '.join(str(s) for s in specs)))
    else:
        print("    None")

    print()
    print("Description:")
    if pkg.__doc__:
        print(pkg.format_doc(indent=4))
    else:
        print("    None")
예제 #16
0
def rst_table(elts):
    """Print out a RST-style table."""
    cols = StringIO()
    ncol, widths = colify(elts, output=cols, tty=True)
    header = " ".join("=" * (w - 1) for w in widths)
    return "%s\n%s%s" % (header, cols.getvalue(), header)