示例#1
0
 def test_terminal_colors(self):
     # since other test might disable ansi colors
     # we need to ensure it is enabled
     enable_ANSI_colors()
     assert ansi('reset') != ''
     test = '@_This is underlined@|'
     rslt = '\033[4mThis is underlined\033[0m\033[0m'
     assert fmt(test) == rslt
     test = 'This has bad stuff @! @/ @_ @| OK!'
     test = sanitize(test)
     rslt = 'This has bad stuff @! @/ @_ @| OK!\033[0m'
     assert fmt(test) == rslt
     test = char(2018)
     test = sanitize(test)
     rslt = char(2018)
     assert test == rslt
 def test_terminal_colors(self):
     # since other test might disable ansi colors
     # we need to ensure it is enabled
     enable_ANSI_colors()
     assert ansi('reset') != ''
     test = '@_This is underlined@|'
     rslt = '\033[4mThis is underlined\033[0m\033[0m'
     assert fmt(test) == rslt
     test = 'This has bad stuff @! @/ @_ @| OK!'
     test = sanitize(test)
     rslt = 'This has bad stuff @! @/ @_ @| OK!\033[0m'
     assert fmt(test) == rslt
     test = char(2018)
     test = sanitize(test)
     rslt = char(2018)
     assert test == rslt
示例#3
0
def colorize_line(line):
    cline = sanitize(line)
    cline = cline.replace(
        '-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
        '-- @{pf}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@|')
    if line.startswith('-- ~~'):
        # -- ~~  -
        cline = cline.replace('~~ ', '@{pf}~~ @|')
        cline = cline.replace(' - ', ' - @!@{bf}')
        cline = cline.replace('(', '@|(')
        cline = cline.replace('(plain cmake)', '@|(@{rf}plain cmake@|)')
        cline = cline.replace('(unknown)', '@|(@{yf}unknown@|)')
    if line.startswith('-- +++'):
        # -- +++ add_subdirectory(package)
        cline = cline.replace('+++', '@!@{gf}+++@|')
        cline = cline.replace('kin package: \'', 'kin package: \'@!@{bf}')
        cline = cline.replace(')', '@|)')
        cline = cline.replace('\'\n', '@|\'\n')
        cline = cline.replace('cmake package: \'', 'cmake package: \'@!@{bf}')
        cline = cline.replace('\'\n', '@|\'\n')
    if line.startswith('-- ==>'):
        cline = cline.replace('-- ==>', '-- @!@{bf}==>@|')
    if line.lower().startswith('warning'):
        # WARNING
        cline = ansi('yf') + cline
    if line.startswith('CMake Warning'):
        # CMake Warning...
        cline = cline.replace('CMake Warning', '@{yf}@!CMake Warning@|')
    if line.startswith('ERROR:'):
        # ERROR:
        cline = cline.replace('ERROR:', '@!@{rf}ERROR:@|')
    if line.startswith('[guoguo]'):
        # guoguo:
        cline = cline.replace('[guoguo]:', '@!@{rf}[guoguo]@|')
    if line.startswith('CMake Error'):
        # CMake Error...
        cline = cline.replace('CMake Error', '@{rf}@!CMake Error@|')
    if line.startswith('Call Stack (most recent call first):'):
        # CMake Call Stack
        cline = cline.replace('Call Stack (most recent call first):',
                              '@{cf}@_Call Stack (most recent call first):@|')
    return fmt(cline)
示例#4
0
def colorize_line(line):
    cline = sanitize(line)
    cline = cline.replace(
        '-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
        '-- @{pf}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@|'
    )
    if line.startswith('-- ~~'):
        # -- ~~  -
        cline = cline.replace('~~ ', '@{pf}~~ @|')
        cline = cline.replace(' - ', ' - @!@{bf}')
        cline = cline.replace('(', '@|(')
        cline = cline.replace('(metapackage)', '@|(@{cf}metapackage@|)')
        cline = cline.replace('(plain cmake)', '@|(@{rf}plain cmake@|)')
        cline = cline.replace('(unknown)', '@|(@{yf}unknown@|)')
    if line.startswith('-- +++'):
        # -- +++ add_subdirectory(package)
        cline = cline.replace('+++', '@!@{gf}+++@|')
        cline = cline.replace('kin package: \'', 'kin package: \'@!@{bf}')
        cline = cline.replace(')', '@|)')
        cline = cline.replace('metapackage: \'', 'metapackage: \'@!@{bf}')
        cline = cline.replace('\'\n', '@|\'\n')
        cline = cline.replace('cmake package: \'', 'cmake package: \'@!@{bf}')
        cline = cline.replace('\'\n', '@|\'\n')
    if line.startswith('-- ==>'):
        cline = cline.replace('-- ==>', '-- @!@{bf}==>@|')
    if line.lower().startswith('warning'):
        # WARNING
        cline = ansi('yf') + cline
    if line.startswith('CMake Warning'):
        # CMake Warning...
        cline = cline.replace('CMake Warning', '@{yf}@!CMake Warning@|')
    if line.startswith('ERROR:'):
        # ERROR:
        cline = cline.replace('ERROR:', '@!@{rf}ERROR:@|')
    if line.startswith('CMake Error'):
        # CMake Error...
        cline = cline.replace('CMake Error', '@{rf}@!CMake Error@|')
    if line.startswith('Call Stack (most recent call first):'):
        # CMake Call Stack
        cline = cline.replace('Call Stack (most recent call first):',
                              '@{cf}@_Call Stack (most recent call first):@|')
    return fmt(cline)
示例#5
0
def colorize_line(line):
    cline = sanitize(line)
    cline = cline.replace(
        "-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
        "-- @{pf}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@|",
    )
    if line.startswith("-- ~~"):
        # -- ~~  -
        cline = cline.replace("~~ ", "@{pf}~~ @|")
        cline = cline.replace(" - ", " - @!@{bf}")
        cline = cline.replace("(", "@|(")
        cline = cline.replace("(plain cmake)", "@|(@{rf}plain cmake@|)")
        cline = cline.replace("(unknown)", "@|(@{yf}unknown@|)")
    if line.startswith("-- +++"):
        # -- +++ add_subdirectory(package)
        cline = cline.replace("+++", "@!@{gf}+++@|")
        cline = cline.replace("kin package: '", "kin package: '@!@{bf}")
        cline = cline.replace(")", "@|)")
        cline = cline.replace("'\n", "@|'\n")
        cline = cline.replace("cmake package: '", "cmake package: '@!@{bf}")
        cline = cline.replace("'\n", "@|'\n")
    if line.startswith("-- ==>"):
        cline = cline.replace("-- ==>", "-- @!@{bf}==>@|")
    if line.lower().startswith("warning"):
        # WARNING
        cline = ansi("yf") + cline
    if line.startswith("CMake Warning"):
        # CMake Warning...
        cline = cline.replace("CMake Warning", "@{yf}@!CMake Warning@|")
    if line.startswith("ERROR:"):
        # ERROR:
        cline = cline.replace("ERROR:", "@!@{rf}ERROR:@|")
    if line.startswith("CMake Error"):
        # CMake Error...
        cline = cline.replace("CMake Error", "@{rf}@!CMake Error@|")
    if line.startswith("Call Stack (most recent call first):"):
        # CMake Call Stack
        cline = cline.replace("Call Stack (most recent call first):", "@{cf}@_Call Stack (most recent call first):@|")
    return fmt(cline)