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


Python QFileInfo.canonicalPath方法代码示例

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


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

示例1: __insertFlashCookie

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import canonicalPath [as 别名]
 def __insertFlashCookie(self, path):
     """
     Private method to insert a Flash cookie into the cache.
     
     @param path Flash cookies path
     @type str
     """
     solFile = QFile(path)
     if not solFile.open(QFile.ReadOnly):
         return
     
     dataStr = ""
     data = bytes(solFile.readAll())
     if data:
         try:
             reader = FlashCookieReader()
             reader.setBytes(data)
             reader.parse()
             dataStr = reader.toString()
         except FlashCookieReaderError as err:
             dataStr = err.msg
     
     solFileInfo = QFileInfo(solFile)
     
     cookie = FlashCookie()
     cookie.contents = dataStr
     cookie.name = solFileInfo.fileName()
     cookie.path = solFileInfo.canonicalPath()
     cookie.size = int(solFile.size())
     cookie.lastModified = solFileInfo.lastModified()
     cookie.origin = self.__extractOriginFrom(path)
     
     self.__flashCookies.append(cookie)
开发者ID:testmana2,项目名称:test,代码行数:35,代码来源:FlashCookieManager.py

示例2: FileBasedTextStream

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import canonicalPath [as 别名]
class FileBasedTextStream(QTextStream):
    def __init__(self, qfile):
        super().__init__(qfile)
        self.saved_file = qfile
        self.qfi = None # may never need this
    def rewind(self):
        self.flush()
        self.seek(0)
    def writeLine(self, str):
        self << str
        self << '\n'
    def open_mode(self):
        return self.saved_file.openMode()
    def fullpath(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.canonicalFilePath()
    def folderpath(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.canonicalPath()
    def filename(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.fileName()
    def basename(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.completeBaseName()
    def suffix(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.suffix()
开发者ID:B-Rich,项目名称:PPQT2,代码行数:35,代码来源:utilities.py

示例3: FileBasedTextStream

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import canonicalPath [as 别名]
class FileBasedTextStream(QTextStream):
    def __init__(self, qfile):
        super().__init__(qfile)
        self.saved_file = qfile
        self.qfi = None # may never need this
    def rewind(self):
        self.flush()
        self.seek(0)
    def writeLine(self, str):
        self << str
        self << '\n'
    def open_mode(self):
        return self.saved_file.openMode()
    def fullpath(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.canonicalFilePath()
    def folderpath(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.canonicalPath()
    def filename(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.fileName()
    def basename(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.completeBaseName()
    def suffix(self):
        if self.qfi is None:
            self.qfi = QFileInfo(self.saved_file)
        return self.qfi.suffix()
    def flush(self):
        super().flush() # make sure text buffer goes to device
        return self.device().flush() # do a real flush
    def show_error( self, action, parent ):
        error_number = self.device().error()
        if error_number : # is not 0, no error
            error_string = self.device().errorString()
            msg_string = 'Error {} ({}) on {}'.format(
                error_number, error_string, action )
            warning_msg( msg_string, self.fullpath(), parent )
开发者ID:tallforasmurf,项目名称:PPQT2,代码行数:45,代码来源:utilities.py

示例4: Project

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import canonicalPath [as 别名]

#.........这里部分代码省略.........
            if name == '':
                return ''

        return self._fileinfo_from_user(name).completeBaseName()

    def expandvars(self, path):
        """ Call os.path.expandvars() after expanding some internal values. """

        major, minor, micro = self.python_target_version
        major = str(major)
        minor = str(minor)
        micro = str(micro)

        path = path.replace('$PDY_PY_MAJOR', major)
        path = path.replace('${PDY_PY_MAJOR}', major)

        path = path.replace('$PDY_PY_MINOR', minor)
        path = path.replace('${PDY_PY_MINOR}', minor)

        path = path.replace('$PDY_PY_MICRO', micro)
        path = path.replace('${PDY_PY_MICRO}', micro)

        return os.path.expandvars(path)

    def _fileinfo_from_user(self, user_path):
        """ Convert the name of a file or directory specified by the user to a
        QFileInfo instance.  A user path may be relative to the name of the
        project and may contain environment variables.
        """

        fi = QFileInfo(self.expandvars(user_path.strip()))

        if fi.isRelative() and self._name is not None:
            fi = QFileInfo(self._name.canonicalPath() + '/' + fi.filePath())

        return fi

    def get_stdlib_requirements(self, include_hidden=False):
        """ Return a 2-tuple of the required Python standard library modules
        and the required external libraries.  The modules are a dict with the
        module name as the key and a bool as the value.  The bool is True if
        the module is explicitly required and False if it is implicitly
        required.  The libraries are a set of well known library names.
        """

        # Work out the dependencies.
        metadata = get_python_metadata(self.python_target_version)
        all_modules = {name: _DepState(module)
                for name, module in metadata.items()}

        visit = 0
        for name in all_modules.keys():
            self._set_dependency_state(all_modules, name, visit)
            visit += 1

        # Extract the required modules and libraries.
        required_modules = {}
        required_libraries = set()

        for name, dep_state in all_modules.items():
            if dep_state.explicit:
                explicit = True
            elif dep_state.implicit:
                explicit = False
            else:
                continue
开发者ID:GreatFruitOmsk,项目名称:pyqtdeploy,代码行数:70,代码来源:project.py


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