Ejemplo n.º 1
0
 def test_mint_ns(self):
     ns = range(10)
     for n in ns:
         self.assertEqual(pynoid.mint('d', n), pynoid.DIGIT[n])
     ns = range(29)
     for n in ns:
         self.assertEqual(pynoid.mint('e', n), pynoid.XDIGIT[n])
Ejemplo n.º 2
0
 def test_mint_ns(self):
     ns = range(10)
     for n in ns:
         self.assertEqual(pynoid.mint('d', n), pynoid.DIGIT[n])
     ns = range(29)
     for n in ns:
         self.assertEqual(pynoid.mint('e', n), pynoid.XDIGIT[n])
Ejemplo n.º 3
0
 def _seededmint(self, mask, n):
     out = noid.mint(self._seededmask, n)
     if self.issued(out):
         log.debug("apparent EDI-ARK id collision: %s", out)
         self._collision_count += 1
         mask = out[:-1] + "0.zek"
         while self.issued(out):
             out = noid.mint(mask, self._annotn)
             self._annotn += 1
     return out
def new(request, ref=None):
    uriNeeded = True
    while uriNeeded == True:
        # assign an identifier
        identifier = pynoid.mint('zeek', random.randint(0, 100000))
        uri = Namespace("http://data.library.oregonstate.edu/person/")[identifier]
        uriNeeded = queryManager.ask(uri) # if this identifier is already in use, let's get another one
    forms = buildForm()
       
    return render_to_response("resource.tpl", {'uri': str(uri), 'short': uri.split('/')[-1], 'res': {}, 'form': forms['form'], 'variants': forms['variants']})
Ejemplo n.º 5
0
    def mint(self, data=None):
        """
        return an available identifier string.  
     
        Whether the data parameter is supported depends on the support 
        provided by the IDRegistry instance provided at construction.  
        The default registry (used if no registry was provided) does not 
        support the data parameter; if provided, it will be ignored.  

        :param data dict:  any data to associate with the identifier.  (See
                           note above about its support.)
        """
        out = noid.mint(self.mask, self.nextn)
        self.nextn += 1
        while self.issued(out):
            out = noid.mint(self.mask, self.nextn)
            self.nextn += 1
        self.registry.registerID(out, data)
        return out
Ejemplo n.º 6
0
 def test_masks(self):
     for mask in "dddd eeee eded".split():
         mask = "mc5."+mask
         self.minter = minter.NoidMinter(mask)
         for i in range(5, 6000, 5):
             id = noid.mint(mask, i)
             self.minter.nextn = i
             self.assertFalse(self.minter.issued(id),
               "id {0} prematurely issued for mask={1}".format(repr(id),
                                                               repr(mask)))
             mid = self.minter.mint()
             self.assertEqual(mid, id,
                               "{0} != {1} for mask={2}".format(repr(mid),
                                                                repr(id),
                                                                repr(mask)))
             self.assertTrue(self.minter.issued(id), 
                "id {0} forgotten for mask={1}".format(repr(id), repr(mask)))
Ejemplo n.º 7
0
    def test_seqFor(self):
        mask = "ede"
        reg = minter.NoidMinter.seqreg(0, "ede")

        self.assertEqual(reg.seqFor("000"), 0)
        self.assertEqual(reg.seqFor("001"), 1)
        self.assertEqual(reg.seqFor("008"), 8)
        self.assertEqual(reg.seqFor("00b"), 10)
        self.assertEqual(reg.seqFor("01f"), 42)
        self.assertEqual(reg.seqFor("10z"), 318)
        self.assertEqual(reg.seqFor("34g"), 1000)
        self.assertEqual(reg.seqFor("m79"), 5432)

        for mask in "dddd eeee eded".split():
            reg = minter.NoidMinter.seqreg(0, mask)
            for i in range(5, 6000, 5):
                n = reg.seqFor(noid.mint(mask, i))
                self.assertEqual(n, i,
                             "{0} != {1} for mask={2}".format(n, i, repr(mask)))
Ejemplo n.º 8
0
 def test_checkdigit(self):
     self.assertEqual(pynoid.mint('eek', 100), '3f0')
     self.assertRaises(pynoid.ValidationError, pynoid.validate, 'f30')
Ejemplo n.º 9
0
 def test_checkdigit(self):
     self.assertEqual(pynoid.mint('eek', 100), '3f0')
     self.assertRaises(pynoid.ValidationError, pynoid.validate, 'f30')
Ejemplo n.º 10
0
 def test_mint_z_rollover(self):
     self.assertEqual(pynoid.mint('zd', 10), '10')        
     self.assertEqual(pynoid.mint('ze', 29), '10')
Ejemplo n.º 11
0
 def test_mint_short_term(self):
     noid = pynoid.mint()
     self.assertTrue(noid.startswith(pynoid.SHORT))
Ejemplo n.º 12
0
 def test_scheme_append(self):
     schemes = ['doi:', 'ark:/', 'http://']
     for scheme in schemes:
         noid = pynoid.mint(scheme=scheme)
         self.assertTrue(noid.startswith(scheme))
Ejemplo n.º 13
0
 def test_naa_append(self):
     noid = pynoid.mint(naa='abc')
     self.assertTrue(noid.startswith('abc/'))
Ejemplo n.º 14
0
 def test_mint_z_rollover(self):
     self.assertEqual(pynoid.mint('zd', 10), '10')
     self.assertEqual(pynoid.mint('ze', 29), '10')
Ejemplo n.º 15
0
 def test_naa_append(self):
     noid = pynoid.mint(naa='abc')
     self.assertTrue(noid.startswith('abc/'))
Ejemplo n.º 16
0
 def test_mint_short_term(self):
     noid = pynoid.mint()
     self.assertTrue(noid.startswith(pynoid.SHORT))
Ejemplo n.º 17
0
 def test_scheme_append(self):
     schemes = ['doi:', 'ark:/', 'http://']
     for scheme in schemes:
         noid = pynoid.mint(scheme=scheme)
         self.assertTrue(noid.startswith(scheme))