当前位置: 首页>>代码示例>>Python>>正文


Python Utility.get_file_extension方法代码示例

本文整理汇总了Python中utility.Utility.get_file_extension方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.get_file_extension方法的具体用法?Python Utility.get_file_extension怎么用?Python Utility.get_file_extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utility.Utility的用法示例。


在下文中一共展示了Utility.get_file_extension方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import get_file_extension [as 别名]
    def load(self, file_name):

        try:
            zf = zipfile.ZipFile(file_name, 'r')
        except zipfile.BadZipfile as excp:
            raise InvalidTypeFileException(excp.message)
        except zipfile.LargeZipFile as excp:
            raise LoadComicsException(excp.message)
        except IOError as excp:
            raise LoadComicsException(excp.message)

        name_list = zf.namelist()
        name_list.sort()
        aux = 100.0 / len(name_list)
        page_number = 1
        self.data = []

        for idx, name in enumerate(name_list):

            if Utility.get_file_extension(name).lower() in self.extension:
                self.data.append(Page(zf.read(name), name, page_number))
                page_number += 1

            self.progress.emit(idx * aux)

        zf.close()

        if not self.data:
            raise NoDataFindException('No one file is loaded!')
开发者ID:gitter-badger,项目名称:pynocchio-comic-reader,代码行数:31,代码来源:compact_file_loader_zip.py

示例2: load

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import get_file_extension [as 别名]
    def load(self, file_name):

        try:
            tar = tarfile.open(file_name, 'r')
        except tarfile.CompressionError as excp:
            raise InvalidTypeFileException(excp.message)
        except IOError as excp:
            raise LoadComicsException(excp.message)

        name_list = tar.getnames()
        name_list.sort()
        aux = 100.0 / len(name_list)
        page_number = 1
        self.data = []

        for idx, name in enumerate(name_list):

            if Utility.get_file_extension(name).lower() in self.extension:
                try:
                    data = tar.extractfile(name).read()
                    self.data.append(Page(data, name, page_number))
                    page_number += 1
                except tarfile.ExtractError as err:
                    print '%20s  %s' % (name, err.message)
                except tarfile.ReadError as err:
                    print '%20s  %s' % (name, err.message)

            self.progress.emit(idx * aux)

        tar.close()

        if not self.data:
            raise NoDataFindException
开发者ID:gitter-badger,项目名称:pynocchio-comic-reader,代码行数:35,代码来源:compact_file_loader_tar.py

示例3: load

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import get_file_extension [as 别名]
    def load(self, filename, initial_page=0):

        image_extensions = ['.bmp', '.jpg', '.jpeg', '.gif', '.png', '.pbm',
                            '.pgm', '.ppm', '.tiff', '.xbm', '.xpm', '.webp']

        loader = LoaderFactory.create_loader(
            Utility.get_file_extension(filename), set(image_extensions))

        loader.progress.connect(self.load_progressbar_value)

        try:
            loader.load(filename)
        except NoDataFindException as excp:
            # Caso nao exista nenhuma imagem, carregamos a imagem indicando
            # erro
            from page import Page
            print excp.message
            q_file = QtCore.QFile(":/icons/notCover.png")
            q_file.open(QtCore.QIODevice.ReadOnly)
            loader.data.append(Page(q_file.readAll(), 'exit_red_1.png', 0))

        self.comic = Comic(Utility.get_base_name(filename),
                           Utility.get_dir_name(filename), initial_page)

        self.comic.pages = loader.data
        self.current_directory = Utility.get_dir_name(filename)
        self.path_file_filter.parse(filename)
开发者ID:gitter-badger,项目名称:pynocchio-comic-reader,代码行数:29,代码来源:main_window_model.py

示例4: load

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import get_file_extension [as 别名]
    def load(self, file_name):
        try:
            rar = rarfile.RarFile(file_name, 'r')
        except rarfile.RarOpenError as exception:
            raise InvalidTypeFileException(exception.message)
        except IOError as exception:
            raise LoadComicsException(exception.strerror)

        name_list = rar.namelist()
        name_list.sort()
        aux = 100.0 / len(name_list)
        page_number = 1
        self.data = []

        for idx, name in enumerate(name_list):

            if Utility.get_file_extension(name).lower() in self.extension:
                self.data.append(Page(rar.read(name), name, page_number))
                page_number += 1

            self.progress.emit(idx * aux)

        rar.close()

        if not self.data:
            raise NoDataFindException
开发者ID:mwergles,项目名称:pynocchio,代码行数:28,代码来源:compact_file_loader_rar.py


注:本文中的utility.Utility.get_file_extension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。