mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-21 06:03:50 +00:00
Avoid "DeprecationWarning: invalid escape sequence"
Without this change, many warnings like this will be generated while running pytest:
```
test/test_template.py:3
/build/source/test/test_template.py:3: DeprecationWarning: invalid escape sequence '\/'
"""!
```
This can also be seen when manually running python with warnings enabled.
This happens because the comment uses a multiline string and Python interprets the backslash in the logo as an escape character and complains that \/ is not a valid escape sequence. To fix this, prepend the string with the letter r to indicate that the backslash should be treated as a literal character, see https://docs.python.org/3/reference/lexical_analysis.html#index-20.
I also applied this change to all the comment strings since that shouldn't break anything and to establish it as a pattern for the future so this problem hopefully never happens again.
This is what I did specifically:
- Change the comment at the top of bw_client.py and bw_server.py to start with `"""!` since that seems to be the pattern here
- Search-and-Replace all occurances of `"""!` with `r"""!`
- Manually change the strings in `logoToLog()` in boswatch/utils/header.py
This commit is contained in:
parent
1b95474bc2
commit
d4dcc75711
50 changed files with 327 additions and 327 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -24,12 +24,12 @@ logging.debug("- %s loaded", __name__)
|
|||
|
||||
|
||||
class PluginBase(ABC):
|
||||
"""!Main plugin class"""
|
||||
r"""!Main plugin class"""
|
||||
|
||||
_pluginsActive = []
|
||||
|
||||
def __init__(self, pluginName, config):
|
||||
"""!init preload some needed locals and then call onLoad() directly"""
|
||||
r"""!init preload some needed locals and then call onLoad() directly"""
|
||||
self._pluginName = pluginName
|
||||
self.config = config
|
||||
self._pluginsActive.append(self)
|
||||
|
|
@ -54,13 +54,13 @@ class PluginBase(ABC):
|
|||
self.onLoad()
|
||||
|
||||
def _cleanup(self):
|
||||
"""!Cleanup routine calls onUnload() directly"""
|
||||
r"""!Cleanup routine calls onUnload() directly"""
|
||||
logging.debug("[%s] onUnload()", self._pluginName)
|
||||
self._pluginsActive.remove(self)
|
||||
self.onUnload()
|
||||
|
||||
def _run(self, bwPacket):
|
||||
"""!start an complete running turn of an plugin.
|
||||
r"""!start an complete running turn of an plugin.
|
||||
Calls setup(), alarm() and teardown() in this order.
|
||||
The alarm() method serves the BOSWatch packet to the plugin.
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ class PluginBase(ABC):
|
|||
return None
|
||||
|
||||
def _getStatistics(self):
|
||||
"""!Returns statistical information's from last plugin run
|
||||
r"""!Returns statistical information's from last plugin run
|
||||
|
||||
@return Statistics as pyton dict"""
|
||||
stats = {"type": "plugin",
|
||||
|
|
@ -137,55 +137,55 @@ class PluginBase(ABC):
|
|||
return stats
|
||||
|
||||
def onLoad(self):
|
||||
"""!Called by import of the plugin
|
||||
r"""!Called by import of the plugin
|
||||
can be inherited"""
|
||||
pass
|
||||
|
||||
def setup(self):
|
||||
"""!Called before alarm
|
||||
r"""!Called before alarm
|
||||
can be inherited"""
|
||||
pass
|
||||
|
||||
def fms(self, bwPacket):
|
||||
"""!Called on FMS alarm
|
||||
r"""!Called on FMS alarm
|
||||
can be inherited
|
||||
|
||||
@param bwPacket: bwPacket instance"""
|
||||
logging.warning("ZVEI not implemented in %s", self._pluginName)
|
||||
|
||||
def pocsag(self, bwPacket):
|
||||
"""!Called on POCSAG alarm
|
||||
r"""!Called on POCSAG alarm
|
||||
can be inherited
|
||||
|
||||
@param bwPacket: bwPacket instance"""
|
||||
logging.warning("POCSAG not implemented in %s", self._pluginName)
|
||||
|
||||
def zvei(self, bwPacket):
|
||||
"""!Called on ZVEI alarm
|
||||
r"""!Called on ZVEI alarm
|
||||
can be inherited
|
||||
|
||||
@param bwPacket: bwPacket instance"""
|
||||
logging.warning("ZVEI not implemented in %s", self._pluginName)
|
||||
|
||||
def msg(self, bwPacket):
|
||||
"""!Called on MSG packet
|
||||
r"""!Called on MSG packet
|
||||
can be inherited
|
||||
|
||||
@param bwPacket: bwPacket instance"""
|
||||
logging.warning("MSG not implemented in %s", self._pluginName)
|
||||
|
||||
def teardown(self):
|
||||
"""!Called after alarm
|
||||
r"""!Called after alarm
|
||||
can be inherited"""
|
||||
pass
|
||||
|
||||
def onUnload(self):
|
||||
"""!Called on shutdown of boswatch
|
||||
r"""!Called on shutdown of boswatch
|
||||
can be inherited"""
|
||||
pass
|
||||
|
||||
def parseWildcards(self, msg):
|
||||
"""!Return the message with parsed wildcards"""
|
||||
r"""!Return the message with parsed wildcards"""
|
||||
if self._bwPacket is None:
|
||||
logging.warning("wildcard replacing not allowed - no bwPacket set")
|
||||
return msg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue