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:
Luflosi 2023-09-19 16:13:23 +02:00
parent 1b95474bc2
commit d4dcc75711
No known key found for this signature in database
GPG key ID: 4E41E29EDCC345D0
50 changed files with 327 additions and 327 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""!
r"""!
____ ____ ______ __ __ __ _____
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
@ -27,7 +27,7 @@ class Decoder:
@staticmethod
def decode(data):
"""!Choose the right decoder and return a bwPacket instance
r"""!Choose the right decoder and return a bwPacket instance
@param data: data to decode
@return bwPacket instance"""

View file

@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""!
r"""!
____ ____ ______ __ __ __ _____
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
@ -24,7 +24,7 @@ logging.debug("- %s loaded", __name__)
class FmsDecoder:
"""!FMS decoder class
r"""!FMS decoder class
This class decodes FMS data.
First step is to validate the data and _check if the format is correct.
@ -32,7 +32,7 @@ class FmsDecoder:
@staticmethod
def decode(data):
"""!Decodes FMS
r"""!Decodes FMS
@param data: FMS for decoding
@return BOSWatch FMS packet or None"""

View file

@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""!
r"""!
____ ____ ______ __ __ __ _____
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
@ -24,7 +24,7 @@ logging.debug("- %s loaded", __name__)
class PocsagDecoder:
"""!POCSAG decoder class
r"""!POCSAG decoder class
This class decodes POCSAG data.
First step is to validate the data and _check if the format is correct.
@ -32,7 +32,7 @@ class PocsagDecoder:
@staticmethod
def decode(data):
"""!Decodes POCSAG
r"""!Decodes POCSAG
@param data: POCSAG for decoding
@return BOSWatch POCSAG packet or None"""
@ -63,7 +63,7 @@ class PocsagDecoder:
@staticmethod
def _getBitrateRicSubric(data):
"""!Gets the Bitrate, Ric and Subric from data
r"""!Gets the Bitrate, Ric and Subric from data
@param data: POCSAG data string
@return bitrate

View file

@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""!
r"""!
____ ____ ______ __ __ __ _____
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
@ -24,7 +24,7 @@ logging.debug("- %s loaded", __name__)
class ZveiDecoder:
"""!ZVEI decoder class
r"""!ZVEI decoder class
This class decodes ZVEI data.
First step is to validate the data and _check if the format is correct.
@ -33,7 +33,7 @@ class ZveiDecoder:
@staticmethod
def decode(data):
"""!Decodes ZVEI
r"""!Decodes ZVEI
@param data: ZVEI for decoding
@return BOSWatch ZVEI packet or None"""
@ -51,7 +51,7 @@ class ZveiDecoder:
@staticmethod
def _solveDoubleTone(data):
"""!Remove the doubleTone sign (here its the 'E')
r"""!Remove the doubleTone sign (here its the 'E')
@param data: ZVEI for double tone sign replacement
@return Double Tone replaced ZVEI"""