Mac OS X文件预览生成器
pyglass的Python项目详细描述
#pyglass:预览Mac OS X文档
pyglass是一个python包装器,它围绕苹果的[quicklook](https://developer.apple.com/library/mac/documentation/userexperience/conceptual/quicklook_programming_guide/Introduction/Introduction.html)来提取预览图像 从公共文件类型。
另外,pyglass会环绕[sketchtool](http://bohemiancoding.com/sketch/tool/)来生成预览 来自[草图](bohemiancoding.com/sketch/)文件。
##用法
###基本预览
>>> import pyglass >>> previews = pyglass.preview('design_v1.sketch') >>> previews ['/var/folders/fq/xtn_qh1x6c3drpp3ycytx1fr0000gn/T/pyglassY92Xqs.png', '/var/folders/fq/xtn_qh1x6c3drpp3ycytx1fr0000gn/T/pyglassZ34Jab.png']
列表中返回的每个预览都是一个PNG,源文档中的每个页面都有一个PNG。
###草图
####页数
要获得一个简单的列表,请使用sketch.pages。请注意,每个页面中的切片和艺术板列表不会使用此命令自动填充。如果您对Artboard和Slice数据感兴趣,请分别使用“Sketch.List\u Artboards”和“Sketch.List\u Slices”。
>>> pyglass.sketch.pages('/Users/Vayu/Development/src/pyglass/tests/data/sketch/pages.sketch') [<Page: '<Page ( id="C10E136D-6E3D-40C9-AA6C-67C456893C6D", name="Something", bounds=<Bounds (x=-75.0, y=-128.0, width=541.0, height=399.0)>, slices=[], artboards=[] )>' >, <Page: '<Page ( id="AB21474C-3F41-4531-8433-9E01140E08EC", name="Another one", bounds=<Bounds (x=-66.0, y=-31.0, width=587.0, height=369.0)>, slices=[], artboards=[] )>' >, <Page: '<Page ( id="7BEAECDA-21FF-4245-9758-D94A3FDAA9A8", name="A third one", bounds=<Bounds (x=-99.0, y=-269.0, width=572.0, height=312.0)>, slices=[], artboards=[] )>' >]
####艺术板
要获得一个简单的列表,请使用sketch.artboards
>>> pyglass.sketch.artboards('/Users/Vayu/Development/src/pyglass/tests/data/sketch/artboards.sketch') [<Artboard: '<Artboard ( id="38BADD7D-C452-4DFD-9054-7939A23902C1", name="Artboard 1", rect=<Rect (x=-101.0, y=-557.0, width=640.0, height=1136.0)>) >'>, <Artboard: '<Artboard ( id="BFFAD951-2678-4C55-85CB-0B2130BD0392", name="Artboard 2", rect=<Rect (x=639.0, y=-557.0, width=640.0, height=1136.0)>) >'> ]
要获得整个层次结构,请使用“sketch.list\u artboards”
>>> pyglass.sketch.list_artboards('/Users/Vayu/Development/src/pyglass/tests/data/sketch/artboards.sketch') [<Page: '<Page ( id="C10E136D-6E3D-40C9-AA6C-67C456893C6D", name="Something", bounds=<Bounds (x=-131.0, y=-587.0, width=1440.0, height=1196.0)>, slices=[], artboards=[ <Artboard: \'<Artboard ( id="38BADD7D-C452-4DFD-9054-7939A23902C1", name="Artboard 1", rect=<Rect (x=-101.0, y=-557.0, width=640.0, height=1136.0)> )>\'>, <Artboard: \'<Artboard ( id="BFFAD951-2678-4C55-85CB-0B2130BD0392", name="Artboard 2", rect=<Rect (x=639.0, y=-557.0, width=640.0, height=1136.0)> )>\'> ] )> '>]
##要求
- 系统要求
- Mac OS X 10.7+
- [xcode命令行工具](https://developer.apple.com/downloads)
- 外部依赖性
##安装
只需运行:
$ pip install pyglass
##测试
要运行测试套件,请执行:
python setup.py nosetests
- 许可证
麻省理工学院请参见许可证文件。
作者:Shravan Reddy。版权所有(c)Pixelapse。