disdat 1.1.5__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.
disdat/__init__.py ADDED
@@ -0,0 +1,21 @@
1
+ #
2
+ # Copyright 2015, 2016 Human Longevity, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from disdat.log import logger
17
+
18
+ try:
19
+ from disdat.version import __version__
20
+ except ImportError: # pragma: no cover
21
+ __version__ = "dev"
disdat/add.py ADDED
@@ -0,0 +1,77 @@
1
+ #
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ #
14
+
15
+ from __future__ import print_function
16
+
17
+ import disdat.api as api
18
+ import disdat.common as common
19
+ import disdat.fs
20
+ from disdat import logger as _logger
21
+
22
+
23
+ def _add(args):
24
+ """Invoke the api.add() call from the CLI to create a bundle.
25
+
26
+ Args:
27
+ args: command line args.
28
+
29
+ Returns:
30
+ None
31
+
32
+ """
33
+
34
+ fs = disdat.fs.DisdatFS()
35
+
36
+ if not fs.in_context():
37
+ _logger.warning("Not in a data context")
38
+ return
39
+
40
+ _ = api.add(
41
+ fs._curr_context.get_local_name(),
42
+ args.bundle,
43
+ args.path_name,
44
+ tags=common.parse_args_tags(args.tag),
45
+ )
46
+
47
+ return
48
+
49
+
50
+ def add_arg_parser(subparsers):
51
+ """Initialize a command line set of subparsers with the add command.
52
+
53
+ Args:
54
+ subparsers: A collection of subparsers as defined by `argsparse`.
55
+ """
56
+ # add
57
+ add_p = subparsers.add_parser(
58
+ "add", description="Create a bundle from a .csv, .tsv, or a directory of files."
59
+ )
60
+ add_p.add_argument(
61
+ "-t",
62
+ "--tag",
63
+ nargs=1,
64
+ type=str,
65
+ action="append",
66
+ help="Set one or more tags: 'dsdt add -t authoritative:True -t version:0.7.1'",
67
+ )
68
+ add_p.add_argument(
69
+ "bundle", type=str, help="The destination bundle in the current context"
70
+ )
71
+ add_p.add_argument(
72
+ "path_name",
73
+ type=str,
74
+ help="File or directory of files to add to the bundle",
75
+ action="store",
76
+ )
77
+ add_p.set_defaults(func=lambda args: _add(args))