예제 #1
0
 def printHeader(self, filePath):
     from stat import ST_SIZE
     fileSize = os.stat(filePath)[ST_SIZE]
     size_str = formatSize(fileSize)
     print("\n%s\t%s[ %s ]%s" %
           (boldText(os.path.basename(filePath),
                     HEADER_COLOR()), HEADER_COLOR(), size_str, Fore.RESET))
     print("-" * 79)
예제 #2
0
파일: __init__.py 프로젝트: peppy0510/eyeD3
    def _getFileHeader(path, width):
        path = pathlib.Path(path)
        file_size = path.stat().st_size
        path_str = str(path)
        size_str = formatSize(file_size)
        size_len = len(size_str) + 5
        if len(path_str) + size_len >= width:
            path_str = "..." + str(path)[-(75 - size_len):]
        padding_len = width - len(path_str) - size_len

        return "{path}{color}{padding}[ {size} ]{reset}"\
               .format(path=boldText(path_str, c=HEADER_COLOR()),
                       color=HEADER_COLOR(),
                       padding=" " * padding_len,
                       size=size_str,
                       reset=Fore.RESET)
예제 #3
0
def test_printHeader():
    eyed3.utils.console.USE_ANSI = False
    with RedirectStdStreams() as out:
        printHeader("Furthur")
    assert_equal(out.stdout.read(), "Furthur\n")

    eyed3.utils.console.USE_ANSI = True
    with RedirectStdStreams() as out:
        printHeader("Furthur")
    assert_equal(out.stdout.read(),
                 "%sFurthur%s\n" % (HEADER_COLOR(), Fore.RESET))