-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsirenicons.py
73 lines (69 loc) · 2.62 KB
/
sirenicons.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
72
73
#!/usr/bin/python3
#
# Copyright (C) 2016-2023 Sustainable Energy Now Inc., Angus King
#
# sirenicons.py - This file is part of SIREN.
#
# SIREN is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# SIREN is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General
# Public License along with SIREN. If not, see
# <http://www.gnu.org/licenses/>.
#
import configparser # decode .ini file
import sys
from getmodels import getModelFile
from senutils import techClean
class Icons:
def __init__(self):
config = configparser.RawConfigParser()
if len(sys.argv) > 1:
config_file = sys.argv[1]
else:
config_file = getModelFile('SIREN.ini')
config.read(config_file)
self.icons = {'BESS': 'bess_g.png', 'Biomass': 'biomass_g.png', 'CST': 'solar_g.png',
'Fossil': 'fossil_g.png', 'Geothermal': 'hot_rocks_g.png', 'Hydro': 'hydro_g.png',
'Offshore Wind': 'offwind_g.png', 'Other': 'question.png', 'PV': 'solar_pv_g.png',
'Solar Thermal': 'solar_g.png', 'Wave': 'wave_g.png', 'Wind': 'wind_g.png'}
try:
technologies = config.get('Power', 'technologies').split()
for tec in technologies:
tec = techClean(tec)
try:
self.icons[tec] = config.get(tec, 'icon')
except:
pass
technologies = config.get('Power', 'fossil_technologies').split()
for tec in technologies:
tec = techClean(tec)
try:
self.icons[tec] = config.get(tec, 'icon')
except:
pass
except:
pass
def getIcon(self, technology):
if technology in list(self.icons.keys()):
return self.icons[technology]
tech = technology
if technology == 'Battery':
tech = 'BESS'
elif technology == 'Biogas':
tech = 'Biomass'
elif 'PV' in technology:
tech = 'PV'
elif technology[:6] == 'Fossil':
tech = 'Fossil'
try:
return self.icons[tech]
except:
return 'question.png'