def term_width():
    """Get the width (columns) of the terminal."""
    fallback = config['ui']['terminal_width'].get(int)

    # The fcntl and termios modules are not available on non-Unix
    # platforms, so we fall back to a constant.
    try:
        import fcntl
        import termios
    except ImportError:
        return fallback

    try:
        buf = fcntl.ioctl(0, termios.TIOCGWINSZ, ' ' * 4)
    except __HOLE__:
        return fallback
    try:
        height, width = struct.unpack(b'hh', buf)
    except struct.error:
        return fallback
    return width
dataset/ETHPy150Open beetbox/beets/beets/ui/__init__.py/term_width