def test_protobarcode_model_insert(self): """We should be able to insert ProtoBarcode records""" for i in self.samplebarcodes: if i['barcode']: bc = ProtoBarcode(**i) try: bc.save() except IntegrityError, e: if e.message.endswith(u'not unique'): pass else: print "Problem with barcode %s" % (i['barcode'],) print "Error: %s" % (e,)
def do_barcodes(barcodefiles): """Load data from one or more barcode files""" for b in barcodefiles: barcodefile = DictReader(open(b)) for row in barcodefile: barcode = ProtoBarcode(**row) try: barcode.barcode += calc_checkdigit(barcode.barcode) except ValueError: log.warn('File: %s Value: %s Invalid barcode' % (b, barcode.barcode)) continue try: barcode.full_clean() barcode.save() except ValidationError, e: for key in e.message_dict: log.debug("File: %s Value: %s" % (b, barcode.barcode,)) log.debug("%s: %s" % (key, e.message_dict[key],)) continue
def do_barcodes(barcodefiles): """Load data from one or more barcode files""" for b in barcodefiles: barcodefile = DictReader(open(b)) for row in barcodefile: barcode = ProtoBarcode(**row) try: barcode.barcode += calc_checkdigit(barcode.barcode) except ValueError: log.warn('File: %s Value: %s Invalid barcode' % (b, barcode.barcode)) continue try: barcode.full_clean() barcode.save() except ValidationError, e: for key in e.message_dict: log.debug("File: %s Value: %s" % ( b, barcode.barcode, )) log.debug("%s: %s" % ( key, e.message_dict[key], )) continue