2016-01-08 21:31:41 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
__init__.py
|
|
|
|
---------------------
|
|
|
|
Date : January 2016
|
|
|
|
Copyright : (C) 2016 by Victor Olaya
|
|
|
|
Email : volayaf at gmail dot com
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Victor Olaya'
|
|
|
|
__date__ = 'January 2016'
|
|
|
|
__copyright__ = '(C) 2016, Victor Olaya'
|
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
2016-01-08 08:27:22 +01:00
|
|
|
import os
|
2016-11-24 09:40:22 -07:00
|
|
|
import codecs
|
2019-03-04 21:31:08 +10:00
|
|
|
import warnings
|
|
|
|
with warnings.catch_warnings():
|
|
|
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
|
|
import yaml
|
|
|
|
|
2017-03-03 20:39:17 +01:00
|
|
|
from qgis.core import QgsSettings, Qgis
|
2019-02-26 22:13:02 +01:00
|
|
|
from qgis.PyQt.QtCore import QLocale, QCoreApplication
|
2016-01-08 08:27:22 +01:00
|
|
|
|
2016-01-08 10:32:43 +02:00
|
|
|
|
2016-01-08 08:27:22 +01:00
|
|
|
def loadShortHelp():
|
|
|
|
h = {}
|
|
|
|
path = os.path.dirname(__file__)
|
|
|
|
for f in os.listdir(path):
|
|
|
|
if f.endswith("yaml"):
|
|
|
|
filename = os.path.join(path, f)
|
2016-11-24 09:40:22 -07:00
|
|
|
with codecs.open(filename, encoding='utf-8') as stream:
|
2019-03-04 21:31:08 +10:00
|
|
|
with warnings.catch_warnings():
|
|
|
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
|
|
for k, v in yaml.load(stream).items():
|
|
|
|
if v is None:
|
|
|
|
continue
|
|
|
|
h[k] = QCoreApplication.translate("{}Algorithm".format(f[:-5].upper()), v)
|
2019-02-26 22:13:02 +01:00
|
|
|
|
2016-07-21 22:01:38 +10:00
|
|
|
version = ".".join(Qgis.QGIS_VERSION.split(".")[0:2])
|
2017-03-03 20:39:17 +01:00
|
|
|
overrideLocale = QgsSettings().value('locale/overrideFlag', False, bool)
|
2016-01-08 08:27:22 +01:00
|
|
|
if not overrideLocale:
|
|
|
|
locale = QLocale.system().name()[:2]
|
|
|
|
else:
|
2017-03-03 20:39:17 +01:00
|
|
|
locale = QgsSettings().value('locale/userLocale', '')
|
2016-01-08 08:27:22 +01:00
|
|
|
locale = locale.split("_")[0]
|
2016-01-08 10:32:43 +02:00
|
|
|
|
2016-01-08 08:27:22 +01:00
|
|
|
def replace(s):
|
|
|
|
if s is not None:
|
|
|
|
return s.replace("{qgisdocs}", "https://docs.qgis.org/%s/%s/docs" % (version, locale))
|
|
|
|
else:
|
|
|
|
return None
|
2019-02-26 22:13:02 +01:00
|
|
|
|
2016-09-27 19:51:06 +02:00
|
|
|
h = {k: replace(v) for k, v in list(h.items())}
|
2019-02-26 22:13:02 +01:00
|
|
|
|
2016-01-08 08:27:22 +01:00
|
|
|
return h
|
|
|
|
|
|
|
|
|
|
|
|
shortHelp = loadShortHelp()
|