ConfigurationChecker.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. class NoSynapeName(Exception):
  2. pass
  3. class NoSynapeNeurons(Exception):
  4. pass
  5. class NoSynapeSignals(Exception):
  6. pass
  7. class NoValidSignal(Exception):
  8. pass
  9. class NoEventID(Exception):
  10. pass
  11. class NoEventPeriod(Exception):
  12. pass
  13. class ConfigurationChecker:
  14. def __init__(self):
  15. pass
  16. @staticmethod
  17. def check_synape_dict(synape_dict):
  18. if 'name' not in synape_dict:
  19. raise NoSynapeName("The Synapse does not have a name: %s" % synape_dict)
  20. if 'neurons' not in synape_dict:
  21. raise NoSynapeNeurons("The Synapse does not have neurons: %s" % synape_dict)
  22. if 'signals' not in synape_dict:
  23. raise NoSynapeSignals("The Synapse does not have signals: %s" % synape_dict)
  24. return True
  25. @staticmethod
  26. def check_neuron_dict(neuron_dict):
  27. # TODO check that the Neuron plugin exist
  28. return True
  29. @staticmethod
  30. def check_signal_dict(signal_dict):
  31. if ('event' not in signal_dict) and ('order' not in signal_dict):
  32. raise NoValidSignal("The signal is not an event or an order %s" % signal_dict)
  33. return True
  34. @staticmethod
  35. def check_event_dict(event_dict):
  36. # if 'id' not in event_dict:
  37. # raise NoEventID("Event must contain a unique ID: %s" % event_dict)
  38. if 'period' not in event_dict:
  39. raise NoEventPeriod("Event must contain a period: %s" % event_dict)
  40. return True
  41. @staticmethod
  42. def check_order_dict(order_dict):
  43. if order_dict is not None:
  44. return True
  45. return False
  46. @staticmethod
  47. def check_synapes(synapses_list):
  48. """
  49. Check the synapse list is ok. No double same name
  50. :param synapses_list:
  51. :type synapses_list: list of Synapse
  52. :return:
  53. """
  54. # TODO: check no same name
  55. pass