code: def extract_format_spec(cls, format):
          
          # -- BASED-ON: parse.extract_format()
          # pylint: disable=redefined-builtin, unsubscriptable-object
          if not format:
              raise ValueError("INVALID-FORMAT: %s (empty-string)" % format)
  
          orig_format = format
          fill = align = None
          if format[0] in cls.ALIGN_CHARS:
              align = format[0]
              format = format[1:]
          elif len(format) > 1 and format[1] in cls.ALIGN_CHARS:
              fill = format[0]
              align = format[1]
              format = format[2:]
  
          zero = False
          if format and format[0] == '0':
              zero = True
              format = format[1:]
  
          width = ''
          while format:
              if not format[0].isdigit():
                  break
              width += format[0]
              format = format[1:]
  
          precision = None
          if format.startswith('.'):
              # Precision isn't needed but we need to capture it so that
              # the ValueError isn't raised.
              format = format[1:]  # drop the '.'
              precision = ''
              while format:
                  if not format[0].isdigit():
                      break
                  precision += format[0]
                  format = format[1:]
  
          # the rest is the type, if present
          type = format
          if not type:
              raise ValueError("INVALID-FORMAT: %s (without type)" % orig_format)
          return FormatSpec(type, width, zero, align, fill, precision)
docs: Pull apart the format: [[fill]align][0][width][.precision][type]