class_docstr: Helper class to convert between `Range` and PostgreSQL range types.
  
  Objects of this class are usually created by `register_range()`. Manual
  creation could be useful if querying the database is not advisable: in
  this case the oids must be provided.
class_docstr_tok: ["Helper","class","to","convert","between","`","Range","`","and","PostgreSQL","range","types",".","Objects","of","this","class","are","usually","created","by","`","register_range","(",")","`",".","Manual","creation","could","be","useful","if","querying","the","database","is","not","advisable",":","in","this","case","the","oids","must","be","provided","."]
code: def parse(self, s, cur=None):
      if s is None:
          return None
  
      if s == "empty":
          return self.range(empty=True)
  
      m = self._re_range.match(s)
      if m is None:
          raise InterfaceError(f"failed to parse range: '{s}'")
  
      lower = m.group(3)
      if lower is None:
          lower = m.group(2)
          if lower is not None:
              lower = self._re_undouble.sub(r"\1", lower)
  
      upper = m.group(5)
      if upper is None:
          upper = m.group(4)
          if upper is not None:
              upper = self._re_undouble.sub(r"\1", upper)
  
      if cur is not None:
          lower = cur.cast(self.subtype_oid, lower)
          upper = cur.cast(self.subtype_oid, upper)
  
      bounds = m.group(1) + m.group(6)
  
      return self.range(lower, upper, bounds)
  
imports: import re
  from psycopg2._psycopg import ProgrammingError, InterfaceError
  from psycopg2.extensions import ISQLQuote, adapt, register_adapter
  from psycopg2.extensions import new_type, new_array_type, register_type
label_desc: Use image node_id 4 for calling the RangeCaster obj's underlying member method code with example usage: obj.parse(s, cur) and returns: self, None, self