Advertisement
Joze

UPC & ISRC en Python

May 5th, 2012
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def newUPC():
  2.     #... sacamos el último de la BD
  3.     oldValue += 1
  4.     st = UPC_RAIZ + "%04d" % (oldValue,)   
  5.     dc = -(int(st[0]) + 3*int(st[1]) + int(st[2]) + 3*int(st[3]) + int(st[4]) + 3*int(st[5]) + int(st[6]) + 3*int(st[7]) + int(st[8]) + 3*int(st[9]) + int(st[10]) + 3*int(st[11])) % 10
  6.      
  7.     return  st + str(dc)
  8.    
  9.    
  10. def newISRC(twoDigitsYear):
  11.  
  12.     #... sacamos el último de la BD
  13.     oldValue += 1
  14.    
  15.     st = str(ISRC_RAIZ) + "%02d-" % (twoDigitsYear,)
  16.     return st + "%05d" % (oldValue,)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement