def _line_segment_with_colons(linefmt, align, colwidth):
    """Return a segment of a horizontal line with optional colons which
    indicate column's alignment (as in `pipe` output format)."""
    fill = linefmt.hline
    w = colwidth
    if align in ['right', 'decimal']:
        return fill[0] * (w - 1) + ':'
    elif align == 'center':
        return ':' + fill[0] * (w - 2) + ':'
    elif align == 'left':
        return ':' + fill[0] * (w - 1)
    else:
        return fill[0] * w
