#!/usr/bin/env python
"""path colorizer

Colors the path segments in each path given on stdin or in the file
specified in the argument.

"""
#########################################################################
# Copyright (C) 2013-2015  Wojciech Siewierski                          #
#                                                                       #
# This program is free software: you can redistribute it and/or modify  #
# it under the terms of the GNU General Public License as published by  #
# the Free Software Foundation, either version 3 of the License, or     #
# (at your option) any later version.                                   #
#                                                                       #
# This program is distributed in the hope that it will be useful,       #
# but WITHOUT ANY WARRANTY; without even the implied warranty of        #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
# GNU General Public License for more details.                          #
#                                                                       #
# You should have received a copy of the GNU General Public License     #
# along with this program.  If not, see <http://www.gnu.org/licenses/>. #
#########################################################################

import fileinput
import os
import sys

from string_colorizer import PathColorizer


def main():
    colorizer = PathColorizer()
    for line in fileinput.input():
        if sys.version_info < (3, 0):
            utf_line = line.decode('utf-8')
        else:
            utf_line = line
        path = utf_line.rstrip(os.linesep)
        print(colorizer.colorize_path(path))


if __name__ == '__main__':
    main()
