active_suite.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from types import MappingProxyType
  2. from datalad import cfg
  3. spec = None
  4. # names of parameters to exclude for any command
  5. # exclude_parameters = set()
  6. # mapping of parameter names to display names
  7. # to be applied across all commands
  8. # parameter_display_names = {}
  9. # mapping of group name/title to sort index
  10. # api_group_order = {}
  11. #
  12. # API specifications
  13. #
  14. # commands that operate on datasets
  15. dataset_api = None
  16. # commands that operate on any directory
  17. directory_api = None
  18. # commands that operate on directories in datasets
  19. directory_in_ds_api = None
  20. # commands that operate on any file
  21. file_api = None
  22. # commands that operate on any file in a dataset
  23. file_in_ds_api = None
  24. # command that operate on annex'ed files
  25. annexed_file_api = None
  26. # commands that have no specific target type, or another than
  27. # dataset, dir, file etc from above
  28. other_api = None
  29. active_suite = cfg.obtain('datalad.gooey.active-suite')
  30. from datalad.support.entrypoints import iter_entrypoints
  31. for sname, _, sload in iter_entrypoints(
  32. 'datalad.gooey.suites', load=False):
  33. if sname != active_suite:
  34. continue
  35. # deposit the spec in read-only form
  36. spec = MappingProxyType(sload())
  37. # deploy convenience importable symbols
  38. for apiname, api in spec.get('apis', {}).items():
  39. globals()[f"{apiname}_api"] = api
  40. if spec is None:
  41. raise RuntimeError(
  42. f'No active Gooey suite {active_suite!r}! Imploding...')
  43. api = dict()
  44. print(active_suite)
  45. for a in active_suite.get('apis', {}).values():
  46. if a:
  47. api.update(a)