Esempio n. 1
0
    def checkBarcode(self, event):
        import Util.Barcode as Barcode
        bc = self.text_ctrl_barcode.GetValue()
        if not Barcode.validateBarcode(bc):
            wx.MessageDialog(self, "That barcode is wrong!", "Barcode Error", wx.OK | wx.ICON_HAND).ShowModal()
        else:
            if bc[0] == "0" or len(bc) == 12:
                self.choice_country.SetSelection(1)
            else:
                self.choice_country.SetSelection(0)

            res = getAmazonInfoByUPC(bc)
            if res:
                self.amazonStore = res[0]
                self.amazonASIN = res[1]
                self._setInfoLabel(self.button_amazon, "%s (%s)" % (res[1], res[0]))
                self.coverjpg = res[2]
            else:
                self._setInfoLabel(self.button_amazon, "not found")
Esempio n. 2
0
    def checkBarcode(self, event):
        import Util.Barcode as Barcode
        bc = self.text_ctrl_barcode.GetValue()
        if not Barcode.validateBarcode(bc):
            wx.MessageDialog(self, "That barcode is wrong!", "Barcode Error",
                             wx.OK | wx.ICON_HAND).ShowModal()
        else:
            if bc[0] == "0" or len(bc) == 12:
                self.choice_country.SetSelection(1)
            else:
                self.choice_country.SetSelection(0)

            res = getAmazonInfoByUPC(bc)
            if res:
                self.amazonStore = res[0]
                self.amazonASIN = res[1]
                self._setInfoLabel(self.button_amazon,
                                   "%s (%s)" % (res[1], res[0]))
                self.coverjpg = res[2]
            else:
                self._setInfoLabel(self.button_amazon, "not found")
Esempio n. 3
0
 def testNonNumeric(self):
     for bc in ("0000000000X", "Barcode123456"):
         result = Barcode.validateBarcode(bc)
         self.assertFalse(result)
Esempio n. 4
0
 def testTooLong(self):
     for i in range(14, 20):
         bc = "0" * i
         result = Barcode.validateBarcode(bc)
         self.assertFalse(result)
Esempio n. 5
0
 def testTooShort(self):
     for i in range(0, 11):
         bc = "0" * i
         result = Barcode.validateBarcode(bc)
         self.assertFalse(result)
Esempio n. 6
0
 def testKnownValues(self):
     for bc, expectedResult in self.knownValues:
         print bc
         result = Barcode.validateBarcode(bc)
         self.assertEqual(result, expectedResult)
Esempio n. 7
0
 def testNonNumeric(self):
     for bc in ("0000000000X", "Barcode123456"):
         result = Barcode.validateBarcode(bc)
         self.assertFalse(result)        
Esempio n. 8
0
 def testTooLong(self):
     for i in range(14,20):
         bc = "0" * i
         result = Barcode.validateBarcode(bc)
         self.assertFalse(result)
Esempio n. 9
0
 def testTooShort(self):
     for i in range(0,11):
         bc = "0" * i
         result = Barcode.validateBarcode(bc)
         self.assertFalse(result)
Esempio n. 10
0
 def testKnownValues(self):
     for bc, expectedResult in self.knownValues:
         print bc
         result = Barcode.validateBarcode(bc)
         self.assertEqual(result, expectedResult)