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


Python OleFileIO.listdir方法代碼示例

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


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

示例1: MicImageFile

# 需要導入模塊: import OleFileIO [as 別名]
# 或者: from OleFileIO import listdir [as 別名]
class MicImageFile(TiffImagePlugin.TiffImageFile):

    format = "MIC"
    format_description = "Microsoft Image Composer"

    def _open(self):

        # read the OLE directory and see if this is a likely
        # to be a Microsoft Image Composer file

        try:
            self.ole = OleFileIO(self.fp)
        except IOError:
            raise SyntaxError, "not an MIC file; invalid OLE file"

        # find ACI subfiles with Image members (maybe not the
        # best way to identify MIC files, but what the... ;-)

        self.images = []
        for file in self.ole.listdir():
            if file[1:] and file[0][-4:] == ".ACI" and file[1] == "Image":
                self.images.append(file)

        # if we didn't find any images, this is probably not
        # an MIC file.
        if not self.images:
            raise SyntaxError, "not an MIC file; no image entries"

        self.__fp = self.fp
        self.frame = 0

        if len(self.images) > 1:
            self.category = Image.CONTAINER

        self.seek(0)

    def seek(self, frame):

        try:
            filename = self.images[frame]
        except IndexError:
            raise EOFError, "no such frame"

        self.fp = self.ole.openstream(filename)

        TiffImagePlugin.TiffImageFile._open(self)

        self.frame = frame

    def tell(self):

        return self.frame
開發者ID:py-web,項目名稱:ibrouteur,代碼行數:54,代碼來源:MicImagePlugin.py


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