예제 #1
0
def convert(source_path, file_name, output_path):
    """
    Call Vim to do the convertion.

    """
    ori_file = os.path.join(source_path, file_name)
    html_file = os.path.join(source_path, file_name + '.html')
    out_file = os.path.join(output_path, file_name + '.html')

    #  Just display, not actually performing the conversion
    print(u'Converting %s into %s' % (ori_file, out_file))

    global pre

    if not pre:
        global vimrc_file
        cmd = vim_command(vimrc_file) + [ori_file]

        try:
            subprocess.call(cmd, shell=get_shell())
            move(html_file, out_file)
        except Exception:
            sys.exit(u'ERROR: Fail to convert files, aborted.')
예제 #2
0
파일: core.py 프로젝트: kfei/code2html
def convert(source_path, file_name, output_path):
    """
    Call Vim to do the convertion.

    """
    ori_file = os.path.join(source_path, file_name)
    html_file = os.path.join(source_path, file_name + '.html')
    out_file = os.path.join(output_path, file_name + '.html')

    #  Just display, not actually performing the conversion
    print(u'Converting %s into %s' % (ori_file, out_file))

    global pre

    if not pre:
        global vimrc_file
        cmd = vim_command(vimrc_file) + [ori_file]

        try:
            subprocess.call(cmd, shell=get_shell())
            move(html_file, out_file)
        except Exception:
            sys.exit(u'ERROR: Fail to convert files, aborted.')
예제 #3
0
 def test_vim_command(self):
     vimrc_file = '/tmp/temporary-vimrc'
     expected = 'vim -u /tmp/temporary-vimrc -c TOhtml -c wqa'
     self.assertEqual(expected, ' '.join(vim_command(vimrc_file)))