Skip to main content

A python plist xml validator

Project description

validate_plist_xml

This python module will validate Apple XML Plist files.

This is pure python and runs on any operating system, tested on Windows, Mac, and Linux. Currently targets Python 3 only but would like to add Python 2 support.

By default configured to check files with the following extensions: ('.recipe', '.plist', '.profile')

By default, runs in the current working directory against all files in that directory and all subdirectories.

This module depends upon the lxml module. (which is handled by pip automatically)

The code is found within src/validate_plist_xml/validate_plist_xml.py within the git repo.

This module checks that the plist is valid XML and meets the Apple Plist DTD here: https://www.apple.com/DTDs/PropertyList-1.0.dtd

Install with pip:

pip install validate-plist-xml

This will install lxml if not already installed.

Usage Examples:

Run as Python Script:

The python script can be called directly:

$ python3 src/validate_plist_xml/validate_plist_xml.py 
XML Syntax Error in: ./tests/bad/example-bad-xml-tags.recipe
Opening and ending tag mismatch: BAD_TAG line 4 and dict, line 15, column 8 (example-bad-xml-tags.recipe, line 15)
Failed DTD Validation: ./tests/bad/example-bad-dtd.recipe
Element dict content does not follow the DTD, expecting (key , (array | data | date | dict | real | integer | string | true | false))*, got (key astring key string key dict key string key array ), line 4
2 errors found in 3 plist xml files

Run as module:

If installed through pip as a module, then it can be run like this:

$ python3 -m validate_plist_xml
XML Syntax Error in: ./tests/bad/example-bad-xml-tags.recipe
Opening and ending tag mismatch: BAD_TAG line 4 and dict, line 15, column 8 (example-bad-xml-tags.recipe, line 15)
Failed DTD Validation: ./tests/bad/example-bad-dtd.recipe
Element dict content does not follow the DTD, expecting (key , (array | data | date | dict | real | integer | string | true | false))*, got (key astring key string key dict key string key array ), line 4
2 errors found in 3 plist xml files

Use as GitHub Action:

---
name: plistlint

on:
  push:
    paths:
      - "**.plist"
      - "**.recipe"
      - ".github/workflows/plistlint.yaml"
  pull_request:
    paths:
      - "**.plist"
      - "**.recipe"
      - ".github/workflows/plistlint.yaml"

jobs:
  plistlint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.8

      - name: Install validate-plist-xml
        run: pip install validate-plist-xml

      - name: Lint Plist files
        run: python3 -m validate_plist_xml

Use in another Python script:

import validate_plist_xml

# The default folder is `.` but could be any folder
validate_plist_xml.validate_plist_xml.main('.')

or as a one liner:

python3 -c "import validate_plist_xml; validate_plist_xml.validate_plist_xml.main('.')"

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

validate-plist-xml-1.0.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

validate_plist_xml-1.0.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file validate-plist-xml-1.0.2.tar.gz.

File metadata

  • Download URL: validate-plist-xml-1.0.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.6

File hashes

Hashes for validate-plist-xml-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ccf63b3366c4c9881164e03e37054497cca0d1c953a3b7ad1260ba6cc20b1596
MD5 75efc4fd88735776cb7eb8e03b8e278f
BLAKE2b-256 a9a9c53dada985d5dfc1911fdc92a0a8b437060a22fa1069590699f035a78e2b

See more details on using hashes here.

File details

Details for the file validate_plist_xml-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: validate_plist_xml-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.6

File hashes

Hashes for validate_plist_xml-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6f56161a31bb2a79b39b2d798f0aa6f315d9adde55b339c3e5a3c57263633fd2
MD5 ebe98649fdb7ae5e23a9ac15a1f38ea3
BLAKE2b-256 7b1967e75c11962fd3e5377ae6f0ed0583a4ce339e408b471c9f7a19872f5cc4

See more details on using hashes here.

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