src/eric7/PluginManager/PluginUtilities.py

branch
eric7
changeset 10060
b946699e9e79
child 10439
21c28b0f9e41
equal deleted inserted replaced
10059:9e3452188615 10060:b946699e9e79
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing common utility functions needed for plugin management.
8 """
9
10
11 def getPluginHeaderEntry(plugin, entry, default):
12 """
13 Function to get an entry of the plugin header.
14
15 @param plugin reference to the plugin module
16 @type module
17 @param entry name of the entry
18 @type str
19 @param default value to be returned if the entry does not exist
20 @type Any
21 @return requested value
22 @rtype Any
23 """
24 header = getattr(plugin, "__header__", None)
25 if header:
26 return header.get(entry, default)
27 else:
28 # old-style plugin header
29 return getattr(plugin, entry, default)
30
31
32 def hasPluginHeaderEntry(plugin, entry):
33 """
34 Function to check, if the plugin header contains the given entry.
35
36 @param plugin reference to the plugin module
37 @type module
38 @param entry name of the entry
39 @type str
40 @return flag indicating the existence
41 @rtype bool
42 """
43 header = getattr(plugin, "__header__", None)
44 if header:
45 return entry in header
46 else:
47 # old-style plugin header
48 return hasattr(plugin, entry)

eric ide

mercurial