dtool-tag 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dtool_tag/__init__.py
ADDED
dtool_tag/cli.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""dtool tag CLI commands."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
import dtoolcore
|
|
6
|
+
import click
|
|
7
|
+
|
|
8
|
+
from dtool_cli.cli import base_dataset_uri_argument
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _validate_name(name):
|
|
12
|
+
if not dtoolcore.utils.name_is_valid(name):
|
|
13
|
+
click.secho("Invalid tag '{}'".format(name), fg="red")
|
|
14
|
+
click.secho(
|
|
15
|
+
"Tag must be 80 characters or less",
|
|
16
|
+
)
|
|
17
|
+
click.secho(
|
|
18
|
+
"Tags may only contain the characters: {}".format(
|
|
19
|
+
" ".join(dtoolcore.utils.NAME_VALID_CHARS_LIST)
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
click.secho("Example: first-class")
|
|
23
|
+
sys.exit(400)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@click.group()
|
|
27
|
+
def tag():
|
|
28
|
+
"""Tags provide per dataset metadata."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@tag.command(name="set")
|
|
32
|
+
@base_dataset_uri_argument
|
|
33
|
+
@click.argument("tag")
|
|
34
|
+
def set_tag(dataset_uri, tag):
|
|
35
|
+
"""Add a tag to a dataset."""
|
|
36
|
+
try:
|
|
37
|
+
dataset = dtoolcore.ProtoDataSet.from_uri(
|
|
38
|
+
uri=dataset_uri,
|
|
39
|
+
config_path=dtoolcore.utils.DEFAULT_CONFIG_PATH
|
|
40
|
+
)
|
|
41
|
+
except dtoolcore.DtoolCoreTypeError:
|
|
42
|
+
dataset = dtoolcore.DataSet.from_uri(
|
|
43
|
+
uri=dataset_uri,
|
|
44
|
+
config_path=dtoolcore.utils.DEFAULT_CONFIG_PATH
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
_validate_name(tag)
|
|
48
|
+
|
|
49
|
+
dataset.put_tag(tag)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@tag.command(name="ls")
|
|
53
|
+
@base_dataset_uri_argument
|
|
54
|
+
def list_tags(dataset_uri):
|
|
55
|
+
"""List the dataset tags."""
|
|
56
|
+
try:
|
|
57
|
+
dataset = dtoolcore.ProtoDataSet.from_uri(
|
|
58
|
+
uri=dataset_uri,
|
|
59
|
+
config_path=dtoolcore.utils.DEFAULT_CONFIG_PATH
|
|
60
|
+
)
|
|
61
|
+
except dtoolcore.DtoolCoreTypeError:
|
|
62
|
+
dataset = dtoolcore.DataSet.from_uri(
|
|
63
|
+
uri=dataset_uri,
|
|
64
|
+
config_path=dtoolcore.utils.DEFAULT_CONFIG_PATH
|
|
65
|
+
)
|
|
66
|
+
for tag in sorted(dataset.list_tags()):
|
|
67
|
+
click.secho("{}".format(tag))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@tag.command(name="delete")
|
|
71
|
+
@base_dataset_uri_argument
|
|
72
|
+
@click.argument("tag")
|
|
73
|
+
def delete_tag(dataset_uri, tag):
|
|
74
|
+
"""Delete a dataset tag."""
|
|
75
|
+
try:
|
|
76
|
+
dataset = dtoolcore.ProtoDataSet.from_uri(
|
|
77
|
+
uri=dataset_uri,
|
|
78
|
+
config_path=dtoolcore.utils.DEFAULT_CONFIG_PATH
|
|
79
|
+
)
|
|
80
|
+
except dtoolcore.DtoolCoreTypeError:
|
|
81
|
+
dataset = dtoolcore.DataSet.from_uri(
|
|
82
|
+
uri=dataset_uri,
|
|
83
|
+
config_path=dtoolcore.utils.DEFAULT_CONFIG_PATH
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
dataset.delete_tag(tag)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dtool-tag
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Add ability to tag datasets using the dtool CLI
|
|
5
|
+
Project-URL: Repository, https://github.com/jic-dtool/dtool-tag
|
|
6
|
+
Author-email: Tjelvar Olsson <tjelvar.olsson@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE.rst
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Requires-Dist: click
|
|
11
|
+
Requires-Dist: dtool-cli>=0.7.2
|
|
12
|
+
Requires-Dist: dtoolcore>=3.17.0
|
|
13
|
+
Description-Content-Type: text/x-rst
|
|
14
|
+
|
|
15
|
+
dtool CLI commands for working with tags
|
|
16
|
+
========================================
|
|
17
|
+
|
|
18
|
+
.. image:: https://badge.fury.io/py/dtool-tag.svg
|
|
19
|
+
:target: http://badge.fury.io/py/dtool-tag
|
|
20
|
+
:alt: PyPi package
|
|
21
|
+
|
|
22
|
+
.. image:: https://github.com/jic-dtool/dtool-tag/actions/workflows/test.yml/badge.svg?branch=main
|
|
23
|
+
:target: https://github.com/jic-dtool/dtool-tag/actions/workflows/test.yml
|
|
24
|
+
:alt: Tests
|
|
25
|
+
|
|
26
|
+
.. image:: https://codecov.io/github/jic-dtool/dtool-tag/coverage.svg?branch=main
|
|
27
|
+
:target: https://codecov.io/github/jic-dtool/dtool-tag?branch=main
|
|
28
|
+
:alt: Code Coverage
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Installation
|
|
32
|
+
------------
|
|
33
|
+
|
|
34
|
+
::
|
|
35
|
+
|
|
36
|
+
$ pip install dtool-tag
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
Example usage
|
|
40
|
+
-------------
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Get a dataset to play with::
|
|
44
|
+
|
|
45
|
+
$ LOCAL_DS_URI=$(dtool cp -q http://bit.ly/Ecoli-ref-genome .)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
Add a couple of tags::
|
|
49
|
+
|
|
50
|
+
$ dtool tag set $LOCAL_DS_URI e.coli
|
|
51
|
+
$ dtool tag set $LOCAL_DS_URI genome
|
|
52
|
+
|
|
53
|
+
List the dataset tags::
|
|
54
|
+
|
|
55
|
+
$ dtool tag ls $LOCAL_DS_URI
|
|
56
|
+
e.coli
|
|
57
|
+
genome
|
|
58
|
+
|
|
59
|
+
Delete a tag::
|
|
60
|
+
|
|
61
|
+
$ dtool tag delete $LOCAL_DS_URI genome
|
|
62
|
+
|
|
63
|
+
For more information see the `dtool documentation <https://dtool.readthedocs.io>`_.
|
|
64
|
+
|
|
65
|
+
Related packages
|
|
66
|
+
----------------
|
|
67
|
+
|
|
68
|
+
- `dtoolcore <https://github.com/jic-dtool/dtoolcore>`_
|
|
69
|
+
- `dtool-cli <https://github.com/jic-dtool/dtool-cli>`_
|
|
70
|
+
- `dtool-create <https://github.com/jic-dtool/dtool-create>`_
|
|
71
|
+
- `dtool-overlay <https://github.com/jic-dtool/dtool-overlay>`_
|
|
72
|
+
- `dtool-annotation <https://github.com/jic-dtool/dtool-annotation>`_
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
dtool_tag/__init__.py,sha256=T8FaQf_Bq3Qj-K6utc66fb355vWKLBkRNo7a6Of_5qU,221
|
|
2
|
+
dtool_tag/cli.py,sha256=Mj5dp6y4NqbT-2XQEDcF6bJ6vK1XdLI7kMm4hH-M4Dw,2256
|
|
3
|
+
dtool_tag-0.1.2.dist-info/METADATA,sha256=kwEsObkpGGMGUbRAA_TgHGpr2TfaO5vh-_UAgAC-ApU,1869
|
|
4
|
+
dtool_tag-0.1.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
5
|
+
dtool_tag-0.1.2.dist-info/entry_points.txt,sha256=BnkL48fODelodaCePOlsCWqMX16iTauNteTyCmfauxQ,36
|
|
6
|
+
dtool_tag-0.1.2.dist-info/licenses/LICENSE.rst,sha256=3wTaQ15u0aBGHi11jgv7TVKeFDmJBRUWd53t79rsUhs,1083
|
|
7
|
+
dtool_tag-0.1.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2019 Tjelvar Olsson
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|