Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated escape sequences #107

Closed
kmpm opened this issue Dec 27, 2022 · 1 comment
Closed

remove deprecated escape sequences #107

kmpm opened this issue Dec 27, 2022 · 1 comment

Comments

@kmpm
Copy link
Collaborator

kmpm commented Dec 27, 2022

Running tests reveal some deprecation warnings on regex escape sequences.
These should be reworked

tests/test_bootstrap_commands.py::TestBootstrapCommands::test_import_update_gui
    D:\a\Trade-Dangerous\Trade-Dangerous\tradedangerous\commands\update_gui.py:698: DeprecationWarning: invalid escape sequence \d
      elif re.match('^\d+$', supply):
  
  tests/test_bootstrap_plugins.py::TestBootstrapPlugins::test_import_plugins_netlog
    D:\a\Trade-Dangerous\Trade-Dangerous\tradedangerous\plugins\netlog_plug.py:85: DeprecationWarning: invalid escape sequence \d
      oldHeadRegEx = re.compile("^(?P<headDateTime>\d\d-\d\d-\d\d-\d\d:\d\d)\s+(?P<headTZName>.*[^\s])\s+(?P<headTimeGMT>\(.*GMT\))")
  
  tests/test_bootstrap_plugins.py::TestBootstrapPlugins::test_import_plugins_netlog
    D:\a\Trade-Dangerous\Trade-Dangerous\tradedangerous\plugins\netlog_plug.py:86: DeprecationWarning: invalid escape sequence \d
      newHeadRegEx = re.compile("^(?P<headDateTime>\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)\s+(?P<headTZName>.*[^\s])")
  
  tests/test_bootstrap_plugins.py::TestBootstrapPlugins::test_import_plugins_netlog
    D:\a\Trade-Dangerous\Trade-Dangerous\tradedangerous\plugins\netlog_plug.py:88: DeprecationWarning: invalid escape sequence \{
      sysRegEx  = re.compile('^\{[^\}]+\}\s+System:"(?P<sysName>[^"]+)".*StarPos:\((?P<sysPos>[^)]+)\)ly')
  
  tests/test_bootstrap_plugins.py::TestBootstrapPlugins::test_import_plugins_netlog
    D:\a\Trade-Dangerous\Trade-Dangerous\tradedangerous\plugins\netlog_plug.py:89: DeprecationWarning: invalid escape sequence \{
      dateRegEx = re.compile('^\{(?P<logTime>\d\d:\d\d:\d\d)')
@eyeonus
Copy link
Owner

eyeonus commented Dec 27, 2022

From the documentation, it seems like the solution is to change for example '^\d+$' to be r"^\d+$" so that Python doesn't try to parse the escape characters itself.

Assuming all the escapes in the strings are there for the regex, that's not difficult to fix, I'll take care of it tomorrow after I get some sleep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants