mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
add specific datatypes to config loader
This commit is contained in:
parent
405c632ceb
commit
0383744927
|
|
@ -59,7 +59,37 @@ class Config:
|
|||
logging.debug("configuration sharePoint: %s", sharePoint)
|
||||
return True
|
||||
|
||||
def get(self, section, key, sharePoint=""):
|
||||
def getInt(self, section, key, sharePoint=""):
|
||||
"""!Method to read a single config entry as integer
|
||||
|
||||
@param section: Section to read from
|
||||
@param key: Value to read
|
||||
@param sharePoint: Name of the global config share (empty is only local)
|
||||
@return The value or None"""
|
||||
value = int(self._get(section, key, sharePoint))
|
||||
if value is None:
|
||||
return 0
|
||||
return int(value)
|
||||
|
||||
def getBool(self, section, key, sharePoint=""):
|
||||
"""!Method to read a single config entry as boolean
|
||||
|
||||
@param section: Section to read from
|
||||
@param key: Value to read
|
||||
@param sharePoint: Name of the global config share (empty is only local)
|
||||
@return The value or None"""
|
||||
return bool(self._get(section, key, sharePoint))
|
||||
|
||||
def getStr(self, section, key, sharePoint=""):
|
||||
"""!Method to read a single config entry as string
|
||||
|
||||
@param section: Section to read from
|
||||
@param key: Value to read
|
||||
@param sharePoint: Name of the global config share (empty is only local)
|
||||
@return The value or None"""
|
||||
return str(self._get(section, key, sharePoint))
|
||||
|
||||
def _get(self, section, key, sharePoint=""):
|
||||
"""!Method to read a single config entry
|
||||
|
||||
@param section: Section to read from
|
||||
|
|
|
|||
|
|
@ -71,12 +71,12 @@ class Packet:
|
|||
- frequency"""
|
||||
config = Config()
|
||||
logging.debug("add client data to bwPacket")
|
||||
self.set("clientName", config.get("Client", "Name", "clientConfig"))
|
||||
self.set("clientName", config.getStr("Client", "Name", "clientConfig"))
|
||||
self.set("clientVersion", version.client)
|
||||
self.set("clientBuildDate", version.date)
|
||||
self.set("clientBranch", version.branch)
|
||||
self.set("inputSource", config.get("Server", "InputSource", "clientConfig"))
|
||||
self.set("frequency", config.get("Stick", "Frequency", "clientConfig"))
|
||||
self.set("inputSource", config.getStr("Server", "InputSource", "clientConfig"))
|
||||
self.set("frequency", config.getStr("Stick", "Frequency", "clientConfig"))
|
||||
|
||||
def addServerData(self):
|
||||
"""!Add the server information to the decoded data
|
||||
|
|
@ -88,7 +88,7 @@ class Packet:
|
|||
- serverBranch"""
|
||||
config = Config()
|
||||
logging.debug("add server data to bwPacket")
|
||||
self.set("serverName", config.get("Server", "Name", "serverConfig"))
|
||||
self.set("serverName", config.getStr("Server", "Name", "serverConfig"))
|
||||
self.set("serverVersion", version.server)
|
||||
self.set("serverBuildDate", version.date)
|
||||
self.set("serverBranch", version.branch)
|
||||
|
|
|
|||
Loading…
Reference in a new issue