check required ssdp fields

This commit is contained in:
Jack Robison 2018-10-16 09:01:49 -04:00
parent fc511cfe4e
commit df4337f5be
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -3,7 +3,7 @@ import logging
import binascii import binascii
import json import json
from collections import OrderedDict from collections import OrderedDict
from typing import Dict, List from typing import List
from aioupnp.fault import UPnPError from aioupnp.fault import UPnPError
from aioupnp.constants import line_separator from aioupnp.constants import line_separator
@ -100,6 +100,9 @@ class SSDPDatagram(object):
if not normalized.startswith("_") and hasattr(self, normalized) and getattr(self,normalized) is None: if not normalized.startswith("_") and hasattr(self, normalized) and getattr(self,normalized) is None:
setattr(self, normalized, v) setattr(self, normalized, v)
self._case_mappings: dict = {k.lower(): k for k in kwargs.keys()} self._case_mappings: dict = {k.lower(): k for k in kwargs.keys()}
for k in self._required_fields[self._packet_type]:
if getattr(self, k) is None:
raise UPnPError("missing required field %s" % k)
def get_cli_igd_kwargs(self) -> str: def get_cli_igd_kwargs(self) -> str:
fields = [] fields = []