pull/3/head
Raphaël Vinot 2017-07-26 16:11:46 +02:00
parent 1d1bf4f0ec
commit 20b524652d
1 changed files with 7 additions and 21 deletions

View File

@ -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,10 +245,11 @@ 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]
try:
cluster = self.clusters[cluster_type] cluster = self.clusters[cluster_type]
for v in cluster.values.values(): value = cluster[cluster_value]
if v.value == cluster_value: return cluster, value
return cluster, v except:
raise UnableToRevertMachinetag('The machinetag {} could not be found.'.format(machinetag)) raise UnableToRevertMachinetag('The machinetag {} could not be found.'.format(machinetag))
def search(self, query): def search(self, query):