예제 #1
0
 def test_color_code_for_path_with_double_extension(self):
     temp_dir = self.make_temp_dir()
     tar_gz_path = os.path.join(temp_dir, "test.tar.gz")
     open(tar_gz_path, "w").close()
     self.assertEquals(
         lscolors.color_code_for_path(tar_gz_path, self.COLOR_CODES),
         self.TAR_GZ_COLOR)
예제 #2
0
 def test_color_code_for_path_with_extension(self):
     temp_dir = self.make_temp_dir()
     awk_path = os.path.join(temp_dir, "test.awk")
     open(awk_path, "w").close()
     self.assertEquals(
         lscolors.color_code_for_path(awk_path, self.COLOR_CODES),
         self.AWK_COLOR)
예제 #3
0
 def test_color_code_for_path_without_extension(self):
     temp_dir = self.make_temp_dir()
     file_path = os.path.join(temp_dir, "foo")
     open(file_path, "w").close()
     self.assertEquals(
         lscolors.color_code_for_path(file_path, {"fi": "file color"}),
         "file color")
예제 #4
0
 def colorise_completion(completion):
     completion_path = os.path.join(self.cwd.get_cwd(), completion)
     color_code = lscolors.color_code_for_path(completion_path, 
                                               Reader.COLOR_CODES)
     colored_completion = lscolors.ColoredString(completion)
     colored_completion.set_color(color_code)
     return colored_completion
예제 #5
0
def test_against_ls(root_path, environment):
    process = subprocess.Popen(
        ["ls", "--color=always", "-R", root_path],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environment)
    stdout, stderr = process.communicate()
    color_codes = lscolors.get_color_codes(environment)
    for line in stdout.splitlines():
        line = line.strip()
        if line == "":
            continue
        if line.endswith(":"):
            current_directory = line[:-1]
            continue
        ls_color_code, filename = parse_ls_line(line)
        path = os.path.join(current_directory, filename)
        if os.path.exists(path):  # Some paths are already gone. e.g. in /proc
            color_code = lscolors.color_code_for_path(path, color_codes)
            if color_code != ls_color_code:
                print "%s %r %r" % (path, color_code, ls_color_code)
예제 #6
0
파일: tools.py 프로젝트: ahamilton/vigil
def _charstyle_of_path(path):
    color_code = lscolors.color_code_for_path(path, _LS_COLOR_CODES)
    return (termstr.CharStyle() if color_code is None else
            _convert_lscolor_code_to_charstyle(color_code))