Brain.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. class Brain:
  2. """
  3. This Class is a Singleton Representing the Brain.yml file with synapse
  4. .. note:: the is_loaded Boolean is True when the Brain has been properly loaded.
  5. """
  6. def __init__(self, synapses=None, brain_file=None, brain_yaml=None):
  7. self.synapses = synapses
  8. self.brain_file = brain_file
  9. self.brain_yaml = brain_yaml
  10. def get_synapse_by_name(self, synapse_name):
  11. """
  12. Get the synapse, using its synapse name, from the synapse list
  13. :param synapse_name: the name of the synapse to get
  14. :type synapse_name: str
  15. :return: The Synapse corresponding to the name
  16. :rtype: Synapse
  17. """
  18. synapse_launched = None
  19. for synapse in self.synapses:
  20. if synapse.name == synapse_name:
  21. synapse_launched = synapse
  22. # we found the synapse, we don't need to check the rest of the list
  23. break
  24. return synapse_launched
  25. def __eq__(self, other):
  26. """
  27. This is used to compare 2 objects
  28. :param other:
  29. :return:
  30. """
  31. return self.__dict__ == other.__dict__