python反编译chm文件并生成pdf文件
2024-08-25 04:36:23
# -*- 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)
最新文章
- SharePoint Style Library的权限问题
- atitit.解决net.sf.json.JSONException There is a cycle in the hierarchy
- File存储 - 文件存储
- c++实现两个文件的拼接。
- Uva12504 Updating a Dictonary
- Ubuntu CTRL+ALT+F1~F6 进入命令模式后不支持中文显示的解决办法
- Android Bitmap实战技巧
- GCD(1222)Wolf and Rabbit
- 【期望DP】
- How to execute tons of tasks parallelly with TPL method?
- kali 2017更新源
- crm 数据展示 和分页思想(一)
- 蓝牙baseband概述
- 我的集合学习笔记--LinkedList
- day13 for内部机制详解,迭代器
- api-gateway-engine知识点(2)
- Python数据分析-Day1-Numpy模块
- postman使用方法
- cloud配置中心遇到的坑
- 如何使用git管理代码