generated from datalad/datalad-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from datalad/move-procedure
Add deprecated metadata config procedure from datalad core
- Loading branch information
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from datalad.conftest import setup_package, capture_logs | ||
from datalad.conftest import * |
38 changes: 38 additions & 0 deletions
38
datalad_deprecated/resources/procedures/cfg_metadatatypes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
"""Procedure to configure additional metadata types | ||
Additional arguments: <metadata type label> [...] | ||
""" | ||
|
||
import sys | ||
import os.path as op | ||
|
||
from datalad.consts import ( | ||
DATASET_CONFIG_FILE | ||
) | ||
from datalad.utils import ensure_tuple_or_list | ||
from datalad.distribution.dataset import require_dataset | ||
|
||
ds = require_dataset( | ||
sys.argv[1], | ||
check_installed=True, | ||
purpose='configuration') | ||
|
||
existing_types = ensure_tuple_or_list( | ||
ds.config.get('datalad.metadata.nativetype', [], get_all=True)) | ||
|
||
for nt in sys.argv[2:]: | ||
if nt in existing_types: | ||
# do not duplicate | ||
continue | ||
ds.config.add( | ||
'datalad.metadata.nativetype', | ||
nt, | ||
scope='branch', | ||
reload=False) | ||
|
||
ds.save( | ||
path=op.join(ds.path, DATASET_CONFIG_FILE), | ||
message="Configure metadata type(s)", | ||
result_renderer='disabled' | ||
) |