Beispiel #1
0
	def mint(self, quantity = 1):
		ark_list = []
		for x in quantity
		    key = arkpy.mint(authority = setting.NAAN, prefix = self.prefix, template = seif.template)
		    while _ark_exists(key):
		       key = arkpy.mint()
		    ark = Ark.object.create(key = key, minter = self)
		    ark.save()
		    ark_list.append(ark)
		 if quantity = 1
		    return ark_list[0]
Beispiel #2
0
 def generate(self):
     pid = arkpy.mint(authority=str(self.naan), prefix=self.prefix,
         template=self.template)
     pid = pid.split('/')[1]
     if self._pid_exists(pid):
         return self.generate()
     return pid
Beispiel #3
0
 def mint(self, quantity):
     authority = settings.NAAN
     template = self.template
     prefix = self.prefix
     for item in range(quantity):
         ark = Ark()
         while True:
             if prefix == None:
                 offset = 6
                 tryark = arkpy.mint(authority, template, prefix)[offset:]
             else:
                 offset = 6 + len(prefix)
                 tryark = arkpy.mint(authority, template, prefix)[offset:]
             if self._ark_exists(tryark):
                 pass
             else:
                 ark.url = tryark
                 ark.key = tryark
                 ark.minter = self
                 break
         ark.save()
Beispiel #4
0
 def mint(self, qty):
     arks = []
     i = 0
     while i < qty:
         key = arkpy.mint(authority=settings.NAAN,
                          prefix=self.prefix,
                          template=self.template)
         if self._ark_exists(key):
             continue
         else:
             ark = Ark.objects.create(key=key, minter=self)
             arks.append(ark)
             i += 1
     if qty == 1:
         return arks[0]
     else:
         return arks
Beispiel #5
0
 def mint(self, quantity=1):
     x = 0
     arks = []
     while x < quantity:
         ark = arkpy.mint(authority=settings.NAAN,
                          template=self.template,
                          prefix=self.prefix)
         if self._ark_exists(ark) == False:
             object = Ark.objects.create(key=ark, minter=self)
             object.bind(staticurl)
             arks.append(ark)
             x += 1
         else:
             continue
     if quantity == 1:
         return arks[0]
     else:
         return arks
Beispiel #6
0
 def test_bare(self):
     ark = arkpy.mint(authority='66666', template='eeddk')
     ark2 = arkpy.mint(authority='66666', template='dedededk', bare=False)
     self.assertFalse(ark.startswith('ark:/'))
     self.assertTrue(ark2.startswith('ark:/'))
Beispiel #7
0
 def test_length(self):
     ark = arkpy.mint(authority='66666', template='eeddk')
     # 11 = 5 (from '66666' authority)
     #    + 1 (from '/')
     #    + 5 (from 'eedd' template)
     self.assertEqual(len(ark), 11)
Beispiel #8
0
def mint(authority, template):
    return arkpy.mint(authority=authority, template=template)
Beispiel #9
0
 def mint(self):
     return arkpy.mint(authority=NAME_AUTHORITY,
                       template=TEMPLATE,
                       bare=False)
Beispiel #10
0
def mint():
    ark = arkpy.mint(authority='42409', template='eeddeeddk')
    return ark
Beispiel #11
0
 def test_template_xdigits(self):
     ark = arkpy.mint(authority='66666', template='eeeeeeeee')
     parts = ark.split('/')
     identifier = parts[1]
     for char in identifier:
         self.assertTrue(char in arkpy.xdigits)
Beispiel #12
0
 def test_validate_bare_and_nonbare(self):
     ark = arkpy.mint(authority='66666', template='ddeeddeek', bare=False)
     ark2 = arkpy.mint(authority='66666', template='ddeeddeek', bare=True)
     self.assertTrue(arkpy.validate(ark))
     self.assertTrue(arkpy.validate(ark2))
Beispiel #13
0
 def _generate_id(self):
     # Currently only generates ARKs
     if self.minter_type == 'a':
         return arkpy.mint(authority=self.authority_number, prefix=self.prefix, template=self.template)
Beispiel #14
0
 def test_prefix(self):
     ark = arkpy.mint(authority='66666', template='eeddk', prefix='dc')
     parts = ark.split('/')
     identifier = parts[1]
     self.assertTrue(identifier.startswith('dc'))
Beispiel #15
0
 def test_length(self):
     ark = arkpy.mint(authority='66666', template='eeddk')
     # 11 = 5 (from '66666' authority)
     #    + 1 (from '/')
     #    + 5 (from 'eedd' template)
     self.assertEqual(len(ark), 11)
Beispiel #16
0
 def test_validate_bare_and_nonbare(self):
     ark = arkpy.mint(authority='66666', template='ddeeddeek', bare=False)
     ark2 = arkpy.mint(authority='66666', template='ddeeddeek', bare=True)
     self.assertTrue(arkpy.validate(ark))
     self.assertTrue(arkpy.validate(ark2))
Beispiel #17
0
 def test_template_xdigits(self):
     ark = arkpy.mint(authority='66666', template='eeeeeeeee')
     parts = ark.split('/')
     identifier = parts[1]
     for char in identifier:
         self.assertTrue(char in arkpy.xdigits)
Beispiel #18
0
 def test_prefix(self):
     ark = arkpy.mint(authority='66666', template='eeddk', prefix='dc')
     parts = ark.split('/')
     identifier = parts[1]
     self.assertTrue(identifier.startswith('dc'))
Beispiel #19
0
 def test_bare(self):
     ark = arkpy.mint(authority='66666', template='eeddk')
     ark2 = arkpy.mint(authority='66666', template='dedededk', bare=False)
     self.assertFalse(ark.startswith('ark:/'))
     self.assertTrue(ark2.startswith('ark:/'))