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","."]
docstr: Create Range and RangeAdapter classes if needed.
docstr_tok: ["Create","Range","and","RangeAdapter","classes","if","needed","."]
code: def _create_ranges(self, pgrange, pyrange):
      """Create Range and RangeAdapter classes if needed."""
      # if got a string create a new RangeAdapter concrete type (with a name)
      # else take it as an adapter. Passing an adapter should be considered
      # an implementation detail and is not documented. It is currently used
      # for the numeric ranges.
      self.adapter = None
      if isinstance(pgrange, str):
          self.adapter = type(pgrange, (RangeAdapter,), {})
          self.adapter.name = pgrange
      else:
          try:
              if (
                  issubclass(pgrange, RangeAdapter)
                  and pgrange is not RangeAdapter
              ):
                  self.adapter = pgrange
          except TypeError:
              pass
  
      if self.adapter is None:
          raise TypeError(
              "pgrange must be a string or a RangeAdapter strict subclass"
          )
  
      self.range = None
      try:
          if isinstance(pyrange, str):
              self.range = type(pyrange, (Range,), {})
          if issubclass(pyrange, Range) and pyrange is not Range:
              self.range = pyrange
      except TypeError:
          pass
  
      if self.range is None:
          raise TypeError(
              "pyrange must be a type or a Range strict subclass"
          )
  
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 2 for calling the RangeCaster obj's underlying member method code with example usage: obj._create_ranges(pgrange, pyrange) without return types