Skip to main content

pure python plist manipulator

Project description

plist

Build Status PyPI version

Introduction

Info.plist is a manifest-liked file to store properties of an application. It's file format can be xml or binary. This library is a pure python implementation to manipulate plist file and parse mobileprovision file.

Usage

The PlistInfo is an ordered dict-liked class, so you can treat it as an ordered dict.

When parsing from binary data or file, PlistInfo will automatically detect the format and get the correct result.

MobileProvision is an ordered dict-liked class too, and basically its data comes from xml plist.

Binary Format

import json
import os
from gplist.plist import PlistInfo

# raw binary
with open("FooApp.app/Info.plist", "rb") as fd:
    p = PlistInfo(fd.read())
    print(json.dumps(p, indent=2))

# from raw file
p = PlistInfo.from_file("FooApp.app/Info.plist")

# from app or ipa
p = PlistInfo.from_app("FooApp.app")
p = PlistInfo.from_app("FooApp.ipa")

foo_file = "foo.plist"
p.to_binary_file(foo_file)
assert os.path.isfile(foo_file)

buf = p.to_binary()
assert isinstance(buf, bytes)

XML Format

import os
from gplist.plist import PlistInfo

p = PlistInfo.from_app("FooApp.ipa")

foo_file = "foo_xml.plist"
p.to_xml_file(foo_file)
assert os.path.isfile(foo_file)

p.to_xml_file(foo_file, encoding="UTF-8", pretty=False)
assert os.path.isfile(foo_file)

buf = p.to_xml(encoding="UTF-8", pretty=True)
assert isinstance(buf, bytes)

Property Manipulation

from gplist.plist import PlistInfo

p = PlistInfo.from_app("FooApp.ipa")

p.add_property({"a": 1}, "foo")
assert p["foo"] == {"a": 1}

p.add_property("b", "foo", "b")
assert p["foo"]["b"] == "b"

p.update_property("c", "foo", "b")
assert p["foo"]["b"] == "c"

p.remove_property("foo", "a")
assert p["foo"] == {"b": "c"}

Mobile Provision

from gplist.mobileprovision import MobileProvision

m = MobileProvision.from_file(provision_file)
print(m.is_expired())
print(m["Name"])
print(m.has_udid("00008030-001A2DA6********")
for cert in m.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)

Command Line Tools

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gplist-0.0.15.tar.gz (10.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page