forked from UMEP-dev/UMEP-processing
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
67 lines (55 loc) · 2.22 KB
/
Copy path__init__.py
File metadata and controls
67 lines (55 loc) · 2.22 KB
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
# -*- coding: utf-8 -*-
"""
/***************************************************************************
ProcessingUMEP
A QGIS plugin
UMEP for processing toolbox
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2020-04-02
copyright : (C) 2020 by Fredrik Lindberg
email : fredrikl@gvc.gu.se
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
This script initializes the plugin, making it known to QGIS.
"""
# 1. Initialize fallback immediately to shield all downstream imports
import site
import sys
user_site = site.getusersitepackages()
if user_site not in sys.path:
sys.path.append(user_site)
try:
import torch
except ImportError:
# Create the local mock right here
class MetaMock(type):
def __getattr__(cls, name):
if name == "is_available":
return lambda: False
return cls
def __call__(cls, *args, **kwargs):
return cls
class LocalMockTorch(metaclass=MetaMock):
pass
# Inject it into Python's module registry BEFORE QGIS loads any sub-files
sys.modules["torch"] = LocalMockTorch
__author__ = "Fredrik Lindberg"
__date__ = "2020-04-02"
__copyright__ = "(C) 2020 by Fredrik Lindberg"
# noinspection PyPep8Naming
def classFactory(iface): # pylint: disable=invalid-name
"""Load ProcessingUMEP class from file ProcessingUMEP.
:param iface: A QGIS interface instance.
:type iface: QgsInterface
"""
from .processing_umep import ProcessingUMEPPlugin
# Crucial: pass the iface variable QGIS gives you right into the plugin
return ProcessingUMEPPlugin()