From ea118eddd2229a9a4b06859cc2f2301cc6745bd9 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sat, 15 Jun 2024 01:11:20 -0400 Subject: [PATCH] fix `SyntaxWarning: invalid escape sequence` (#274) * fix `SyntaxWarning: invalid escape sequence` ``` /opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/gromacs/fileformats/mdp.py:61: SyntaxWarning: invalid escape sequence '\s' COMMENT = re.compile("""\s*;\s*(?P.*)""") # eat initial ws /opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/gromacs/fileformats/mdp.py:64: SyntaxWarning: invalid escape sequence '\s' """ /opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/gromacs/fileformats/ndx.py:89: SyntaxWarning: invalid escape sequence '\s' SECTION = re.compile("""\s*\[\s*(?P\S.*\S)\s*\]\s*""") /opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/gromacs/fileformats/xpm.py:122: SyntaxWarning: invalid escape sequence '\s' """\ ``` * `\` should be removed when using `r` --- gromacs/fileformats/mdp.py | 2 +- gromacs/fileformats/ndx.py | 2 +- gromacs/fileformats/xpm.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gromacs/fileformats/mdp.py b/gromacs/fileformats/mdp.py index e14a2b94..01c93c5e 100644 --- a/gromacs/fileformats/mdp.py +++ b/gromacs/fileformats/mdp.py @@ -58,7 +58,7 @@ class MDP(odict, utilities.FileUtils): COMMENT = re.compile("""\s*;\s*(?P.*)""") # eat initial ws # see regex in cbook.edit_mdp() PARAMETER = re.compile( - """ + r""" \s*(?P[^=]+?)\s*=\s* # parameter (ws-stripped), before '=' (?P[^;]*) # value (stop before comment=;) (?P\s*;.*)? # optional comment diff --git a/gromacs/fileformats/ndx.py b/gromacs/fileformats/ndx.py index 4356a4f2..8bea2546 100644 --- a/gromacs/fileformats/ndx.py +++ b/gromacs/fileformats/ndx.py @@ -82,7 +82,7 @@ class NDX(odict, utilities.FileUtils): default_extension = "ndx" # match: [ index_groupname ] - SECTION = re.compile("""\s*\[\s*(?P\S.*\S)\s*\]\s*""") + SECTION = re.compile(r"""\s*\[\s*(?P\S.*\S)\s*\]\s*""") #: standard ndx file format: 15 columns ncol = 15 diff --git a/gromacs/fileformats/xpm.py b/gromacs/fileformats/xpm.py index 3386cbb8..a60bd04d 100644 --- a/gromacs/fileformats/xpm.py +++ b/gromacs/fileformats/xpm.py @@ -115,7 +115,7 @@ class XPM(utilities.FileUtils): #: #: .. _`printable ASCII character`: http://www.danshort.com/ASCIImap/indexhex.htm COLOUR = re.compile( - """\ + r""" ^.*" # start with quotation mark (?P[\x20-\x7E])# printable ASCII symbol used in the actual pixmap: 'space' to '~' \s+ # white-space separated