No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

specs.py 823B

12345678910111213141516171819202122
  1. ##@brief Contains some constants in order to check that a LeObject child
  2. #is compatible with the datasource
  3. #
  4. #@note isolated in order to be usable by __init__.py and main.py
  5. LEO_NAME = 'Lodelsite'
  6. MANDATORY_FIELDNAMES = [ 'shortname', 'extensions', 'em_groups' ]
  7. ##@brief Checks that given emcomponent is compatible with datasource
  8. #behavior
  9. #@warning 100% hardcoded checks on leo name fieldnames & types
  10. #@param emcomp LeObject subclass (or instance)
  11. #@return a tuple (bool, reason_str)
  12. def check(leo):
  13. if not hasattr(leo, '__name__'):
  14. leo = leo.__class__
  15. if leo.__name__ != LEO_NAME:
  16. return (False, 'bad name')
  17. missings = set(MANDATORY_FIELDNAMES) - set(leo.fieldnames())
  18. if len(missings) > 0:
  19. return (False, 'missing fields : ' + (', '.join(missings)))
  20. return (True, 'ok')