本文整理汇总了Python中qgis.core.QgsApplication.qgisSettingsDirPath方法的典型用法代码示例。如果您正苦于以下问题:Python QgsApplication.qgisSettingsDirPath方法的具体用法?Python QgsApplication.qgisSettingsDirPath怎么用?Python QgsApplication.qgisSettingsDirPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsApplication
的用法示例。
在下文中一共展示了QgsApplication.qgisSettingsDirPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testResetScriptFolder
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def testResetScriptFolder(self):
# if folder exist
defaultScriptFolder = ScriptUtils.defaultScriptsFolder()
folder = ScriptUtils.resetScriptFolder(defaultScriptFolder)
self.assertEqual(folder, defaultScriptFolder)
folder = ScriptUtils.resetScriptFolder('.')
self.assertEqual(folder, '.')
# if folder does not exist and not absolute
folder = ScriptUtils.resetScriptFolder('fake')
self.assertEqual(folder, None)
# if absolute but not relative to QgsApplication.qgisSettingsDirPath()
folder = os.path.join(tempfile.gettempdir(), 'fakePath')
newFolder = ScriptUtils.resetScriptFolder(folder)
self.assertEqual(newFolder, folder)
# if absolute profile but poiting somewhere
# reset the path as pointing to profile into the current settings
folder = QgsApplication.qgisSettingsDirPath()
# modify default profile changing absolute path pointing somewhere
paths = folder.split(os.sep)
paths[0] = '/'
paths[1] = 'fakelocation'
folder = os.path.join(*paths)
folder = ScriptUtils.resetScriptFolder(folder)
self.assertEqual(folder, QgsApplication.qgisSettingsDirPath())
示例2: customProfileFiles
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def customProfileFiles():
customProfileFilepath = os.path.join(QgsApplication.qgisSettingsDirPath(), 'profiles')
if os.path.exists(customProfileFilepath):
return glob.glob(os.path.join(customProfileFilepath, '*.json'))
else:
return []
示例3: save_profile_as
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def save_profile_as(self):
"""Save the minimum needs under a new profile name.
"""
# noinspection PyCallByClass,PyTypeChecker
file_name_dialog = QFileDialog(self)
file_name_dialog.setAcceptMode(QFileDialog.AcceptSave)
file_name_dialog.setNameFilter(self.tr('JSON files (*.json *.JSON)'))
file_name_dialog.setDefaultSuffix('json')
dir = os.path.join(QgsApplication.qgisSettingsDirPath(),
'inasafe', 'minimum_needs')
file_name_dialog.setDirectory(expanduser(dir))
if file_name_dialog.exec_():
file_name = file_name_dialog.selectedFiles()[0]
else:
return
file_name = basename(file_name)
file_name = file_name.replace('.json', '')
minimum_needs = {'resources': []}
self.mark_current_profile_as_saved()
for index in range(self.resources_list.count()):
item = self.resources_list.item(index)
minimum_needs['resources'].append(item.resource_full)
minimum_needs['provenance'] = self.provenance.text()
minimum_needs['profile'] = file_name
self.minimum_needs.update_minimum_needs(minimum_needs)
self.minimum_needs.save()
self.minimum_needs.save_profile(file_name)
if self.profile_combo.findText(file_name) == -1:
self.profile_combo.addItem(file_name)
self.profile_combo.setCurrentIndex(
self.profile_combo.findText(file_name))
示例4: new_profile
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def new_profile(self):
"""Create a new profile by name.
"""
# noinspection PyCallByClass,PyTypeChecker
dir = os.path.join(QgsApplication.qgisSettingsDirPath(),
'inasafe', 'minimum_needs')
file_name, __ = QFileDialog.getSaveFileName(
self,
self.tr('Create a minimum needs profile'),
expanduser(dir),
self.tr('JSON files (*.json *.JSON)'),
options=QFileDialog.DontUseNativeDialog)
if not file_name:
return
file_name = basename(file_name)
if self.profile_combo.findText(file_name) == -1:
minimum_needs = {
'resources': [], 'provenance': '', 'profile': file_name}
self.minimum_needs.update_minimum_needs(minimum_needs)
self.minimum_needs.save_profile(file_name)
self.profile_combo.addItem(file_name)
self.clear_resource_list()
self.profile_combo.setCurrentIndex(
self.profile_combo.findText(file_name))
else:
self.profile_combo.setCurrentIndex(
self.profile_combo.findText(file_name))
self.select_profile_by_name(file_name)
示例5: installFromStandardPath
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def installFromStandardPath():
"""Also install all plugins from "standard" location
"""
dirName = os.path.join(QgsApplication.qgisSettingsDirPath(), firstRunPluginsPath)
if os.path.isdir(dirName):
installAllFromDirectory(dirName)
shutil.rmtree(dirName)
示例6: root_directory
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def root_directory(self):
"""Map the root directory to ~/.qgis2/inasafe so the minimum needs
profile will be placed there (~/.qgis2/inasafe/minimum_needs).
:returns: root directory
:rtype: QString
"""
if not QgsApplication.qgisSettingsDirPath() or (
QgsApplication.qgisSettingsDirPath() == ''):
self._root_directory = None
else:
# noinspection PyArgumentList
self._root_directory = os.path.join(
QgsApplication.qgisSettingsDirPath(),
'inasafe')
return self._root_directory
示例7: storeCurrentConfiguration
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def storeCurrentConfiguration():
global userProfile
folder = os.path.join(QgsApplication.qgisSettingsDirPath(), 'profiles')
filepath = os.path.join(folder, 'profile%s.json' % str(time.time()))
name = time.strftime("%b %d %Y %H:%M:%S", time.gmtime(time.time()))
description = "This profile was created based on your QGIS configuration at %s" % name
if not os.path.exists(folder):
os.mkdir(folder)
saveCurrentStatus(filepath, name, description=description)
示例8: load_packages
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def load_packages():
# Load all the Python modules found in the users command bar folder
folder = os.path.join(QgsApplication.qgisSettingsDirPath(), "python",
"commandbar")
try:
os.makedirs(folder)
except OSError:
pass
command.load_packages([folder])
示例9: getTemplates
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def getTemplates():
fl = os.path.join(QgsApplication.qgisSettingsDirPath(),
"qgis2web",
"templates")
if not os.path.exists(fl):
shutil.copytree(os.path.join(os.path.dirname(__file__),
"templates"),
fl)
return tuple(f[:f.find(".")] for f in reversed(os.listdir(fl))
if f.endswith("html"))
示例10: setStyleLayer
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def setStyleLayer(qml):
qmlFile = "%saddlayersql_action_temp.qml" % ( QgsApplication.qgisSettingsDirPath() )
if os.path.exists(qmlFile):
os.remove( qmlFile )
f = codecs.open( qmlFile, 'w', encoding='utf8')
f.write( qml )
f.close()
#
layerQuery.loadNamedStyle( qmlFile )
#
os.remove( qmlFile )
示例11: replaceInTemplate
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def replaceInTemplate(template, values):
path = os.path.join(QgsApplication.qgisSettingsDirPath(),
"qgis2web",
"templates",
template)
with open(path) as f:
lines = f.readlines()
s = "".join(lines)
for name, value in values.items():
s = s.replace(name, value)
return s
示例12: is_plugin_installed
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def is_plugin_installed(name):
"""Check if a plugin is installed, even if it's not enabled.
:param name: Name of the plugin to check.
:type name: string
:return: If the plugin is installed.
:rtype: bool
"""
directory = QgsApplication.qgisSettingsDirPath()
return isdir(join(directory, 'python', 'plugins', name))
示例13: setRepositoryUrl
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def setRepositoryUrl():
"""Adds Boundless repository URL to Connect settings"""
fName = os.path.join(QgsApplication.qgisSettingsDirPath(), repoUrlFile)
if os.path.exists(fName):
cfg = ConfigParser.SafeConfigParser()
cfg.read(fName)
url = cfg.get('general', 'repoUrl')
os.remove(fName)
else:
url = defaultRepoUrl
settings = QSettings('Boundless', 'BoundlessConnect')
settings.setValue('repoUrl', url)
示例14: _downgradePlugin
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def _downgradePlugin(pluginName, corePlugin=True):
if corePlugin:
metadataPath = os.path.join(QgsApplication.pkgDataPath(), 'python', 'plugins', pluginName, 'metadata.txt')
else:
metadataPath = os.path.join(QgsApplication.qgisSettingsDirPath()(), 'python', 'plugins', pluginName, 'metadata.txt')
cfg = ConfigParser()
cfg.read(metadataPath)
global originalVersion
originalVersion = cfg.get('general', 'version')
cfg.set('general', 'version', '0.0.1')
with open(metadataPath, 'wb') as f:
cfg.write(f)
示例15: setRepositoryUrl
# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import qgisSettingsDirPath [as 别名]
def setRepositoryUrl():
"""Adds Boundless repository URL to Connect settings"""
fName = os.path.join(QgsApplication.qgisSettingsDirPath(), repoUrlFile)
if os.path.exists(fName):
cfg = ConfigParser()
cfg.read(fName)
url = cfg.get('general', 'repoUrl')
os.remove(fName)
else:
url = pluginSetting('repoUrl')
setPluginSetting('repoUrl', url)
return url