code: def _generate_data_for_format(fmt):
      
      # finally try some data, create some random data for the fmt.
      data = {}
      # keep track of how many "free_size" (wildcard) parameters we have
      # if we get two in a row then we know the pattern is invalid, meaning
      # we'll never be able to match the second wildcard field
      free_size_start = False
      for literal_text, field_name, format_spec, conversion in formatter.parse(fmt):
          if literal_text:
              free_size_start = False
  
          if not field_name:
              free_size_start = False
              continue
  
          # encapsulating free size keys,
          # e.g. {:s}{:s} or {:s}{:4s}{:d}
          if not format_spec or format_spec == "s" or format_spec == "d":
              if free_size_start:
                  return None
              else:
                  free_size_start = True
  
          # make some data for this key and format
          if format_spec and '%' in format_spec:
              # some datetime
              t = dt.datetime.now()
              # run once through format to limit precision
              t = parse(
                  "{t:" + format_spec + "}", compose("{t:" + format_spec + "}", {'t': t}))['t']
              data[field_name] = t
          elif format_spec and 'd' in format_spec:
              # random number (with n sign. figures)
              if not format_spec.isalpha():
                  n = _get_number_from_fmt(format_spec)
              else:
                  # clearly bad
                  return None
              data[field_name] = random.randint(0, 99999999999999999) % (10 ** n)
          else:
              # string type
              if format_spec is None:
                  n = 4
              elif format_spec.isalnum():
                  n = _get_number_from_fmt(format_spec)
              else:
                  n = 4
              randstri = ''
              for x in range(n):
                  randstri += random.choice(string.ascii_letters)
              data[field_name] = randstri
      return data
docs: Generate a fake data dictionary to fill in the provided format string.