code: def parse_inventory_category_entry(raw, fields):
      
      r = raw
  
      obj = {}
      bytes_read = 0
      discard = False
      for field in fields:
          value = struct.unpack_from(field.fmt, r)[0]
          read = struct.calcsize(field.fmt)
          bytes_read += read
          r = r[read:]
          # If this entry is not actually present, just parse and then discard it
          if field.presence and not bool(value):
              discard = True
          if not field.include:
              continue
  
          if (field.fmt[-1] == "s"):
              value = value.rstrip("\x00")
          if (field.mapper and value in field.mapper):
              value = field.mapper[value]
          if (field.valuefunc):
              value = field.valuefunc(value)
  
          if not field.multivaluefunc:
              obj[field.name] = value
          else:
              for key in value:
                  obj[key] = value[key]
  
      if discard:
          obj = None
      return bytes_read, obj
docs: Parses one entry in an inventory category.
  
      :param raw: the raw data to the entry. May contain more than one entry,
                  only one entry will be read in that case.
      :param fields: an iterable of EntryField objects to be used for parsing the
                     entry.
  
      :returns: dict -- a tuple with the number of bytes read and a dictionary
                        representing the entry.