This utility is designed to convert Apple plist files to yaml, or yaml files to plist. I/O is from regular files.
The python yaml module is required, which is not installed by default on Macs. You can install it with pip, which you may also need to install first.
sudo python -m ensurepip
pip install pyyamlIf all three files are in the same folder, a single command can be used to convert in either direction:
./plistyamlplist.py -h
Usage: ./plistyamlplist.py <input-file> [<output-file>]Otherwise, each file can be used individually:
./plist_yaml.py -h
Usage: plist-yaml.py <input-file> [<output-file>]
./yaml_plist.py -h
Usage: yaml-plist.py <input-file> [<output-file>]Notes:
- With
plistyamlplist.py, if you do not specify anoutput-filevalue, the script determines if theinput-fileis a plist or yaml file. If a plist file, theinput-filename will be appended with.yamlfor the output file. If a yaml file, the output file name will be theinput-filename with.yamlremoved. - With
plist_yaml.py, if you do not specify anoutput-filevalue, theinput-filename will be appended with.yamlfor the output file. - With
yaml_plist.py, if you do not specify anoutput-filevalue, and theinput-filename ends with.yaml, the output file name will be theinput-filename with.yamlremoved. - With
plist_yaml.py, you may have to first convert a binary plist to text format usingplutil.
To convert a plist file to yaml:
$ plutil -convert xml1 ~/Library/Preferences/com.something.plist
$ ./plistyamlplist.py ~/Library/Preferences/com.something.plist ~/Downloads/com.something.yaml
$ ./plistyamlplist.py ~/Library/Preferences/com.something.plist
# this will output to `~/Library/Preferences/com.something.plist.yaml'
To convert a yaml file to a plist file:
$ ./plistyamlplist.py ~/Downloads/com.something.yaml ~/Downloads/com.something.plist
$ ./plistyamlplist.py ~/Downloads/com.something.plist.yaml
# this will output to `~/Downloads/com.something.plist'
Elements of these scripts come from chaimleib/ppl and asciidoctor/sublimetext-asciidoc