示例#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)
示例#2
0
文件: core.py 项目: kfei/code2html
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)
示例#3
0
 def test_root_starts_with_dot(self):
     root = '.'
     dir_name = './first/second'
     self.assertEqual(get_subdir_name(root, dir_name), 'first/second')
示例#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')