mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-17 20:23:55 +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,7 +24,7 @@ logging.debug("- %s loaded", __name__)
|
|||
class RepeatedTimer:
|
||||
|
||||
def __init__(self, interval, targetFunction, *args, **kwargs):
|
||||
"""!Create a new instance of the RepeatedTimer
|
||||
r"""!Create a new instance of the RepeatedTimer
|
||||
|
||||
@param interval: interval in sec. to recall target function
|
||||
@param targetFunction: function to call on timer event
|
||||
|
|
@ -43,7 +43,7 @@ class RepeatedTimer:
|
|||
self._thread = None
|
||||
|
||||
def start(self):
|
||||
"""!Start a new timer worker thread
|
||||
r"""!Start a new timer worker thread
|
||||
|
||||
@return True or False"""
|
||||
if self._thread is None:
|
||||
|
|
@ -58,7 +58,7 @@ class RepeatedTimer:
|
|||
return True
|
||||
|
||||
def stop(self):
|
||||
"""!Stop the timer worker thread
|
||||
r"""!Stop the timer worker thread
|
||||
|
||||
@return True or False"""
|
||||
if self._thread is not None:
|
||||
|
|
@ -71,7 +71,7 @@ class RepeatedTimer:
|
|||
return True
|
||||
|
||||
def _target(self):
|
||||
"""!Runs the target function with his arguments in own thread"""
|
||||
r"""!Runs the target function with his arguments in own thread"""
|
||||
self._start = time.time()
|
||||
while not self._event.wait(self.restTime):
|
||||
logging.debug("work")
|
||||
|
|
@ -96,12 +96,12 @@ class RepeatedTimer:
|
|||
|
||||
@property
|
||||
def isRunning(self):
|
||||
"""!Property for repeatedTimer running state"""
|
||||
r"""!Property for repeatedTimer running state"""
|
||||
if self._thread:
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def restTime(self):
|
||||
"""!Property to get remaining time till next call"""
|
||||
r"""!Property to get remaining time till next call"""
|
||||
return self._interval - ((time.time() - self._start) % self._interval)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue