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 details)

Uploaded Source

File details

Details for the file gplist-0.0.15.tar.gz.

File metadata

  • Download URL: gplist-0.0.15.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/58.0.4 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.12

File hashes

Hashes for gplist-0.0.15.tar.gz
Algorithm Hash digest
SHA256 d33b6fb2d3cfb573b061c84b20c7f1969d84c16e15c8174b7a7d8d6525f9d344
MD5 1e41be0a1c1f39a2d39e69b8d639bf79
BLAKE2b-256 2f1a2cd4cb857b9a9595a8ba2edd378908b874d553ffc2ad8455dc309f6ffff4

See more details on using hashes here.

Supported by

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