-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
__init__.py
71 lines (59 loc) · 2.47 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
***************************************************************************
__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"
import os
import codecs
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
import yaml
from qgis.core import QgsSettings, Qgis
from qgis.PyQt.QtCore import QLocale, QCoreApplication
def loadShortHelp():
h = {}
path = os.path.dirname(__file__)
for f in os.listdir(path):
if f.endswith("yaml"):
filename = os.path.join(path, f)
with codecs.open(filename, encoding="utf-8") as stream:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
for k, v in yaml.load(stream, Loader=yaml.SafeLoader).items():
if v is None:
continue
h[k] = QCoreApplication.translate(
f"{f[:-5].upper()}Algorithm", v
)
version = ".".join(Qgis.QGIS_VERSION.split(".")[0:2])
overrideLocale = QgsSettings().value("locale/overrideFlag", False, bool)
if not overrideLocale:
locale = QLocale.system().name()[:2]
else:
locale = QgsSettings().value("locale/userLocale", "")
locale = locale.split("_")[0]
def replace(s):
if s is not None:
return s.replace(
"{qgisdocs}", f"https://docs.qgis.org/{version}/{locale}/docs"
)
else:
return None
h = {k: replace(v) for k, v in list(h.items())}
return h
shortHelp = loadShortHelp()