Exemplo n.º 1
0
def traverse_files(in_out, includes):
    """
    Traverse the source directory, and send each file to
    convert. Without lost of the directory structure.
    """
    s_root = in_out[0]
    o_root = in_out[1]

    ignores = get_ignores()  # Apply the ignore list

    for dir_name, sub_dir_name, file_list in os.walk(s_root):
        # Ignore some sub directories, e.g. source code control
        for ig in ignores:
            match = re.search(ig, dir_name, re.IGNORECASE)
            if match:
                break
        else:
            subdir = get_subdir_name(s_root, dir_name)

            if subdir:
                # Create sub directories to preserve the original structure
                create_subdir(o_root, subdir)

            for f in file_list:
                if not included(f, includes):
                    continue  # Only do convert on included files
                if subdir:
                    convert(dir_name, f, os.path.join(o_root, subdir))
                else:
                    convert(dir_name, f, os.path.join(o_root))

    clean_vimrc(vimrc_file)
Exemplo n.º 2
0
def traverse_files(in_out, includes):
    """
    Traverse the source directory, and send each file to
    convert. Without lost of the directory structure.
    """
    s_root = in_out[0]
    o_root = in_out[1]

    ignores = get_ignores()  # Apply the ignore list

    for dir_name, sub_dir_name, file_list in os.walk(s_root):
        # Ignore some sub directories, e.g. source code control
        for ig in ignores:
            match = re.search(ig, dir_name, re.IGNORECASE)
            if match:
                break
        else:
            subdir = get_subdir_name(s_root, dir_name)

            if subdir:
                # Create sub directories to preserve the original structure
                create_subdir(o_root, subdir)

            for f in file_list:
                if not included(f, includes):
                    continue  # Only do convert on included files
                if subdir:
                    convert(dir_name, f, os.path.join(o_root, subdir))
                else:
                    convert(dir_name, f, os.path.join(o_root))

    clean_vimrc(vimrc_file)
Exemplo n.º 3
0
 def test_root_starts_with_dot(self):
     root = '.'
     dir_name = './first/second'
     self.assertEqual(get_subdir_name(root, dir_name), 'first/second')
Exemplo n.º 4
0
 def test_root_starts_with_wave(self):
     root = '~'
     dir_name = '~/first/second/third'
     self.assertEqual(get_subdir_name(root, dir_name), 'first/second/third')