本文整理汇总了Python中PySide.QtCore.QDir.fromNativeSeparators方法的典型用法代码示例。如果您正苦于以下问题:Python QDir.fromNativeSeparators方法的具体用法?Python QDir.fromNativeSeparators怎么用?Python QDir.fromNativeSeparators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QDir
的用法示例。
在下文中一共展示了QDir.fromNativeSeparators方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onBrowseClicked
# 需要导入模块: from PySide.QtCore import QDir [as 别名]
# 或者: from PySide.QtCore.QDir import fromNativeSeparators [as 别名]
def onBrowseClicked(self):
"""Slot. Called when the user clicks on the `browseButton` button"""
# Presents the user with a native directory selector window
localdir = QFileDialog.getExistingDirectory()
localdir = QDir.fromNativeSeparators(localdir)
if len(localdir) > 0:
# If `localdir`'s value is good, store it using a `QSettings` object
# and triggers a sync request.
# Careful with '\' separators on Windows.
localdir = QDir.toNativeSeparators(localdir)
get_settings().setValue(SettingsKeys['localdir'], localdir)
self.localdirEdit.setText(localdir)
示例2: checkout
# 需要导入模块: from PySide.QtCore import QDir [as 别名]
# 或者: from PySide.QtCore.QDir import fromNativeSeparators [as 别名]
def checkout(self):
"""
Recursively checks out all files on the server.
Returns a dictionary of files on the server with their last modified date.
:param download: Indicates whether or not the files should be downloaded
"""
# Check `self.deleteQueue`, `self.uploadQueue` and `self.downloadQueue` queues.
# These tasks are done in queues to make sure all FTP commands
# are done sequentially, in the same thread.
self.deleteAll()
self.uploadAll()
self.downloadAll()
# Handy list to keep track of the checkout process.
# This list contain absolute paths only.
checked_dirs = list()
# Sets '/' as initial directory and initializes `downloading_dir`
self.ftp.cwd('/')
downloading_dir = self.currentdir
check_date = dt.utcnow()
sidirlist = list()
root_cached = False
fileC = 0
while True:
# Gets the list of sub directories and files inside the
# current directory `downloading_dir`.
self.textStatus.emit('Remote scan- Downloading folder list of '+downloading_dir+'...')
if root_cached and downloading_dir == '/':
dir_subdirs = saved_root_dirs
dirfiles = saved_root_files
else:
dir_subdirs = self.getDirs(downloading_dir)
if downloading_dir == '/':
saved_root_dirs = dir_subdirs
# sidirlist.extend(dir_subdirs)
self.textStatus.emit('Remote scan- Downloading files list of '+downloading_dir+'...')
dirfiles = self.getFiles(downloading_dir)
if downloading_dir == '/':
saved_root_files = dirfiles
root_cached = True
# Leading '/' in `downloading_dir` breaks the `os.path.join` call
localdir = os.path.join(self.localdir, downloading_dir[1:])
if not os.path.exists(localdir):
# Creates the directory if it doesn't already exists.
os.makedirs(localdir)
for file_ in dirfiles:
# `serverpath` is the absolute path of the file on the server,
# download it only if it hasn't been already downloaded
serverpath = os.path.join(downloading_dir, file_)
serverpath = QDir.fromNativeSeparators(serverpath)
server_file = File.fromPath(serverpath)
self.textStatus.emit('Scanning remote file... '+serverpath+'...')
# How do we know if we should check this server file?
# We see if the date last checked is the check start time.
if server_file.last_checked_server != check_date:
# Do this process only once per file
# Added by Simon
# Give feedback on scanning of files.
fileC += 1
if fileC % 1 == 2:
self.textStatus.emit('Scanning remote files for changes, '+str(fileC)+' files scanned.')
# STEP: IS THIS THE FIRST TIME WE SAW THE FILE, OR WAS IT ALREADY IN OUR DB?
just_added = not server_file.inserver
# STEP: IF ITS A NEW FILE, ENSURE WE DONT WANT TO SKIP IT
# Example: If it's a temporary file, or a Unix file with a name we don't support.
if just_added:
filename = os.path.basename(serverpath)
if platform.system() == 'Windows':
badName = False
for chr in ['\\', '/', ':', '?', '"', '<', '>', '|']:
if chr in filename:
badName = True
break
if badName:
if filename not in self.warnedNames:
#.........这里部分代码省略.........
示例3: serverFromLocal
# 需要导入模块: from PySide.QtCore import QDir [as 别名]
# 或者: from PySide.QtCore.QDir import fromNativeSeparators [as 别名]
def serverFromLocal(self, localpath):
serverpath = localpath.replace(self.localdir, '')
serverpath = QDir.fromNativeSeparators(serverpath)
return serverpath