simplified_api.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. from .constraints import EnsureDatasetSiblingName
  2. # each item is a command that is allowed in the API
  3. # the key is the command name in the Python API.
  4. # the values are dicts with the following keys
  5. # - exclude_parameters: set with parameter names to
  6. # exclude from the API
  7. api = dict(
  8. clone=dict(
  9. name='&Clone a dataset',
  10. exclude_parameters=set((
  11. 'git_clone_opts',
  12. 'reckless',
  13. 'description',
  14. )),
  15. parameter_display_names=dict(
  16. source='Clone from',
  17. path='Clone into',
  18. dataset='Register in superdataset',
  19. ),
  20. parameter_order=dict(
  21. source=0,
  22. path=1,
  23. dataset=2,
  24. ),
  25. ),
  26. create=dict(
  27. name='C&reate a dataset',
  28. exclude_parameters=set((
  29. 'initopts',
  30. 'description',
  31. 'fake_dates',
  32. )),
  33. parameter_display_names=dict(
  34. force='OK if target directory not empty',
  35. path='Create at',
  36. dataset='Register in superdataset',
  37. ),
  38. parameter_order=dict(
  39. path=0,
  40. annex=1,
  41. dataset=2,
  42. ),
  43. ),
  44. create_sibling_gitlab=dict(
  45. name='Create a Git&Lab sibling',
  46. exclude_parameters=set((
  47. 'dryrun',
  48. )),
  49. ),
  50. create_sibling_gin=dict(
  51. name='Create a GI&N sibling',
  52. ),
  53. create_sibling_github=dict(
  54. name='Create a Git&Hub sibling',
  55. exclude_parameters=set((
  56. 'dryrun',
  57. )),
  58. ),
  59. create_sibling_webdav=dict(
  60. name='Create a &WebDAV sibling',
  61. ),
  62. drop=dict(
  63. name='Dr&op dataset content',
  64. exclude_parameters=set((
  65. 'check',
  66. 'if_dirty',
  67. 'reckless',
  68. )),
  69. ),
  70. get=dict(
  71. name='&Get dataset content',
  72. exclude_parameters=set((
  73. 'description',
  74. 'reckless',
  75. )),
  76. ),
  77. push=dict(
  78. name='&Push data/updates to a sibling',
  79. exclude_parameters=set((
  80. 'since',
  81. )),
  82. parameter_constraints=dict(
  83. to=EnsureDatasetSiblingName(),
  84. ),
  85. ),
  86. save=dict(
  87. name='&Save the state in a dataset',
  88. exclude_parameters=set((
  89. 'updated',
  90. 'message_file',
  91. )),
  92. parameter_display_names=dict(
  93. dataset='Save changes in dataset at',
  94. message='Description of change',
  95. path='Only save',
  96. recursive='Include changes in subdatasets',
  97. to_git='Do not put files in annex',
  98. version_tag='Tag for saved dataset state',
  99. amend='Amend last saved state',
  100. ),
  101. parameter_order=dict(
  102. dataset=0,
  103. message=1,
  104. path=2,
  105. recursive=3,
  106. to_git=4,
  107. version_tag=5,
  108. amend=6,
  109. ),
  110. ),
  111. update=dict(
  112. name='&Update from a sibling',
  113. exclude_parameters=set((
  114. 'merge',
  115. 'fetch_all',
  116. 'how_subds',
  117. 'follow',
  118. 'reobtain_data',
  119. )),
  120. parameter_constraints=dict(
  121. sibling=EnsureDatasetSiblingName(),
  122. ),
  123. ),
  124. )
  125. exclude_parameters = set((
  126. 'result_renderer',
  127. 'return_type',
  128. 'result_filter',
  129. 'result_xfm',
  130. 'on_failure',
  131. 'jobs',
  132. 'recursion_limit',
  133. ))
  134. parameter_display_names = dict(
  135. annex='Dataset with file annex',
  136. cfg_proc='Configuration procedure(s)',
  137. dataset='Dataset location',
  138. )
  139. dataset_api = {
  140. c: s for c, s in api.items()
  141. if c in (
  142. 'clone', 'create', 'create_sibling_gitlab', 'create_sibling_gin',
  143. 'create_sibling_github', 'drop', 'get', 'push', 'save', 'update'
  144. )
  145. }
  146. directory_api = {
  147. c: s for c, s in api.items() if c in ('clone', 'create')
  148. }
  149. directory_in_ds_api = {
  150. c: s for c, s in api.items()
  151. if c in ('clone', 'create', 'drop', 'get', 'push', 'save')
  152. }
  153. file_api = None
  154. file_in_ds_api = {
  155. c: s for c, s in api.items() if c in ('save', 'get', 'drop')
  156. }
  157. annexed_file_api = {
  158. c: s for c, s in api.items()
  159. if c in ('drop', 'get', 'push', 'save')
  160. }
  161. # simplified API has no groups
  162. api_group_order = {}