纯python plist操纵器
gplist的Python项目详细描述
plist公司
简介
在信息列表是一个类似清单的文件,用于存储应用程序的属性。它的文件格式可以是xml或二进制。这个库是一个纯python实现,用于操作plist文件和解析mobileprovision文件。在
使用
PlistInfo
是一个类似于有序dict的类,因此可以将其视为有序dict
当分析二进制数据或文件时,PlistInfo
将自动检测格式并获得正确的结果。在
MobileProvision
也是一个有序的类dict,它的数据基本上来自xml plist。在
二进制格式
importjsonimportosfromgplist.plistimportPlistInfo# raw binarywithopen("FooApp.app/Info.plist","rb")asfd:p=PlistInfo(fd.read())print(json.dumps(p,indent=2))# from raw filep=PlistInfo.from_file("FooApp.app/Info.plist")# from app or ipap=PlistInfo.from_app("FooApp.app")p=PlistInfo.from_app("FooApp.ipa")foo_file="foo.plist"p.to_binary_file(foo_file)assertos.path.isfile(foo_file)buf=p.to_binary()assertisinstance(buf,bytes)
XML格式
^{pr2}$属性操作
fromgplist.plistimportPlistInfop=PlistInfo.from_app("FooApp.ipa")p.add_property({"a":1},"foo")assertp["foo"]=={"a":1}p.add_property("b","foo","b")assertp["foo"]["b"]=="b"p.update_property("c","foo","b")assertp["foo"]["b"]=="c"p.remove_property("foo","a")assertp["foo"]=={"b":"c"}
移动设备
fromgplist.mobileprovisionimportMobileProvisionm=MobileProvision.from_file(provision_file)print(m.is_expired())print(m["Name"])print(m.has_udid("00008030-001A2DA6********")forcertinm.certs:print(cert.sha1)print(cert.is_expired())print(cert.serial)print(cert.common_name)print(cert.organization_unit_name)print(cert.organization_name)print(cert.country_name)
命令行工具
python -m gplist Info.plist
python -m gplist embedded.mobileprovision
python -m gplist --cert embedded.mobileprovision
python -m gplist --has-udid "00008030-001A2DA6********" embedded.mobileprovision
- 项目
标签: