pdbx icon indicating copy to clipboard operation
pdbx copied to clipboard

use raw strings for all regex in PdbxReader

Open joemin opened this issue 1 year ago • 0 comments

thanks for writing all this!

I think we can avoid some SyntaxWarnings from python (examples below) if we just make all the regex strings in PdbxReader raw strings (add a leading r, like on line 340). Otherwise we end up with noisy output:

  "(?:_(.+?)[.](\S+))"               "|"  # _category.attribute
/pdbx/pdbx/reader/PdbxReader.py:345: SyntaxWarning: invalid escape sequence '\s'
  "(?:['](.*?)(?:[']\s|[']$))"       "|"  # single quoted strings
/pdbx/pdbx/reader/PdbxReader.py:346: SyntaxWarning: invalid escape sequence '\s'
  "(?:[\"](.*?)(?:[\"]\s|[\"]$))"    "|"  # double quoted strings
/pdbx/pdbx/reader/PdbxReader.py:348: SyntaxWarning: invalid escape sequence '\s'
  "(?:\s*#.*$)"                      "|"  # comments (dumped)
/pdbx/pdbx/reader/PdbxReader.py:350: SyntaxWarning: invalid escape sequence '\S'
  "(\S+)"                                 # unquoted words
/pdbx/pdbx/reader/PdbxReader.py:418: SyntaxWarning: invalid escape sequence '\S'
  "(?:_(.+?)[.](\S+))"               "|"  # _category.attribute
/pdbx/pdbx/reader/PdbxReader.py:420: SyntaxWarning: invalid escape sequence '\s'
  "(?:['\"](.*?)(?:['\"]\s|['\"]$))" "|"  # quoted strings
/pdbx/pdbx/reader/PdbxReader.py:422: SyntaxWarning: invalid escape sequence '\s'
  "(?:\s*#.*$)"                      "|"  # comments (dumped)
/pdbx/pdbx/reader/PdbxReader.py:424: SyntaxWarning: invalid escape sequence '\S'
  "(\S+)"                                 # unquoted words```
  
  thanks!

joemin avatar Jun 10 '24 22:06 joemin