class_docstr: Handle conversion from format directives to regexes.
class_docstr_tok: ["Handle","conversion","from","format","directives","to","regexes","."]
docstr: Return regex pattern for the format string.
  
  Need to make sure that any characters that might be interpreted as
  regex syntax are escaped.
docstr_tok: ["Return","regex","pattern","for","the","format","string",".","Need","to","make","sure","that","any","characters","that","might","be","interpreted","as","regex","syntax","are","escaped","."]
code: def pattern(self, format):
      """Return regex pattern for the format string.
  
      Need to make sure that any characters that might be interpreted as
      regex syntax are escaped.
  
      """
      processed_format = ""
      # The sub() call escapes all characters that might be misconstrued
      # as regex syntax.  Cannot use re.escape since we have to deal with
      # format directives (%m, etc.).
      regex_chars = re_compile(r"([\\.^$*+?\(\){}\[\]|])")
      format = regex_chars.sub(r"\\\1", format)
      whitespace_replacement = re_compile(r"\s+")
      format = whitespace_replacement.sub(r"\\s+", format)
      while "%" in format:
          directive_index = format.index("%") + 1
          processed_format = "%s%s%s" % (
              processed_format,
              format[: directive_index - 1],
              self[format[directive_index]],
          )
          format = format[directive_index + 1 :]
      return "%s%s" % (processed_format, format)
  
imports: import time
  import locale
  import calendar
  from re import compile
  from re import IGNORECASE
  from re import escape
  from datetime import date, timedelta, timezone
  from _thread import allocate_lock
label_desc: Use image node_id 3 for calling the TimeRE obj's underlying member method code with example usage: obj.pattern(format) and returns: unknown