# -*- coding: utf-8 -*-

 import os
import os.path
import logging
import pdfkit original_chm = r'C:\Users\hushaojun\Documents\canoe\Help01\CAPLfunctions.chm'
root_dir = r'C:\Users\hushaojun\Documents\canoe\Help01\canoe\Topics'
seperator = os.sep # HH.EXE -decompile <输出路径> <目标chm文件> logging.basicConfig(level=logging.WARNING,
format='%(asctime)s %(pathname)s %(filename)s %(funcName)s [line:%(lineno)d] %(levelname)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
filename='all_file_name.log',
filemode='w+') #深度优先算法
def recursionFunction(level, path):
for file_content in os.listdir(path): #列举显示所有文件夹下的内容
#“-”用于显示目录层次结构
full_path_name = os.path.join(path, file_content)
print('-'*(level+1) + full_path_name) if os.path.isdir(full_path_name): #如果是文件夹就递归显示
recursionFunction(level+1, full_path_name)
else: #如果是文件那就要直接显示
(shotname, extension) = os.path.splitext(file_content) logging.error('文件全名为:' + full_path_name)
print('文件名为:' + shotname)
print('文件后缀名为:' + extension) pdf_file_name = os.path.join(path, shotname + '.pdf') if (not os.path.exists(pdf_file_name)) and ((extension == '.htm') or (extension == '.html')):
try:
pdfkit.from_file(full_path_name, pdf_file_name)
except OSError:
print('just skip!')
except Exception as e:
print(type(e)) if __name__ == '__main__':
decomplile_cmd = 'HH.EXE -decompile %s %s' % (root_dir, original_chm)
os.system(decomplile_cmd)
recursionFunction(0, root_dir)

最新文章

  1. SharePoint Style Library的权限问题
  2. atitit.解决net.sf.json.JSONException There is a cycle in the hierarchy
  3. File存储 - 文件存储
  4. c++实现两个文件的拼接。
  5. Uva12504 Updating a Dictonary
  6. Ubuntu CTRL+ALT+F1~F6 进入命令模式后不支持中文显示的解决办法
  7. Android Bitmap实战技巧
  8. GCD(1222)Wolf and Rabbit
  9. 【期望DP】
  10. How to execute tons of tasks parallelly with TPL method?
  11. kali 2017更新源
  12. crm 数据展示 和分页思想(一)
  13. 蓝牙baseband概述
  14. 我的集合学习笔记--LinkedList
  15. day13 for内部机制详解,迭代器
  16. api-gateway-engine知识点(2)
  17. Python数据分析-Day1-Numpy模块
  18. postman使用方法
  19. cloud配置中心遇到的坑
  20. 如何使用git管理代码

热门文章

  1. Swift:playground
  2. Java集合类: Set、List、Map、Queue使用场景
  3. 64位Windows操作系统中的注冊表
  4. Eclipse SDK Android Studio 下载地址
  5. Caffe的solver参数介绍
  6. mac或者linux磁力下载方法:远离渣雷
  7. 内核态(Kernel Mode)与用户态(User Mode)
  8. mysqlpump:更加合理的mysql数据库逻辑备份工具
  9. Nutch1.7学习笔记:基本环境搭建及使用
  10. impala 导出CSV 或excel