當前位置: 首頁>>代碼示例>>Python>>正文


Python CoreFoundation.CFDataCreate方法代碼示例

本文整理匯總了Python中CoreFoundation.CFDataCreate方法的典型用法代碼示例。如果您正苦於以下問題:Python CoreFoundation.CFDataCreate方法的具體用法?Python CoreFoundation.CFDataCreate怎麽用?Python CoreFoundation.CFDataCreate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CoreFoundation的用法示例。


在下文中一共展示了CoreFoundation.CFDataCreate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _CopyStringsFile

# 需要導入模塊: import CoreFoundation [as 別名]
# 或者: from CoreFoundation import CFDataCreate [as 別名]
def _CopyStringsFile(self, source, dest):
    """Copies a .strings file using iconv to reconvert the input into UTF-16."""
    input_code = self._DetectInputEncoding(source) or "UTF-8"

    # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call
    # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints
    #     CFPropertyListCreateFromXMLData(): Old-style plist parser: missing
    #     semicolon in dictionary.
    # on invalid files. Do the same kind of validation.
    import CoreFoundation
    s = open(source, 'rb').read()
    d = CoreFoundation.CFDataCreate(None, s, len(s))
    _, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None)
    if error:
      return

    fp = open(dest, 'wb')
    fp.write(s.decode(input_code).encode('UTF-16'))
    fp.close() 
開發者ID:refack,項目名稱:GYP3,代碼行數:21,代碼來源:mac_tool.py

示例2: _CopyStringsFile

# 需要導入模塊: import CoreFoundation [as 別名]
# 或者: from CoreFoundation import CFDataCreate [as 別名]
def _CopyStringsFile(self, source, dest, convert_to_binary):
    """Copies a .strings file using iconv to reconvert the input into UTF-16."""
    input_code = self._DetectInputEncoding(source) or "UTF-8"

    # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call
    # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints
    #     CFPropertyListCreateFromXMLData(): Old-style plist parser: missing
    #     semicolon in dictionary.
    # on invalid files. Do the same kind of validation.
    import CoreFoundation
    s = open(source, 'rb').read()
    d = CoreFoundation.CFDataCreate(None, s, len(s))
    _, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None)
    if error:
      return

    fp = open(dest, 'wb')
    fp.write(s.decode(input_code).encode('UTF-16'))
    fp.close()

    if convert_to_binary == 'True':
      self._ConvertToBinary(dest) 
開發者ID:zhaoolee,項目名稱:StarsAndClown,代碼行數:24,代碼來源:mac_tool.py


注:本文中的CoreFoundation.CFDataCreate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。