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 ...
随机推荐
- HTML5入门7---"session的会话缓存"和"localStorage的cookie"缓存数据
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Hibernate逍遥游记-第15章处理并发问题-002悲观锁
1. 2. hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.connection.driver_class=com.mys ...
- java:异常处理
异常:编译正常,但运行出错,会中断正常指令流 RuntimeException:运行时异常 分为:uncheck exception.和check exception(除了RuntimeExcepti ...
- 机器学习 —— 概率图模型(Homework: Exact Inference)
在前三周的作业中,我构造了概率图模型并调用第三方的求解器对器进行了求解,最终获得了每个随机变量的分布(有向图),最大后验分布(双向图).本周作业的主要内容就是自行编写概率图模型的求解器.实际上,从根本 ...
- 卷积神经网络Convolutional Neural Networks
Convolutional Neural Networks NOTE: This tutorial is intended for advanced users of TensorFlow and a ...
- IOS基础框架
GameKit 为游戏提供网络功能:点对点互联和游戏中的语音交流 AddressBook 提供访问用户联系人信息的功能 AddressBookUI 提供一个用户界面,用于显示存储在地址簿中的联系人信息 ...
- JSTL、EL、ONGL、Struts标签的区别与使用
一.JSTL 来源 我们使用JSP开发信息展现非常方便,也可嵌入java代码用来实现相关逻辑,但同样带来了很多问题: jsp维护难度增加 出事提示不明确,不容易提示 分工不明确等 解决上面的问题可以 ...
- Atheros AR9485 ubuntu 10.04 驱动安装及networking disable问题解决
Laptop: ACER Aspire 5733-6629 Wireless:Lite-on HB125, CHIPS: Atheros AR9485 Ubuntu: 10.04LTS (2.6.32 ...
- UVA 11916 Emoogle Grid(同余模)
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- [Codeforces676B]Pyramid of Glasses(递推,DP)
题目链接:http://codeforces.com/problemset/problem/676/B 递推,dp(i, j)表示第i层第j个杯子,从第一层开始向下倒,和数塔一样的题.每个杯子1个时间 ...