Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/bagit-1.7.0.dist-info/METADATA @ 0:d30785e31577 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:18:57 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d30785e31577 |
---|---|
1 Metadata-Version: 2.1 | |
2 Name: bagit | |
3 Version: 1.7.0 | |
4 Summary: Create and validate BagIt packages | |
5 Home-page: https://libraryofcongress.github.io/bagit-python/ | |
6 Author: Ed Summers | |
7 Author-email: ehs@pobox.com | |
8 License: UNKNOWN | |
9 Platform: POSIX | |
10 Classifier: License :: Public Domain | |
11 Classifier: Intended Audience :: Developers | |
12 Classifier: Topic :: Communications :: File Sharing | |
13 Classifier: Topic :: Software Development :: Libraries :: Python Modules | |
14 Classifier: Topic :: System :: Filesystems | |
15 Classifier: Programming Language :: Python :: 2.7 | |
16 Classifier: Programming Language :: Python :: 3.1 | |
17 Classifier: Programming Language :: Python :: 3.2 | |
18 Classifier: Programming Language :: Python :: 3.3 | |
19 Classifier: Programming Language :: Python :: 3.4 | |
20 Classifier: Programming Language :: Python :: 3.5 | |
21 Classifier: Programming Language :: Python :: 3.6 | |
22 | |
23 bagit-python | |
24 ============ | |
25 | |
26 |Build Status| |Coverage Status| | |
27 | |
28 bagit is a Python library and command line utility for working with | |
29 `BagIt <http://purl.org/net/bagit>`__ style packages. | |
30 | |
31 Installation | |
32 ------------ | |
33 | |
34 bagit.py is a single-file python module that you can drop into your | |
35 project as needed or you can install globally with: | |
36 | |
37 :: | |
38 | |
39 pip install bagit | |
40 | |
41 Python v2.7+ is required. | |
42 | |
43 Command Line Usage | |
44 ------------------ | |
45 | |
46 When you install bagit you should get a command-line program called | |
47 bagit.py which you can use to turn an existing directory into a bag: | |
48 | |
49 :: | |
50 | |
51 bagit.py --contact-name 'John Kunze' /directory/to/bag | |
52 | |
53 Finding Bagit on your system | |
54 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
55 | |
56 The ``bagit.py`` program should be available in your normal command-line | |
57 window (Terminal on OS X, Command Prompt or Powershell on Windows, | |
58 etc.). If you are unsure where it was installed you can also request | |
59 that Python search for ``bagit`` as a Python module: simply replace | |
60 ``bagit.py`` with ``python -m bagit``: | |
61 | |
62 :: | |
63 | |
64 python -m bagit --help | |
65 | |
66 On some systems Python may have been installed as ``python3``, ``py``, | |
67 etc. – simply use the same name you use to start an interactive Python | |
68 shell: | |
69 | |
70 :: | |
71 | |
72 py -m bagit --help | |
73 python3 -m bagit --help | |
74 | |
75 Configuring BagIt | |
76 ~~~~~~~~~~~~~~~~~ | |
77 | |
78 You can pass in key/value metadata for the bag using options like | |
79 ``--contact-name`` above, which get persisted to the bag-info.txt. For a | |
80 complete list of bag-info.txt properties you can use as commmand line | |
81 arguments see ``--help``. | |
82 | |
83 Since calculating checksums can take a while when creating a bag, you | |
84 may want to calculate them in parallel if you are on a multicore | |
85 machine. You can do that with the ``--processes`` option: | |
86 | |
87 :: | |
88 | |
89 bagit.py --processes 4 /directory/to/bag | |
90 | |
91 To specify which checksum algorithm(s) to use when generating the | |
92 manifest, use the --md5, --sha1, --sha256 and/or --sha512 flags (MD5 is | |
93 generated by default). | |
94 | |
95 :: | |
96 | |
97 bagit.py --sha1 /path/to/bag | |
98 bagit.py --sha256 /path/to/bag | |
99 bagit.py --sha512 /path/to/bag | |
100 | |
101 If you would like to validate a bag you can use the --validate flag. | |
102 | |
103 :: | |
104 | |
105 bagit.py --validate /path/to/bag | |
106 | |
107 If you would like to take a quick look at the bag to see if it seems | |
108 valid by just examining the structure of the bag, and comparing its | |
109 payload-oxum (byte count and number of files) then use the ``--fast`` | |
110 flag. | |
111 | |
112 :: | |
113 | |
114 bagit.py --validate --fast /path/to/bag | |
115 | |
116 And finally, if you'd like to parallelize validation to take advantage | |
117 of multiple CPUs you can: | |
118 | |
119 :: | |
120 | |
121 bagit.py --validate --processes 4 /path/to/bag | |
122 | |
123 Using BagIt in your programs | |
124 ---------------------------- | |
125 | |
126 You can also use BagIt programatically in your own Python programs by | |
127 importing the ``bagit`` module. | |
128 | |
129 Create | |
130 ~~~~~~ | |
131 | |
132 To create a bag you would do this: | |
133 | |
134 .. code:: python | |
135 | |
136 bag = bagit.make_bag('mydir', {'Contact-Name': 'John Kunze'}) | |
137 | |
138 ``make_bag`` returns a Bag instance. If you have a bag already on disk | |
139 and would like to create a Bag instance for it, simply call the | |
140 constructor directly: | |
141 | |
142 .. code:: python | |
143 | |
144 bag = bagit.Bag('/path/to/bag') | |
145 | |
146 Update Bag Metadata | |
147 ~~~~~~~~~~~~~~~~~~~ | |
148 | |
149 You can change the metadata persisted to the bag-info.txt by using the | |
150 ``info`` property on a ``Bag``. | |
151 | |
152 .. code:: python | |
153 | |
154 # load the bag | |
155 bag = bagit.Bag('/path/to/bag') | |
156 | |
157 # update bag info metadata | |
158 bag.info['Internal-Sender-Description'] = 'Updated on 2014-06-28.' | |
159 bag.info['Authors'] = ['John Kunze', 'Andy Boyko'] | |
160 bag.save() | |
161 | |
162 Update Bag Manifests | |
163 ~~~~~~~~~~~~~~~~~~~~ | |
164 | |
165 By default ``save`` will not update manifests. This guards against a | |
166 situation where a call to ``save`` to persist bag metadata accidentally | |
167 regenerates manifests for an invalid bag. If you have modified the | |
168 payload of a bag by adding, modifying or deleting files in the data | |
169 directory, and wish to regenerate the manifests set the ``manifests`` | |
170 parameter to True when calling ``save``. | |
171 | |
172 .. code:: python | |
173 | |
174 | |
175 import shutil, os | |
176 | |
177 # add a file | |
178 shutil.copyfile('newfile', '/path/to/bag/data/newfile') | |
179 | |
180 # remove a file | |
181 os.remove('/path/to/bag/data/file') | |
182 | |
183 # persist changes | |
184 bag.save(manifests=True) | |
185 | |
186 The save method takes an optional processes parameter which will | |
187 determine how many processes are used to regenerate the checksums. This | |
188 can be handy on multicore machines. | |
189 | |
190 Validation | |
191 ~~~~~~~~~~ | |
192 | |
193 If you would like to see if a bag is valid, use its ``is_valid`` method: | |
194 | |
195 .. code:: python | |
196 | |
197 bag = bagit.Bag('/path/to/bag') | |
198 if bag.is_valid(): | |
199 print("yay :)") | |
200 else: | |
201 print("boo :(") | |
202 | |
203 If you'd like to get a detailed list of validation errors, execute the | |
204 ``validate`` method and catch the ``BagValidationError`` exception. If | |
205 the bag's manifest was invalid (and it wasn't caught by the payload | |
206 oxum) the exception's ``details`` property will contain a list of | |
207 ``ManifestError``\ s that you can introspect on. Each ManifestError, | |
208 will be of type ``ChecksumMismatch``, ``FileMissing``, | |
209 ``UnexpectedFile``. | |
210 | |
211 So for example if you want to print out checksums that failed to | |
212 validate you can do this: | |
213 | |
214 .. code:: python | |
215 | |
216 | |
217 bag = bagit.Bag("/path/to/bag") | |
218 | |
219 try: | |
220 bag.validate() | |
221 | |
222 except bagit.BagValidationError as e: | |
223 for d in e.details: | |
224 if isinstance(d, bagit.ChecksumMismatch): | |
225 print("expected %s to have %s checksum of %s but found %s" % | |
226 (d.path, d.algorithm, d.expected, d.found)) | |
227 | |
228 To iterate through a bag's manifest and retrieve checksums for the | |
229 payload files use the bag's entries dictionary: | |
230 | |
231 .. code:: python | |
232 | |
233 bag = bagit.Bag("/path/to/bag") | |
234 | |
235 for path, fixity in bag.entries.items(): | |
236 print("path:%s md5:%s" % (path, fixity["md5"])) | |
237 | |
238 Contributing to bagit-python development | |
239 ---------------------------------------- | |
240 | |
241 :: | |
242 | |
243 % git clone git://github.com/LibraryOfCongress/bagit-python.git | |
244 % cd bagit-python | |
245 # MAKE CHANGES | |
246 % python test.py | |
247 | |
248 Running the tests | |
249 ~~~~~~~~~~~~~~~~~ | |
250 | |
251 You can quickly run the tests by having setuptools install dependencies: | |
252 | |
253 :: | |
254 | |
255 python setup.py test | |
256 | |
257 Once your code is working, you can use | |
258 `Tox <https://tox.readthedocs.io/>`__ to run the tests with every | |
259 supported version of Python which you have installed on the local | |
260 system: | |
261 | |
262 :: | |
263 | |
264 tox | |
265 | |
266 If you have Docker installed, you can run the tests under Linux inside a | |
267 container: | |
268 | |
269 :: | |
270 | |
271 % docker build -t bagit:latest . && docker run -it bagit:latest | |
272 | |
273 Benchmarks | |
274 ---------- | |
275 | |
276 If you'd like to see how increasing parallelization of bag creation on | |
277 your system effects the time to create a bag try using the included | |
278 bench utility: | |
279 | |
280 :: | |
281 | |
282 % ./bench.py | |
283 | |
284 License | |
285 ------- | |
286 | |
287 |cc0| | |
288 | |
289 Note: By contributing to this project, you agree to license your work | |
290 under the same terms as those that govern this project's distribution. | |
291 | |
292 .. |Build Status| image:: https://travis-ci.org/LibraryOfCongress/bagit-python.svg?branch=master | |
293 :target: http://travis-ci.org/LibraryOfCongress/bagit-python | |
294 .. |Coverage Status| image:: https://coveralls.io/repos/github/LibraryOfCongress/bagit-python/badge.svg?branch=master | |
295 :target: https://coveralls.io/github/LibraryOfCongress/bagit-python?branch=master | |
296 .. |cc0| image:: http://i.creativecommons.org/p/zero/1.0/88x31.png | |
297 :target: http://creativecommons.org/publicdomain/zero/1.0/ | |
298 | |
299 |