一个用于操作苹果注释记号演示文件的工具。
keynote-parser的Python项目详细描述
基调分析器
keynote-parser
是一个用于解包和重新打包的python模块
Apple Keynote.key
文件。支持基调
Keynote 8.3版生成的文件(截至2019年1月)。
Keynote使用专有的压缩二进制格式存储其演示文稿。
此格式由包含图像和视频的zip文件以及
Snappy-压缩
Protobuf.iwa
包含
元数据、文本和演示文稿中使用的所有其他定义。
keynote-parser
将这些组件文件解压到目录中的.yaml
文件中,
通过文本编辑器和/或脚本使它们可编辑,然后允许重新打包这些
文件到工作注释记号存档中。
你能用这个做什么?好吧,我用它来实现git中注释记号文件的版本控制, 这使得diff更容易理解(而不是二进制),以及修改文本 在注释记号文件中响应外部脚本。 (例如:演示前从数据库更新的数据)
安装
pip install keynote-parser
用法
# Unpack MyPresentation.key into ./MyPresentation/ keynote-parser unpack MyPresentation.key # Re-pack ./MyPresentation/ into MyPresentation.out.key keynote-parser pack ./MyPresentation/ # List the files within a Keynote archive keynote-parser ls MyPresentation.key # Dump a particular .iwa file into its yaml representation on stdout keynote-parser cat MyPresentation.key /Index/Slide-00001.iwa # Replace text within a Keynote file in-place keynote-parser replace MyPresentation.key --find "hello world" --replace "hello dolly"
格式
keynote-parser
支持从传入的json文件读取替换列表
作为--replacements
。此文件的格式必须为:
{"replacements":[{"find":"regexp to search for","replace":"string to replace with"},...]}
此参数可以传递给keynote-parser replace
以替换注释记号中的文本
归档到位。它也可以传递给keynote-parser pack
来打包目录
在注释记号文件中,同时替换文字。
替换图像
json格式也可以用来替换注释记号文件中的图像。 这样做:
- 使用
keynote-parser ls
命令确定要替换的图像的名称。 - 将
find
模式设置为图像的名称,去掉-\d\d\d
后缀。 - 将
replace
字段设置为替换映像的本地路径。
keynote-parser
将自动重新缩放替换图像以适应
目标图像的大小。
更新
因为keynote-parser
包含从keynote副本中提取的私有protobuf定义,
新版本的keynote将不可避免地创建.key
文件,这些文件无法被keynote-parser
读取。
随着新版本的Keynote发布,必须执行以下步骤:
- 在keynote的新副本上运行proto-dump以转储新的proto文件。
- protobuf定义中的任何
.
字符都必须手动更改为_
字符。
- protobuf定义中的任何
- 使用
lldb
(或任何其他调试器)连接到Keynote
的运行副本并手动复制 将[TSPRegistry sharedRegistry]
的结果转化为mapping.py
。- macos>;=10.11的版本可能会保护keynote不被调试器附加到- 附加,temporarily disable System IntegrityProtection 才能得到这些数据。
学分
keynote-parser
是由Peter Sobot创建的,但主要基于prior
work由Sean Patrick O'Brien创建的。
o'brien的格式文档副本包含在docs
文件夹中,供子孙后代使用。
许可证
此存储库中的所有代码都是在mit许可证下获得许可的,除了包含自己许可证的protobuf_patch.py
。
Copyright 2019 Peter Sobot
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.