convert source code files to pdf format in python
import os
import sys def find_file(root_dir, type):
dirs_pool = [root_dir]
dest_pool = [] def scan_dir(directory):
entries = os.walk(directory)
for root, dirs, files in entries:
dirs_pool.extend([os.path.join(root, dir_entry) for dir_entry in dirs])
for file_entry in files:
if type in str(file_entry)[-len(type):]:
dest_pool.append(''.join(os.path.join(root, file_entry))) while dirs_pool:
scan_dir(dirs_pool.pop())
return dest_pool def gen_ps(root_dir, type):
vim_cmd = 'vim -me -e -c ":hardcopy >%.ps" -c ":q" '
ps2pdf_cmd = 'ps2pdf {filename}.ps {filename}.pdf'
dests = find_file(root_dir, type)
if not dests:
return
print 'found these source code files:'
for dest in dests:
print dest
print 'begin generate ps files!'
for dest in dests:
command = ''.join([vim_cmd, dest])
print command
os.system(command)
for dest in dests:
command = ps2pdf_cmd.format(filename=dest)
print command
os.system(command) if __name__ == '__main__':
if len(sys.argv) == 3:
gen_ps(sys.argv[1], sys.argv[2])
else:
print 'usage: python code2pdf.py directory filetype\n' \
'such as: python code2pdf.py /home/bruce/python .py'
convert source code files to pdf format in python的更多相关文章
- 3 Ways of JDK Source Code Attachment in Eclipse---reference
You wanna look at a JVM class while you are coding and you cannot. Here is the solution. First of al ...
- source code analyzer 功能强大的C/C++源代码分析软件 Celerity CRACK 破解版
特色 迅捷是一个功能强大的C/C++源代码分析软件.可以处理数百万行的源程序代码.支持标准及K&R风格的C/C++.对每一个打开的源代码工程,通过建立一个包含丰富交叉引用关系的数据库,显示其所 ...
- Visual Studio 2012,创建工程Build Driver,基于纯Source Code.
拿到一堆纯代码,怎么去Create Project,设置Include路径,lib路径,要不要Pre-compile技术,配置Project之间的依赖关系. SourcesConverter Bas ...
- Sound (audio file) player in java - working source code example
转载自:http://ganeshtiwaridotcomdotnp.blogspot.com/2011/12/sound-audio-file-player-in-java-working.html ...
- 编程等宽字体Source Code Pro(转)
Source Code Pro - 最佳的免费编程字体之一!来自 Adobe 公司的开源等宽字体下载 每一位程序员都有一套自己喜爱的代码编辑器与编程字体,譬如我们之前就推荐过一款"神 ...
- How to build the Robotics Library from source code on Windows
The Robotics Library is an open source C++ library for robot kinematics, motion planning and control ...
- How to build windows azure PowerShell Source Code
Download any version source code of Windows Azure Powershell from https://github.com/Azure/azure-sdk ...
- view class source code with JAD plugin in Eclipse
The default class viewer doesn't decompile the class file so you cannot open and check the source co ...
- Classic Source Code Collected
收藏一些经典的源码,持续更新!!! 1.深度学习框架(Deep Learning Framework). A:Caffe (Convolutional Architecture for Fast Fe ...
随机推荐
- darwin转发时,摄像机在3G和4G模式下的参数设置
darwin转发时,摄像机在3G和4G模式下的参数设置 我们转发的是摄像机的子码流,因为在不同的网络环境下,为了达到当前网络环境下最清晰,最流畅的目标,在转发前要根据使用的是3G还是4G及信号强度来自 ...
- PCL—综述—三维图像处理
点云模型与三维信息 三维图像是一种特殊的信息表达形式,其特征是表达的空间中三个维度的数据.和二维图像相比,三维图像借助第三个维度的信息,可以实现天然的物体-背景解耦.除此之外,对于视觉测量来说,物体的 ...
- JDBC学习总结(一)
1.JDBC概述 JDBC是一种可以执行SQL语句并可返回结果的Java API,其全称是Java DataBase Connectivity,也是一套面向对象的应用程序接口API,它由一组用 ...
- thrift总结
定义: Apache Thrift是一个facebook建立的RPC框架,现在是一个Apache的顶级项目.Thrift允许通过一个跨语言的定义文件的方式定义数据类型和服务接口,[这个文件]作为[RP ...
- TagHighlight
:UpdateTypesFile 命令会生成相应的上色高亮文件(生成的着色文件可以叫types_c.taghl)还有相应的tags文件,寻找tags或taghl_config.txt确定project ...
- apk反编译(3)smali语法
from http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html Dalvik opcodes Author: Gabor Paller Vx ...
- C#中跨线程读取控件值、设置控件值
编写应用程序时,涉及到大量数据处理.串口通信.Socket通信等都会用到多线程,多线程中如何跨线程调用主界面或其他界面下的控件是一个问题,利用invoke和delegate可以解决. delegate ...
- Asp.Net MVC Filter权限过滤使用说明
相信对权限过滤大家都不陌生,用户要访问一个页面时,先对其权限进行判断并进行相应的处理动作. mvc中是如何实现权限验证的? mvc中是根据路由配置来请求控制器类中的一个方法 在mvc框架中为程序员提供 ...
- Java EE (14) -- SSH配置
整合Spring与Struts1的三种方法总结 无论用那种方法来整合,第一步都是要装载spring的应用环境,有三种方式: #1. struts-config.xml <?xml version ...
- C# 编写的串口通信程序
如果,翻看我之前的博客,会找到一篇用I/O模拟IIC通信的程序文章.好吧,如果找不到可以点击这里,这里就不在赘述了,系统也已经完全调试通过了. 今天的任务是,把测试得到的数据在上位机的界面上显示出来, ...