123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- from .constraints import (
- EnsureDatasetSiblingName,
- EnsureExistingDirectory,
- )
- # each item is a command that is allowed in the API
- # the key is the command name in the Python API.
- # the values are dicts with the following keys
- # - exclude_parameters: set with parameter names to
- # exclude from the API
- api = dict(
- clone=dict(
- name='&Clone a dataset',
- exclude_parameters=set((
- 'git_clone_opts',
- 'reckless',
- 'description',
- )),
- parameter_display_names=dict(
- source='Clone from',
- path='Clone into',
- dataset='Register in superdataset',
- ),
- parameter_order=dict(
- source=0,
- path=1,
- dataset=2,
- ),
- parameter_constraints=dict(
- path=EnsureExistingDirectory(),
- ),
- ),
- create=dict(
- name='C&reate a dataset',
- exclude_parameters=set((
- 'initopts',
- 'description',
- 'fake_dates',
- )),
- parameter_display_names=dict(
- force='OK if target directory not empty',
- path='Create at',
- dataset='Register in superdataset',
- ),
- parameter_order=dict(
- path=0,
- annex=1,
- dataset=2,
- ),
- parameter_constraints=dict(
- path=EnsureExistingDirectory(),
- ),
- ),
- create_sibling_gitlab=dict(
- name='Create a Git&Lab sibling',
- exclude_parameters=set((
- 'dryrun',
- )),
- ),
- create_sibling_gin=dict(
- name='Create a GI&N sibling',
- exclude_parameters=set((
- 'dryrun',
- 'api'
- )),
- parameter_display_names=dict(
- dataset='Dataset',
- reponame='New repository name on Gin',
- name='Sibling name',
- private='Make Gin repo private',
- existing='If the sibling exists already...',
- recursive='Create siblings for subdatasets',
- credential='Name of credential to be used',
- access_protocol='Access protocol',
- publish_depends='Add publication dependency to'
- ),
- parameter_order=dict(
- dataset=0,
- reponame=1,
- private=2,
- name=3,
- access_protocol=4,
- existing=5,
- recursive=6,
- credential=7,
- ),
- ),
- create_sibling_github=dict(
- name='Create a Git&Hub sibling',
- exclude_parameters=set((
- 'dryrun',
- 'github_login',
- 'github_organization',
- 'api'
- )),
- parameter_display_names=dict(
- dataset='Dataset',
- reponame='New repository name on Github',
- name='Sibling name',
- private='Make GitHub repo private',
- existing='If the sibling exists already...',
- recursive='Create siblings for subdatasets',
- credential='Name of credential to be used',
- access_protocol='Access protocol',
- publish_depends='Add publication dependency to'
- ),
- parameter_order=dict(
- dataset=0,
- reponame=1,
- private=2,
- name=3,
- access_protocol=4,
- existing=5,
- recursive=6,
- credential=7,
- ),
- ),
- create_sibling_webdav=dict(
- name='Create a &WebDAV sibling',
- ),
- drop=dict(
- name='Dr&op content',
- exclude_parameters=set((
- 'check',
- 'if_dirty',
- 'reckless',
- )),
- parameter_order=dict(
- dataset=0,
- what=1,
- path=2,
- recursive=3,
- ),
- ),
- get=dict(
- name='&Get content',
- exclude_parameters=set((
- 'description',
- 'reckless',
- 'source',
- )),
- parameter_display_names=dict(
- path='Only get',
- # 'all' because we have no recursion_limit enabled
- recursive='Also get all subdatasets',
- get_data='Get file content',
- ),
- parameter_order=dict(
- dataset=0,
- get_data=1,
- path=2,
- recursive=3,
- ),
- ),
- push=dict(
- name='&Push data/updates to a sibling',
- exclude_parameters=set((
- 'since',
- )),
- parameter_constraints=dict(
- to=EnsureDatasetSiblingName(),
- ),
- ),
- save=dict(
- name='&Save the state in a dataset',
- exclude_parameters=set((
- 'updated',
- 'message_file',
- )),
- parameter_display_names=dict(
- dataset='Save changes in dataset at',
- message='Description of change',
- path='Only save',
- recursive='Include changes in subdatasets',
- to_git='Do not put files in annex',
- version_tag='Tag for saved dataset state',
- amend='Amend last saved state',
- ),
- parameter_order=dict(
- dataset=0,
- message=1,
- path=2,
- recursive=3,
- to_git=4,
- version_tag=5,
- amend=6,
- ),
- ),
- update=dict(
- name='&Update from a sibling',
- exclude_parameters=set((
- 'merge',
- 'fetch_all',
- 'how_subds',
- 'follow',
- 'reobtain_data',
- )),
- parameter_constraints=dict(
- sibling=EnsureDatasetSiblingName(),
- ),
- ),
- )
- dataset_api = {
- c: s for c, s in api.items()
- if c in (
- 'clone', 'create',
- 'create_sibling_gitlab', 'create_sibling_gin',
- 'create_sibling_github', 'create_sibling_webdav',
- 'drop', 'get', 'push', 'save', 'update'
- )
- }
- directory_api = {
- c: s for c, s in api.items() if c in ('clone', 'create')
- }
- directory_in_ds_api = {
- c: s for c, s in api.items()
- if c in ('clone', 'create', 'drop', 'get', 'push', 'save')
- }
- file_api = None
- file_in_ds_api = {
- c: s for c, s in api.items() if c in ('save')
- }
- annexed_file_api = {
- c: s for c, s in api.items()
- if c in ('drop', 'get', 'push', 'save')
- }
- # get of a single annexed files can be simpler
- from copy import deepcopy
- annexed_file_get = deepcopy(annexed_file_api['get'])
- parameter_constraints=dict(
- path=EnsureExistingDirectory(),
- ),
- annexed_file_get['exclude_parameters'].update((
- # not getting data for an annexed file makes no sense
- 'get_data',
- # recursion underneath a file is not possible
- 'recursive',
- ))
- annexed_file_get['parameter_nargs'] = dict(
- path=1,
- )
- annexed_file_api['get'] = annexed_file_get
- gooey_suite = dict(
- title='Simplified',
- description='Simplified access to the most essential operations',
- options=dict(
- disable_manual_path_input=True,
- ),
- apis=dict(
- dataset=dataset_api,
- directory=directory_api,
- directory_in_ds=directory_in_ds_api,
- file=file_api,
- file_in_ds=file_in_ds_api,
- annexed_file=annexed_file_api,
- ),
- # simplified API has no groups
- api_group_order={},
- exclude_parameters=set((
- 'result_renderer',
- 'return_type',
- 'result_filter',
- 'result_xfm',
- 'on_failure',
- 'jobs',
- 'recursion_limit',
- )),
- parameter_display_names=dict(
- annex='Dataset with file annex',
- cfg_proc='Configuration procedure(s)',
- dataset='Dataset location',
- ),
- )
|