mirror of https://github.com/MISP/PyMISPGalaxies
Cleanup
parent
1d1bf4f0ec
commit
20b524652d
|
@ -79,12 +79,6 @@ class Galaxies(collections.Mapping):
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.galaxies)
|
return len(self.galaxies)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
to_print = ''
|
|
||||||
for galaxy in self.galaxies.values():
|
|
||||||
to_print += '{}\n\n'.format(str(galaxy))
|
|
||||||
return to_print
|
|
||||||
|
|
||||||
|
|
||||||
class ClusterValueMeta():
|
class ClusterValueMeta():
|
||||||
|
|
||||||
|
@ -173,14 +167,6 @@ class ClusterValue():
|
||||||
to_return['meta'] = self.meta._json()
|
to_return['meta'] = self.meta._json()
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
to_print = '{}\n{}'.format(self.value, self.description)
|
|
||||||
if self.meta:
|
|
||||||
to_print += '\n'
|
|
||||||
for k, v in self.meta._json().items():
|
|
||||||
to_print += '- {}:\t{}\n'.format(k, v)
|
|
||||||
return to_print
|
|
||||||
|
|
||||||
|
|
||||||
class Cluster(collections.Mapping):
|
class Cluster(collections.Mapping):
|
||||||
|
|
||||||
|
@ -229,8 +215,7 @@ class Cluster(collections.Mapping):
|
||||||
to_return = {'name': self.name, 'type': self.type, 'source': self.source,
|
to_return = {'name': self.name, 'type': self.type, 'source': self.source,
|
||||||
'authors': self.authors, 'description': self.description,
|
'authors': self.authors, 'description': self.description,
|
||||||
'uuid': self.uuid, 'version': self.version, 'values': []}
|
'uuid': self.uuid, 'version': self.version, 'values': []}
|
||||||
for v in self.values.values():
|
to_return['values'] = [v._json() for v in self.values.values()]
|
||||||
to_return['values'].append(v._json())
|
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,11 +245,12 @@ class Clusters(collections.Mapping):
|
||||||
|
|
||||||
def revert_machinetag(self, machinetag):
|
def revert_machinetag(self, machinetag):
|
||||||
_, cluster_type, cluster_value = re.findall('^([^:]*):([^=]*)="([^"]*)"$', machinetag)[0]
|
_, cluster_type, cluster_value = re.findall('^([^:]*):([^=]*)="([^"]*)"$', machinetag)[0]
|
||||||
cluster = self.clusters[cluster_type]
|
try:
|
||||||
for v in cluster.values.values():
|
cluster = self.clusters[cluster_type]
|
||||||
if v.value == cluster_value:
|
value = cluster[cluster_value]
|
||||||
return cluster, v
|
return cluster, value
|
||||||
raise UnableToRevertMachinetag('The machinetag {} could not be found.'.format(machinetag))
|
except:
|
||||||
|
raise UnableToRevertMachinetag('The machinetag {} could not be found.'.format(machinetag))
|
||||||
|
|
||||||
def search(self, query):
|
def search(self, query):
|
||||||
to_return = []
|
to_return = []
|
||||||
|
|
Loading…
Reference in New Issue