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


Python QFileInfo.completeBaseName方法代码示例

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


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

示例1: __saveFileName

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
 def __saveFileName(self, directory):
     """
     Private method to calculate a name for the file to download.
     
     @param directory name of the directory to store the file into (string)
     @return proposed filename and original filename (string, string)
     """
     path = parseContentDisposition(self.__reply)
     info = QFileInfo(path)
     baseName = info.completeBaseName()
     endName = info.suffix()
     
     origName = baseName
     if endName:
         origName += '.' + endName
     
     name = directory + baseName
     if endName:
         name += '.' + endName
         if not self.__requestFilename:
             # do not overwrite, if the user is not being asked
             i = 1
             while QFile.exists(name):
                 # file exists already, don't overwrite
                 name = directory + baseName + ('-{0:d}'.format(i))
                 if endName:
                     name += '.' + endName
                 i += 1
     return name, origName
开发者ID:pycom,项目名称:EricShort,代码行数:31,代码来源:DownloadItem.py

示例2: FileBasedTextStream

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [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: outputFiles

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
    def outputFiles(self, map, fileName):
        result = []

        # Extract file name without extension and path
        fileInfo = QFileInfo(fileName)
        base = fileInfo.completeBaseName() + "_"
        path = fileInfo.path()

        # Loop layers to calculate the path for the exported file
        for layer in map.layers():
            if layer.layerType() != Layer.TileLayerType:
                continue

            # Get the output file name for this layer
            layerName = layer.name()
            layerFileName = base + layerName + ".csv"
            layerFilePath = QDir(path).filePath(layerFileName)

            result.append(layerFilePath)

        # If there was only one tile layer, there's no need to change the name
        # (also keeps behavior backwards compatible)
        if len(result) == 1:
            result[0] = fileName

        return result
开发者ID:theall,项目名称:Python-Tiled,代码行数:28,代码来源:csvplugin.py

示例4: getDocumentTitle

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
	def getDocumentTitle(self, baseName=False):
		if self.markup and not baseName:
			text = self.editBox.toPlainText()
			try:
				return self.markup.get_document_title(text)
			except Exception:
				self.p.printError()
		if self.fileName:
			fileinfo = QFileInfo(self.fileName)
			basename = fileinfo.completeBaseName()
			return (basename if basename else fileinfo.fileName())
		return self.tr("New document")
开发者ID:modulexcite,项目名称:retext,代码行数:14,代码来源:tab.py

示例5: addShapeToCanvas

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
def addShapeToCanvas( shapefile_path ):
    file_info = QFileInfo( shapefile_path )
    if file_info.exists():
        layer_name = file_info.completeBaseName()
    else:
        return False
    vlayer_new = QgsVectorLayer( shapefile_path, layer_name, "ogr" )
    if vlayer_new.isValid():
        QgsProject.instance().addMapLayers( [vlayer_new] )
        return True
    else:
        return False
开发者ID:rozos,项目名称:Hydrogeios-Qgis,代码行数:14,代码来源:h_utils.py

示例6: getDocumentTitle

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
	def getDocumentTitle(self, baseName=False):
		markup = self.markups[self.ind]
		realTitle = ''
		if markup and not baseName:
			text = self.editBoxes[self.ind].toPlainText()
			try:
				realTitle = markup.get_document_title(text)
			except Exception:
				self.printError()
		if realTitle:
			return realTitle
		elif self.fileNames[self.ind]:
			fileinfo = QFileInfo(self.fileNames[self.ind])
			basename = fileinfo.completeBaseName()
			return (basename if basename else fileinfo.fileName())
		return self.tr("New document")
开发者ID:zisecheng,项目名称:retext,代码行数:18,代码来源:window.py

示例7: __saveFileName

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
 def __saveFileName(self, directory):
     """
     Private method to calculate a name for the file to download.
     
     @param directory name of the directory to store the file into (string)
     @return proposed filename and original filename (string, string)
     """
     path = ""
     if self.__reply.hasRawHeader("Content-Disposition"):
         header = bytes(self.__reply.rawHeader("Content-Disposition"))\
             .decode()
         if header:
             pos = header.find("filename=")
             if pos != -1:
                 path = header[pos + 9:]
                 if path.startswith('"') and path.endswith('"'):
                     path = path[1:-1]
     if not path:
         path = self.__url.path()
     
     info = QFileInfo(path)
     baseName = info.completeBaseName()
     endName = info.suffix()
     
     if not baseName:
         baseName = "unnamed_download"
     
     origName = baseName
     if endName:
         origName += '.' + endName
     
     name = directory + baseName
     if endName:
         name += '.' + endName
         if not self.__requestFilename:
             # do not overwrite, if the user is not being asked
             i = 1
             while QFile.exists(name):
                 # file exists already, don't overwrite
                 name = directory + baseName + ('-{0:d}'.format(i))
                 if endName:
                     name += '.' + endName
                 i += 1
     return name, origName
开发者ID:Darriall,项目名称:eric,代码行数:46,代码来源:DownloadItem.py

示例8: FileBasedTextStream

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [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

示例9: loadRasterfileToCanvas

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
def loadRasterfileToCanvas(prjpath, layerName):
    """Loads a raste to canvas."""
    if isLayerLoaded(layerName):
        return True
    pathFilename=os.path.join(prjpath, layerName+".tif")
    file_info = QFileInfo(pathFilename)
    if file_info.exists():
        layer_name = file_info.completeBaseName()
    else:
        message="Error loading raster"+pathFilename
        QMessageBox.critical(None, 'Error', message, QMessageBox.Ok)
        return False
    layeropts=QgsRasterLayer.LayerOptions(True)    
    rlayer_new = QgsRasterLayer( pathFilename, layer_name, 'gdal', layeropts )
    if rlayer_new.isValid():
        QgsProject.instance().addMapLayer(rlayer_new)
        return True
    else:
        return False
开发者ID:rozos,项目名称:Hydrogeios-Qgis,代码行数:21,代码来源:h_utils.py

示例10: __init__

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
    def __init__(self, path, parent = None):
        super().__init__(parent)
        
        self.mPath = path
        self.mUi = Ui_NewTilesetDialog()
        self.mNameWasEdited = False

        self.mUi.setupUi(self)
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
        # Restore previously used settings
        s = preferences.Preferences.instance().settings()
        tilesetType = s.value(TYPE_KEY, 0)
        colorEnabled = bool(s.value(COLOR_ENABLED_KEY))
        colorName = s.value(COLOR_KEY, '')
        if colorName == '':
            color = Qt.magenta
        else:
            color = QColor(colorName)
        spacing = s.value(SPACING_KEY, 0)
        margin = s.value(MARGIN_KEY, 0)
        self.mUi.tilesetType.setCurrentIndex(tilesetType)
        self.mUi.useTransparentColor.setChecked(colorEnabled)
        self.mUi.colorButton.setColor(color)
        self.mUi.spacing.setValue(spacing)
        self.mUi.margin.setValue(margin)
        self.mUi.browseButton.clicked.connect(self.browse)
        self.mUi.name.textEdited.connect(self.nameEdited)
        self.mUi.name.textChanged.connect(self.updateOkButton)
        self.mUi.image.textChanged.connect(self.updateOkButton)
        self.mUi.tilesetType.currentIndexChanged.connect(self.tilesetTypeChanged)
        # Set the image and name fields if the given path is a file
        fileInfo = QFileInfo(path)
        if (fileInfo.isFile()):
            self.mUi.image.setText(path)
            self.mUi.name.setText(fileInfo.completeBaseName())

        self.mUi.imageGroupBox.setVisible(tilesetType == 0)
        self.updateOkButton()
开发者ID:theall,项目名称:Python-Tiled,代码行数:40,代码来源:newtilesetdialog.py

示例11: _write_qmake

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

#.........这里部分代码省略.........

                l_libs.append('-l' + lib_name)

            # Add the LIBS value for any PyQt modules to the global scope.
            if len(l_libs) > 0:
                self._add_value_for_scopes(used_libs,
                        '-L{0}/{1} {2}'.format(site_packages, pyqt_version,
                                ' '.join(l_libs)))

            # Add the sip module.
            self._add_value_for_scopes(used_inittab, 'sip')
            self._add_value_for_scopes(used_libs,
                    '-L{0} -lsip'.format(site_packages))

        # Handle any other extension modules.
        for other_em in project.other_extension_modules:
            scoped_values = self._parse_scoped_values(other_em.libs, False)

            for scope, values in scoped_values.items():
                self._add_value_for_scopes(used_inittab, other_em.name,
                        [scope])
                self._add_value_set_for_scope(used_libs, values, scope)

        # Configure the target Python interpreter.
        if project.python_target_include_dir != '':
            self._add_value_for_scopes(used_includepath,
                    project.path_from_user(project.python_target_include_dir))

        if project.python_target_library != '':
            fi = QFileInfo(project.path_from_user(
                    project.python_target_library))

            lib_dir = fi.absolutePath()
            lib = fi.completeBaseName()

            # This is smart enough to translate the Python library as a UNIX .a
            # file to what Windows needs.
            if lib.startswith('lib'):
                lib = lib[3:]

            if '.' in lib:
                self._add_value_for_scopes(used_libs,
                        '-L{0} -l{1}'.format(lib_dir, lib.replace('.', '')),
                        ['win32'])
                self._add_value_for_scopes(used_libs,
                        '-L{0} -l{1}'.format(lib_dir, lib), ['!win32'])
            else:
                self._add_value_for_scopes(used_libs,
                        '-L{0} -l{1}'.format(lib_dir, lib))

        # Handle any standard library extension modules.
        if len(required_ext) != 0:
            source_dir = project.path_from_user(project.python_source_dir)
            source_scopes = set()

            for name, module in required_ext.items():
                # Get the list of all applicable scopes.
                module_scopes = self._stdlib_scopes(module.scope)

                if len(module_scopes) == 0:
                    # The module is specific to a platform for which we are
                    # using the python.org Python libraries so ignore it
                    # completely.
                    continue

                self._add_value_for_scopes(used_inittab, name, module_scopes)
开发者ID:doudz,项目名称:pyqtdeploy,代码行数:70,代码来源:builder.py

示例12: _generate_resource

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
    def _generate_resource(self, resources_dir, required_py, job_writer, nr_resources):
        """ Generate the application resource. """

        project = self._project

        self._create_directory(resources_dir)
        resource_contents = []

        # Handle any application package.
        if project.application_package.name is not None:
            fi = QFileInfo(project.path_from_user(
                    project.application_package.name))

            package_src_dir = fi.canonicalFilePath()

            package_name = project.application_package.name
            if package_name != '':
                package_name = fi.completeBaseName()

            self._write_package(resource_contents, resources_dir, package_name,
                    project.application_package, package_src_dir, job_writer)

        # Handle the Python standard library.
        self._write_stdlib_py(resource_contents, resources_dir, required_py,
                job_writer)

        # Handle any additional packages.
        for package in project.other_packages:
            self._write_package(resource_contents, resources_dir, '', package,
                    project.path_from_user(package.name), job_writer)

        # Handle the PyQt package.
        if len(project.pyqt_modules) != 0:
            pyqt_subdir = 'PyQt5' if project.application_is_pyqt5 else 'PyQt4'
            pyqt_dst_dir = resources_dir + '/' +  pyqt_subdir
            pyqt_src_dir = project.path_from_user(project.python_target_stdlib_dir) + '/site-packages/' + pyqt_subdir

            self._create_directory(pyqt_dst_dir)

            self._freeze(job_writer, pyqt_dst_dir + '/__init__.pyo',
                    pyqt_src_dir + '/__init__.py',
                    pyqt_subdir + '/__init__.pyo')

            resource_contents.append(pyqt_subdir + '/__init__.pyo')

            # Handle the PyQt.uic package.
            if 'uic' in project.pyqt_modules:
                skip_dirs = ['__pycache__']
                if project.python_target_version[0] == 3:
                    skip_dirs.append('port_v2')
                else:
                    skip_dirs.append('port_v3')

                def copy_freeze(src, dst):
                    for skip in skip_dirs:
                        if skip in src:
                            break
                    else:
                        if dst.endswith('.py'):
                            dst += 'o'

                            src = QDir.fromNativeSeparators(src)
                            dst = QDir.fromNativeSeparators(dst)
                            rel_dst = dst[len(resources_dir) + 1:]

                            self._freeze(job_writer, dst, src, rel_dst)

                            resource_contents.append(rel_dst)

                shutil.copytree(QDir.toNativeSeparators(pyqt_src_dir + '/uic'),
                        QDir.toNativeSeparators(pyqt_dst_dir + '/uic'),
                        copy_function=copy_freeze)

        # Write the .qrc files.
        if nr_resources == 1:
            resource_names = [self._write_resource(resources_dir,
                    resource_contents)]
        else:
            resource_names = []

            nr_files = len(resource_contents)

            if nr_resources > nr_files:
                nr_resources = nr_files

            per_resource = (nr_files + nr_resources - 1) // nr_resources
            start = 0

            for r in range(nr_resources):
                end = start + per_resource
                if end > nr_files:
                    end = nr_files

                resource_names.append(
                        self._write_resource(resources_dir,
                                resource_contents[start:end], r))
                start += per_resource

        return resource_names
开发者ID:doudz,项目名称:pyqtdeploy,代码行数:101,代码来源:builder.py

示例13: getBaseName

# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import completeBaseName [as 别名]
 def getBaseName(self):
     if self._fileName:
         fileinfo = QFileInfo(self._fileName)
         basename = fileinfo.completeBaseName()
         return basename if basename else fileinfo.fileName()
     return self.tr("New document")
开发者ID:retext-project,项目名称:retext,代码行数:8,代码来源:tab.py


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