in tools/plisttool/plisttool.py [0:0]
def validate_plist(self, plist):
if self.options.get('version_keys_required'):
for k in ('CFBundleVersion', 'CFBundleShortVersionString'):
# This also errors if they are there but the empty string or zero.
if not plist.get(k, None):
raise PlistToolError(MISSING_VERSION_KEY_MSG % (self.target, k))
# If the version keys are set, they must be valid (even if they were
# not required).
for k, validator in (
('CFBundleVersion', IsValidVersionString),
('CFBundleShortVersionString', IsValidShortVersionString)):
v = plist.get(k)
if v and not validator(v):
raise PlistToolError(INVALID_VERSION_KEY_VALUE_MSG % (
self.target, k, v))
child_plists = self.options.get('child_plists')
child_plist_required_values = self.options.get(
'child_plist_required_values')
if child_plists:
self._validate_children(
plist, child_plists, child_plist_required_values, self.target)
pkginfo_file = self.options.get('pkginfo')
if pkginfo_file:
if isinstance(pkginfo_file, str):
with open(pkginfo_file, 'wb') as p:
self._write_pkginfo(p, plist)
else:
self._write_pkginfo(pkginfo_file, plist)