Allow missing values of remote block for GTS support
This commit is contained in:
parent
569cff0957
commit
27168a2a6e
@ -37,14 +37,19 @@ class Instance:
|
|||||||
return exportable
|
return exportable
|
||||||
|
|
||||||
def parse_remote_block(self, instance_dict):
|
def parse_remote_block(self, instance_dict):
|
||||||
self.domain = instance_dict["domain"]
|
# this specifies possible properties and default values if not found on the remote source. If a default is None
|
||||||
self.id = instance_dict["id"]
|
# the value is required and the parse will fail
|
||||||
self.severity = instance_dict["severity"]
|
properties_and_defaults = [("domain", None), ("id", None), ("severity", "suspend"), ("public_comment", ""),
|
||||||
self.public_comment = instance_dict["public_comment"]
|
("private_comment", ""), ("obfuscate", False), ("reject_media", True),
|
||||||
self.private_comment = instance_dict["private_comment"]
|
("reject_reports", True)]
|
||||||
self.obfuscate = instance_dict["obfuscate"]
|
for key, default in properties_and_defaults:
|
||||||
self.reject_media = instance_dict["reject_media"]
|
try:
|
||||||
self.reject_reports = instance_dict["reject_reports"]
|
setattr(self, key, instance_dict[key])
|
||||||
|
except KeyError:
|
||||||
|
if default is not None:
|
||||||
|
setattr(self, key, default)
|
||||||
|
else:
|
||||||
|
raise KeyError(f"The key {key} was not in the remote servers response.")
|
||||||
|
|
||||||
def parse_local_block(self, instance_dict):
|
def parse_local_block(self, instance_dict):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user