本文整理匯總了Python中biplist.readPlist方法的典型用法代碼示例。如果您正苦於以下問題:Python biplist.readPlist方法的具體用法?Python biplist.readPlist怎麽用?Python biplist.readPlist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類biplist
的用法示例。
在下文中一共展示了biplist.readPlist方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: icon_from_app
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def icon_from_app(app_path):
plist_path = os.path.join(app_path, 'Contents', 'Info.plist')
plist = biplist.readPlist(plist_path)
icon_name = plist['CFBundleIconFile']
icon_root,icon_ext = os.path.splitext(icon_name)
if not icon_ext:
icon_ext = '.icns'
icon_name = icon_root + icon_ext
return os.path.join(app_path, 'Contents', 'Resources', icon_name)
# .. Basics ....................................................................
# Uncomment to override the output filename
# filename = 'test.dmg'
# Uncomment to override the output volume name
# volume_name = 'Test'
# Volume format (see hdiutil create -help)
示例2: _parse_plist
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def _parse_plist(self):
try:
if self.plist_temp_file == None:
self._get_plist_temp_file()
if self.plist_temp_file == '':
self.plist_info_list = {}
return False
self.plist_info_list = readPlist(self.plist_temp_file)
os.remove(self.plist_temp_file)
return self.plist_info_list
except Exception, e:
print "Not a plist:", e
self.plist_info_list = {}
return False
示例3: getRootElementNames
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def getRootElementNames(f):
''' The top element is usually called "root", but sometimes it is not!
Hence we retrieve the correct name here. In some plists, there is
more than one top element, this function will retrieve them all.
'''
roots = []
try:
plist = biplist.readPlist(f)
top_element = plist.get('$top', None)
if top_element:
roots = [ x for x in top_element.keys() ]
else:
print('$top element not found! Not an NSKeyedArchive?')
except Exception as ex:
print('Had an exception (error) trying to read plist using biplist')
traceback.print_exc()
return roots
示例4: GetTopLevel
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def GetTopLevel(self, file_object):
"""Returns the deserialized content of a plist as a dictionary object.
Args:
file_object (dfvfs.FileIO): a file-like object to parse.
Returns:
dict[str, object]: contents of the plist.
Raises:
UnableToParseFile: when the file cannot be parsed.
"""
try:
top_level_object = biplist.readPlist(file_object)
except (biplist.InvalidPlistException,
biplist.NotBinaryPlistException) as exception:
raise errors.UnableToParseFile(
'Unable to parse plist with error: {0!s}'.format(exception))
return top_level_object
示例5: Read
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def Read(self, file_object):
"""Reads a plist from a file-like object.
Args:
file_object (dfvfs.FileIO): a file-like object containing plist data.
Raises:
IOError: if the plist file-like object cannot be read.
OSError: if the plist file-like object cannot be read.
"""
try:
self.root_key = biplist.readPlist(file_object)
except (
biplist.NotBinaryPlistException,
biplist.InvalidPlistException) as exception:
raise IOError(exception)
示例6: restore
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def restore(self, options = {"RestoreSystemFiles": True,
"RestoreShouldReboot": True,
"RestorePreserveCameraRoll": True,
"RemoveItemsNotRestored": False,
"RestoreDontCopyBackup": True,
"RestorePreserveSettings": True},
password=None):
self.logger.info("Starting restoration...")
m = os.path.join(self.backupPath,self.udid,"Manifest.plist")
try:
manifest = readPlist(m)
except IOError:
self.logger.error("not a valid backup folder")
return -1
if manifest.get("IsEncrypted"):
print("Backup is encrypted, enter password : ")
if password:
self.password = password
else:
self.password = raw_input()
options["Password"] = self.password
self.mobilebackup2_send_request("Restore", self.udid, self.udid, options)
self.work_loop()
示例7: _GetSystemInfo
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def _GetSystemInfo(self):
''' Gets system version information'''
try:
log.debug("Trying to get system version from /System/Library/CoreServices/SystemVersion.plist")
f = self.Open('/System/Library/CoreServices/SystemVersion.plist')
if f != None:
try:
plist = biplist.readPlist(f)
self.os_version = plist.get('ProductVersion', '')
self.os_build = plist.get('ProductBuildVersion', '')
self.os_friendly_name = plist.get('ProductName', '')
log.info ('iOS version detected is: {} ({}) Build={}'.format(self.os_friendly_name, self.os_version, self.os_build))
f.close()
return True
except (biplist.InvalidPlistException, biplist.NotBinaryPlistException) as ex:
log.error ("Could not get ProductVersion from plist. Is it a valid xml plist? Error=" + str(ex))
f.close()
else:
log.error("Could not open plist to get system version info!")
except:
log.exception("Unknown error from _GetSystemInfo()")
return False
示例8: getRootElementNames
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def getRootElementNames(f):
''' The top element is usually called "root", but sometimes it is not!
Hence we retrieve the correct name here. In some plists, there is
more than one top element, this function will retrieve them all.
'''
roots = []
try:
plist = biplist.readPlist(f)
top_element = plist.get('$top', None)
if top_element:
roots = [ x for x in top_element.keys() ]
else:
print('$top element not found! Not an NSKeyedArchive?')
except biplist.InvalidPlistException:
print('Had an exception (error) trying to read plist using biplist')
traceback.print_exc()
return roots
示例9: icon_from_app
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def icon_from_app(app_path):
plist_path = os.path.join(app_path, 'Contents', 'Info.plist')
plist = biplist.readPlist(plist_path)
icon_name = plist['CFBundleIconFile']
icon_root,icon_ext = os.path.splitext(icon_name)
if not icon_ext:
icon_ext = '.icns'
icon_name = icon_root + icon_ext
return os.path.join(app_path, 'Contents', 'Resources', icon_name)
# .. Basics ....................................................................
# Uncomment to override the output filename
# filename = 'test.dmg'
# Uncomment to override the output volume name
# volume_name = 'Test'
# Volume format (see hdiutil create -help)
示例10: icon_from_app
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def icon_from_app(app_path):
plist_path = os.path.join(app_path, "Contents", "Info.plist")
plist = biplist.readPlist(plist_path)
icon_name = plist["CFBundleIconFile"]
icon_root, icon_ext = os.path.splitext(icon_name)
if not icon_ext:
icon_ext = ".icns"
icon_name = icon_root + icon_ext
return os.path.join(app_path, "Contents", "Resources", icon_name)
# .. Basics ...................................................................
# Uncomment to override the output filename
# filename = 'mu-editor.dmg'
# Uncomment to override the output volume name
# volume_name = 'Mu Editor'
# Volume format (see hdiutil create -help)
示例11: main
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def main(plist):
print("[+] Opening {} file".format(plist))
try:
plist_data = biplist.readPlist(plist)
except (biplist.InvalidPlistException,
biplist.NotBinaryPlistException) as e:
print("[-] Invalid PLIST file - unable to be opened by biplist")
sys.exit(2)
print("[+] Printing Info.plist Device "
"and User Information to Console\n")
for k in plist_data:
if k != 'Applications' and k != 'iTunes Files':
print("{:<25s} - {}".format(k, plist_data[k]))
示例12: _read_and_unlock_keybag
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def _read_and_unlock_keybag(self):
if self._unlocked:
return self._unlocked
# Open the Manifest.plist file to access the Keybag:
with open(self._manifest_plist_path, 'rb') as infile:
self._manifest_plist = biplist.readPlist(infile)
self._keybag = google_iphone_dataprotection.Keybag(self._manifest_plist['BackupKeyBag'])
# Attempt to unlock the Keybag:
self._unlocked = self._keybag.unlockWithPassphrase(self._passphrase)
if not self._unlocked:
raise ValueError("Failed to decrypt keys: incorrect passphrase?")
# No need to keep the passphrase any more:
self._passphrase = None
return True
示例13: handler_bplist
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def handler_bplist(filename, filepath, info, out=None, settings=None ):
if out != None:
out.put("\t[PLIST] Extractiong: " + filepath)
else:
print "\t[PLIST] Extractiong: " + filepath
try:
plist = biplist.readPlist(filepath)
content = biplist.writePlistToString(plist,False)
fobj = ExtractStore.ApplicationFile(filename,ExtractStore.TYPE_XML)
fobj.add_content(content)
return fobj
except:
return handle_data(filename,filepath,info,out)
示例14: plist
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def plist(local_file):
"""
Reads and returns a plist file in dict form
:param str local_file: the plist list file to read
:return: a dict with the plist content
"""
import biplist
return biplist.readPlist(local_file)
示例15: run
# 需要導入模塊: import biplist [as 別名]
# 或者: from biplist import readPlist [as 別名]
def run(self):
try:
d = biplist.readPlist('/Library/Preferences/com.apple.alf.plist')
enabled = (d['globalstate'] >= 1)
except:
return (False, "failed to read firewall config plist")
return (enabled, "{}".format("enabled" if enabled else "disabled"))