Skip to content

Commit 7684c79

Browse files
Merge pull request #72 from Hwesta/agent-includes-version
Include bagit version in Bag-Software-Agent
2 parents 5489148 + aefe9ba commit 7684c79

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

bagit.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
LOGGER = logging.getLogger(__name__)
4949

50+
VERSION = '1.5.4'
51+
5052
# standard bag-info.txt metadata
5153
STANDARD_BAG_INFO_HEADERS = [
5254
'Source-Organization',
@@ -141,7 +143,7 @@ def make_bag(bag_dir, bag_info=None, processes=1, checksum=None):
141143
if 'Bagging-Date' not in bag_info:
142144
bag_info['Bagging-Date'] = date.strftime(date.today(), "%Y-%m-%d")
143145
if 'Bag-Software-Agent' not in bag_info:
144-
bag_info['Bag-Software-Agent'] = 'bagit.py <http://github.com/libraryofcongress/bagit-python>'
146+
bag_info['Bag-Software-Agent'] = 'bagit.py v' + VERSION + ' <http://github.com/libraryofcongress/bagit-python>'
145147
bag_info['Payload-Oxum'] = Oxum
146148
_make_tag_file('bag-info.txt', bag_info)
147149

setup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from setuptools import setup
44

5+
import bagit
6+
57
if version < '2.6.0':
68
print("python 2.6 or higher is required")
79
exit(1)
@@ -24,10 +26,11 @@
2426
except:
2527
requirements.append("hashlib")
2628

29+
version = bagit.VERSION
2730

2831
setup(
2932
name = 'bagit',
30-
version = '1.5.4',
33+
version = version,
3134
url = 'https://libraryofcongress.github.io/bagit-python/',
3235
author = 'Ed Summers',
3336
author_email = '[email protected]',

test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def test_sha1_tagfile(self):
303303
info = {'Bagging-Date': '1970-01-01', 'Contact-Email': '[email protected]'}
304304
bag = bagit.make_bag(self.tmpdir, checksum=['sha1'], bag_info=info)
305305
self.assertTrue(os.path.isfile(j(self.tmpdir, 'tagmanifest-sha1.txt')))
306-
self.assertEqual(bag.entries['bag-info.txt']['sha1'], 'd7f086508df433e5d7464b5a3835d5501df14404')
306+
self.assertEqual(bag.entries['bag-info.txt']['sha1'], 'ec70407d895d4e550bc0a7ea40a82ad653d136e5')
307307

308308
def test_validate_unreadable_file(self):
309309
bag = bagit.make_bag(self.tmpdir, checksum=["md5"])
@@ -360,15 +360,15 @@ def test_make_bag(self):
360360
self.assertTrue('Contact-Email: [email protected]' in bag_info_txt)
361361
self.assertTrue('Bagging-Date: 1970-01-01' in bag_info_txt)
362362
self.assertTrue('Payload-Oxum: 991765.5' in bag_info_txt)
363-
self.assertTrue('Bag-Software-Agent: bagit.py <http://github.com/libraryofcongress/bagit-python>' in bag_info_txt)
363+
self.assertTrue('Bag-Software-Agent: bagit.py v1.5.4 <http://github.com/libraryofcongress/bagit-python>' in bag_info_txt)
364364

365365
# check tagmanifest-md5.txt
366366
self.assertTrue(os.path.isfile(j(self.tmpdir, 'tagmanifest-md5.txt')))
367367
with open(j(self.tmpdir, 'tagmanifest-md5.txt')) as tm:
368368
tagmanifest_txt = tm.read()
369369
self.assertTrue('9e5ad981e0d29adc278f6a294b8c2aca bagit.txt' in tagmanifest_txt)
370370
self.assertTrue('a0ce6631a2a6d1a88e6d38453ccc72a5 manifest-md5.txt' in tagmanifest_txt)
371-
self.assertTrue('6a5090e27cb29d5dda8a0142fbbdf37e bag-info.txt' in tagmanifest_txt)
371+
self.assertTrue('bfe59ad8af1a227d27c191b4178c399f bag-info.txt' in tagmanifest_txt)
372372

373373
def test_make_bag_sha1_manifest(self):
374374
bagit.make_bag(self.tmpdir, checksum=['sha1'])

0 commit comments

Comments
 (0)