mirror of https://github.com/MISP/PyMISP
chg: Test if json exists in cached method
parent
6cc7730d24
commit
cc204475ff
|
@ -60,6 +60,8 @@ if sys.version_info < (3, 0):
|
|||
@staticmethod
|
||||
@cached(cache=LRUCache(maxsize=150))
|
||||
def _load_json(path):
|
||||
if not os.path.exists(path):
|
||||
return None
|
||||
with open(path, 'r') as f:
|
||||
data = load(f)
|
||||
return data
|
||||
|
@ -80,6 +82,8 @@ else:
|
|||
@staticmethod
|
||||
@lru_cache(maxsize=150)
|
||||
def _load_json(path):
|
||||
if not path.exists():
|
||||
return None
|
||||
with path.open('r') as f:
|
||||
data = load(f)
|
||||
return data
|
||||
|
|
|
@ -1177,9 +1177,9 @@ class MISPObject(AbstractMISP):
|
|||
self.update_not_jsonable('ObjectReference')
|
||||
|
||||
def _load_template_path(self, template_path):
|
||||
if not os.path.exists(template_path):
|
||||
return False
|
||||
self._definition = self._load_json(template_path)
|
||||
if not self._definition:
|
||||
return False
|
||||
setattr(self, 'meta-category', self._definition['meta-category'])
|
||||
self.template_uuid = self._definition['uuid']
|
||||
self.description = self._definition['description']
|
||||
|
|
Loading…
Reference in New Issue