Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski authored Aug 19, 2023
1 parent 4d2fd92 commit 96da12b
Show file tree
Hide file tree
Showing 32 changed files with 974 additions and 974 deletions.
220 changes: 110 additions & 110 deletions upcean/convert/convert.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion upcean/decode/ean13.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import cairo;

def decode_ean13_barcode(infile="./ean13.png",resize=1,barheight=(48, 54),barwidth=(1, 1),shiftcheck=False,shiftxy=(0, 0),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),locatebarcode=False,imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(isinstance(infile, Image.Image)):
upc_img = infile.convert('RGB');
Expand Down
2 changes: 1 addition & 1 deletion upcean/decode/ean8.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import cairo;

def decode_ean8_barcode(infile="./ean8.png",resize=1,barheight=(48, 54),barwidth=(1, 1),shiftcheck=False,shiftxy=(0, 0),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),locatebarcode=False,imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(isinstance(infile, Image.Image)):
upc_img = infile.convert('RGB');
Expand Down
6 changes: 3 additions & 3 deletions upcean/decode/itf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import cairo;

def decode_itf_barcode(infile="./itf.png",resize=1,barheight=(48, 54),barwidth=(1, 1),shiftcheck=False,shiftxy=(0, 0),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),locatebarcode=False,imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(isinstance(infile, Image.Image)):
upc_img = infile.convert('RGB');
Expand Down Expand Up @@ -309,8 +309,8 @@ def decode_itf_barcode(infile="./itf.png",resize=1,barheight=(48, 54),barwidth=(
pre_upc_whole_left = "".join(pre_upc_list_left);
pre_upc_whole_right = "".join(pre_upc_list_right);
upc_img.close();
pre_upc_whole_left_re = re.findall("([0-9]{5})", pre_upc_whole_left);
pre_upc_whole_right_re = re.findall("([0-9]{5})", pre_upc_whole_right);
pre_upc_whole_left_re = re.findall(r"([0-9]{5})", pre_upc_whole_left);
pre_upc_whole_right_re = re.findall(r"([0-9]{5})", pre_upc_whole_right);
countlist = barcodesize;
listcount = 0;
barcode_list = [];
Expand Down
6 changes: 3 additions & 3 deletions upcean/decode/itf14.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import cairo;

def decode_itf14_barcode(infile="./itf14.png",resize=1,barheight=(48, 54),barwidth=(1, 1),shiftcheck=False,shiftxy=(0, 0),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),locatebarcode=False,imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(isinstance(infile, Image.Image)):
upc_img = infile.convert('RGB');
Expand Down Expand Up @@ -309,8 +309,8 @@ def decode_itf14_barcode(infile="./itf14.png",resize=1,barheight=(48, 54),barwid
pre_upc_whole_left = "".join(pre_upc_list_left);
pre_upc_whole_right = "".join(pre_upc_list_right);
upc_img.close();
pre_upc_whole_left_re = re.findall("([0-9]{5})", pre_upc_whole_left);
pre_upc_whole_right_re = re.findall("([0-9]{5})", pre_upc_whole_right);
pre_upc_whole_left_re = re.findall(r"([0-9]{5})", pre_upc_whole_left);
pre_upc_whole_right_re = re.findall(r"([0-9]{5})", pre_upc_whole_right);
countlist = barcodesize;
listcount = 0;
barcode_list = [];
Expand Down
2 changes: 1 addition & 1 deletion upcean/decode/stf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import cairo;

def decode_stf_barcode(infile="./stf.png",resize=1,barheight=(48, 54),barwidth=(1, 1),shiftcheck=False,shiftxy=(0, 0),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),locatebarcode=False,imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(isinstance(infile, Image.Image)):
upc_img = infile.convert('RGB');
Expand Down
2 changes: 1 addition & 1 deletion upcean/decode/upca.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import cairo;

def decode_upca_barcode(infile="./upca.png",resize=1,barheight=(48, 54),barwidth=(1, 1),shiftcheck=False,shiftxy=(0, 0),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),locatebarcode=False,imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(isinstance(infile, Image.Image)):
upc_img = infile.convert('RGB');
Expand Down
2 changes: 1 addition & 1 deletion upcean/decode/upce.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import cairo;

def decode_upce_barcode(infile="./upce.png",resize=1,barheight=(48, 54),barwidth=(1, 1),shiftcheck=False,shiftxy=(0, 0),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),locatebarcode=False,imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(isinstance(infile, Image.Image)):
upc_img = infile.convert('RGB');
Expand Down
14 changes: 7 additions & 7 deletions upcean/encode/codabar.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def create_codabar_barcode(upc,outfile="./codabar.png",resize=1,hideinfo=(False,
return False;
if(barwidth[0] < 1):
barwidth[0] = 1;
if(not re.findall("^([a-dA-DeEnN\*tT])([0-9\-\$\:\/\.\+]+)([a-dA-DeEnN\*tT])$", upc)):
if(not re.findall(r"^([a-dA-DeEnN\*tT])([0-9\-\$\:\/\.\+]+)([a-dA-DeEnN\*tT])$", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(barwidth[0])) or int(barwidth[0]) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(barwidth[0])) or int(barwidth[0]) < 1):
barwidth[0] = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -131,12 +131,12 @@ def create_codabar_barcode(upc,outfile="./codabar.png",resize=1,hideinfo=(False,
else:
pil_addon_fix = 0;
cairo_addon_fix = 0;
pre_upc_matches = upc_matches = re.findall("^([a-dA-DeEnN\*tT])([0-9\-\$\:\/\.\+]+)([a-dA-DeEnN\*tT])$", upc);
pre_upc_matches = upc_matches = re.findall(r"^([a-dA-DeEnN\*tT])([0-9\-\$\:\/\.\+]+)([a-dA-DeEnN\*tT])$", upc);
pre_upc_matches = pre_upc_matches[0];
upc_matches = list(pre_upc_matches[1]);
bcsize9 = len(re.findall("([0-9\-\$])", "".join(upc_matches)));
bcsize10 = len(re.findall("([\:\/\.])", "".join(upc_matches)));
bcsize12 = len(re.findall("([\+])", "".join(upc_matches)));
bcsize9 = len(re.findall(r"([0-9\-\$])", "".join(upc_matches)));
bcsize10 = len(re.findall(r"([\:\/\.])", "".join(upc_matches)));
bcsize12 = len(re.findall(r"([\+])", "".join(upc_matches)));
upc_size_add = ((bcsize9 * 9) + (bcsize10 * 10) + (bcsize12 * 12) + len(upc_matches) - 1) * barwidth[0];
if(pilsupport and imageoutlib=="pillow"):
upc_preimg = Image.new("RGB", ((40 * barwidth[0]) + upc_size_add, barheightadd + (9 * barwidth[1])));
Expand Down
16 changes: 8 additions & 8 deletions upcean/encode/code11.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def create_code11_barcode(upc,outfile="./code11.png",resize=1,hideinfo=(False, F
imageoutlib = "cairo";
if(len(upc) < 1):
return False;
if(not re.findall("([0-9\-]+)", upc)):
if(not re.findall(r"([0-9\-]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -131,8 +131,8 @@ def create_code11_barcode(upc,outfile="./code11.png",resize=1,hideinfo=(False, F
upc_print = upc_matches;
if(len(upc_matches)<=0):
return False;
bcsize6 = len(re.findall("([09\-])", "".join(upc_matches)));
bcsize7 = len(re.findall("([1-8])", "".join(upc_matches)));
bcsize6 = len(re.findall(r"([09\-])", "".join(upc_matches)));
bcsize7 = len(re.findall(r"([1-8])", "".join(upc_matches)));
upc_size_add = ((bcsize6 * 6) + (bcsize7 * 7) + len(upc_matches) - 1) * barwidth[0];
if(pilsupport and imageoutlib=="pillow"):
upc_preimg = Image.new("RGB", ((34 * barwidth[0]) + upc_size_add, barheightadd + (9 * barwidth[1])));
Expand Down Expand Up @@ -463,9 +463,9 @@ def create_code11alt_barcode(upc,outfile="./code11.png",resize=1,hideinfo=(False
imageoutlib = "cairo";
if(len(upc) < 1):
return False;
if(not re.findall("([0-9\-]+)", upc)):
if(not re.findall(r"([0-9\-]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -545,8 +545,8 @@ def create_code11alt_barcode(upc,outfile="./code11.png",resize=1,hideinfo=(False
UPC_Count += 1;
UPC_Weight += 1;
upc_matches.append(Code11Array[UPC_Sum % 11]);
bcsize6 = len(re.findall("([09\-])", "".join(upc_matches)));
bcsize7 = len(re.findall("([1-8])", "".join(upc_matches)));
bcsize6 = len(re.findall(r"([09\-])", "".join(upc_matches)));
bcsize7 = len(re.findall(r"([1-8])", "".join(upc_matches)));
upc_size_add = ((bcsize6 * 6) + (bcsize7 * 7) + len(upc_matches) - 1) * barwidth[0];
if(pilsupport and imageoutlib=="pillow"):
upc_preimg = Image.new("RGB", ((34 * barwidth[0]) + upc_size_add, barheightadd + (9 * barwidth[1])));
Expand Down
14 changes: 7 additions & 7 deletions upcean/encode/code128.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def create_code128hex_barcode(upc,outfile="./code128.png",resize=1,hideinfo=(Fal
return False;
if(len(upc) < 8):
return False;
if(not re.findall("([0-9a-f]+)", upc)):
if(not re.findall(r"([0-9a-f]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -130,12 +130,12 @@ def create_code128hex_barcode(upc,outfile="./code128.png",resize=1,hideinfo=(Fal
pil_addon_fix = 0;
cairo_addon_fix = 0;
upc = upc.lower();
if(not re.findall("[0-9a-f]{2}", upc)):
if(not re.findall(r"[0-9a-f]{2}", upc)):
return False;
upc_matches = re.findall("[0-9a-f]{2}", upc);
upc_matches = re.findall(r"[0-9a-f]{2}", upc);
upc_to_dec = list([int(x, 16) for x in upc_matches]);
subfromlist = upc_matches.count("6d");
upc_size_add = (((len(upc_matches) - subfromlist) * 11) + (len(re.findall("6c", upc)) * 2)) * barwidth[0];
upc_size_add = (((len(upc_matches) - subfromlist) * 11) + (len(re.findall(r"6c", upc)) * 2)) * barwidth[0];
if(pilsupport and imageoutlib=="pillow"):
upc_preimg = Image.new("RGB", ((29 * barwidth[0]) + upc_size_add, barheightadd + (9 * barwidth[1])));
upc_img = ImageDraw.Draw(upc_preimg);
Expand Down Expand Up @@ -757,9 +757,9 @@ def create_code128dec_barcode(upc,outfile="./code128.png",resize=1,hideinfo=(Fal
imageoutlib = "cairo";
if(len(upc) < 12):
return False;
if(not re.findall("[0-9]{3}", upc)):
if(not re.findall(r"[0-9]{3}", upc)):
return False;
upc_matches = re.findall("[0-9]{3}", upc);
upc_matches = re.findall(r"[0-9]{3}", upc);
il = len(upc_matches);
i = 0;
upcout = "";
Expand Down
4 changes: 2 additions & 2 deletions upcean/encode/code32.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def create_code32_barcode(upc,outfile="./code32.png",resize=1,hideinfo=(False, F
imageoutlib = "cairo";
if(len(upc) < 1):
return False;
if(not re.findall("([0-9a-zB-DF-HJ-NP-Z\-\.\$\/\+% ]+)", upc)):
if(not re.findall(r"([0-9a-zB-DF-HJ-NP-Z\-\.\$\/\+% ]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down
8 changes: 4 additions & 4 deletions upcean/encode/code39.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def create_code39_barcode(upc,outfile="./code39.png",resize=1,hideinfo=(False, F
imageoutlib = "cairo";
if(len(upc) < 1):
return False;
if(not re.findall("([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
if(not re.findall(r"([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -518,9 +518,9 @@ def create_code39extended_barcode(upc,outfile="./code39extended.png",resize=1,hi
imageoutlib = "cairo";
if(len(upc) < 1):
return False;
if(not re.findall("([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
if(not re.findall(r"([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down
12 changes: 6 additions & 6 deletions upcean/encode/code93.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def create_code93_barcode(upc,outfile="./code93.png",resize=1,hideinfo=(False, F
imageoutlib = "cairo";
if(len(upc) < 1):
return False;
if(not re.findall("([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
if(not re.findall(r"([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -536,9 +536,9 @@ def create_code93extended_barcode(upc,outfile="./code93extended.png",resize=1,hi
imageoutlib = "cairo";
if(len(upc) < 1):
return False;
if(not re.findall("([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
if(not re.findall(r"([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -1029,9 +1029,9 @@ def create_code93alt_barcode(upc,outfile="./code93.png",resize=1,hideinfo=(False
imageoutlib = "cairo";
if(len(upc) < 1):
return False;
if(not re.findall("([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
if(not re.findall(r"([0-9a-zA-Z\-\.\$\/\+% ]+)", upc)):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down
12 changes: 6 additions & 6 deletions upcean/encode/ean13.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ def create_ean13_barcode(upc,outfile="./ean13.png",resize=1,hideinfo=(False, Fal
imageoutlib = "cairo";
upc_pieces = None;
supplement = None;
if(re.findall("([0-9]+)([ |\|]{1})([0-9]{2})$", upc)):
upc_pieces = re.findall("([0-9]+)([ |\|]{1})([0-9]{2})$", upc);
if(re.findall(r"([0-9]+)([ |\|]{1})([0-9]{2})$", upc)):
upc_pieces = re.findall(r"([0-9]+)([ |\|]{1})([0-9]{2})$", upc);
upc_pieces = upc_pieces[0];
upc = upc_pieces[0];
supplement = upc_pieces[2];
if(re.findall("([0-9]+)([ |\|]){1}([0-9]{5})$", upc)):
upc_pieces = re.findall("([0-9]+)([ |\|]){1}([0-9]{5})$", upc);
if(re.findall(r"([0-9]+)([ |\|]){1}([0-9]{5})$", upc)):
upc_pieces = re.findall(r"([0-9]+)([ |\|]){1}([0-9]{5})$", upc);
upc_pieces = upc_pieces[0];
upc = upc_pieces[0];
supplement = upc_pieces[2];
if(len(upc)>13 or len(upc)<13):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -137,7 +137,7 @@ def create_ean13_barcode(upc,outfile="./ean13.png",resize=1,hideinfo=(False, Fal
else:
pil_addon_fix = 0;
cairo_addon_fix = 0;
upc_matches = re.findall("(\d{1})(\d{6})(\d{6})", upc);
upc_matches = re.findall(r"(\d{1})(\d{6})(\d{6})", upc);
if(len(upc_matches)<=0):
return False;
upc_matches = upc_matches[0];
Expand Down
6 changes: 3 additions & 3 deletions upcean/encode/ean2.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def create_ean2sup_barcode(upc,outfile="./ean2_supplement.png",resize=1,hideinfo
imageoutlib = "cairo";
if(len(upc)>2 or len(upc)<2):
return False;
upc_matches = re.findall("(\d{2})", upc);
upc_matches = re.findall(r"(\d{2})", upc);
if(len(upc_matches)<=0):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -429,7 +429,7 @@ def encode_ean2sup_barcode(upc,resize=1,hideinfo=(False, False, False),barheight
return create_ean2sup_barcode(upc,None,resize,hideinfo,barheight,barwidth,textxy,barcolor,imageoutlib);

def create_ean2_barcode(upc,outfile="./ean2.png",resize=1,hideinfo=(False, False, False),barheight=(48, 54),barwidth=(1, 1),textxy=(1, 1, 1),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
upc_preimg = Image.new("RGB", (((29 * barwidth[0]) * int(resize)) + (8 * int(resize)), (barheightadd + (9 * barwidth[1])) * int(resize)));
upc_img = ImageDraw.Draw(upc_preimg);
Expand Down
6 changes: 3 additions & 3 deletions upcean/encode/ean5.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def create_ean5sup_barcode(upc,outfile="./ean5_supplement.png",resize=1,hideinfo
imageoutlib = "cairo";
if(len(upc)>5 or len(upc)<5):
return False;
upc_matches = re.findall("(\d{5})", upc);
upc_matches = re.findall(r"(\d{5})", upc);
if(len(upc_matches)<=0):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -516,7 +516,7 @@ def encode_ean5sup_barcode(upc,resize=1,hideinfo=(False, False, False),barheight
return create_ean5sup_barcode(upc,None,resize,hideinfo,barheight,barwidth,textxy,barcolor,imageoutlib);

def create_ean5_barcode(upc,outfile="./ean5.png",resize=1,hideinfo=(False, False, False),barheight=(48, 54),barwidth=(1, 1),textxy=(1, 1, 1),barcolor=((0, 0, 0), (0, 0, 0), (255, 255, 255)),imageoutlib="pillow"):
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
upc_preimg = Image.new("RGB", (((56 * barwidth[0]) * int(resize)) + (8 * int(resize)), (barheightadd + (9 * barwidth[1])) * int(resize)));
upc_img = ImageDraw.Draw(upc_preimg);
Expand Down
16 changes: 8 additions & 8 deletions upcean/encode/ean8.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ def create_ean8_barcode(upc,outfile="./ean8.png",resize=1,hideinfo=(False, False
imageoutlib = "cairo";
upc_pieces = None;
supplement = None;
if(re.findall("([0-9]+)([ |\|]{1})([0-9]{2})$", upc)):
upc_pieces = re.findall("([0-9]+)([ |\|]{1})([0-9]{2})$", upc);
if(re.findall(r"([0-9]+)([ |\|]{1})([0-9]{2})$", upc)):
upc_pieces = re.findall(r"([0-9]+)([ |\|]{1})([0-9]{2})$", upc);
upc_pieces = upc_pieces[0];
upc = upc_pieces[0];
supplement = upc_pieces[2];
if(re.findall("([0-9]+)([ |\|]){1}([0-9]{5})$", upc)):
upc_pieces = re.findall("([0-9]+)([ |\|]){1}([0-9]{5})$", upc);
if(re.findall(r"([0-9]+)([ |\|]){1}([0-9]{5})$", upc)):
upc_pieces = re.findall(r"([0-9]+)([ |\|]){1}([0-9]{5})$", upc);
upc_pieces = upc_pieces[0];
upc = upc_pieces[0];
supplement = upc_pieces[2];
if(len(upc)>8 or len(upc)<8):
return False;
if(not re.findall("^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
if(not re.findall(r"^([0-9]*[\.]?[0-9])", str(resize)) or int(resize) < 1):
resize = 1;
if(pilsupport and imageoutlib=="pillow"):
try:
Expand Down Expand Up @@ -137,17 +137,17 @@ def create_ean8_barcode(upc,outfile="./ean8.png",resize=1,hideinfo=(False, False
else:
pil_addon_fix = 0;
cairo_addon_fix = 0;
upc_matches = re.findall("(\d{4})(\d{4})", upc);
upc_matches = re.findall(r"(\d{4})(\d{4})", upc);
upc_matches = upc_matches[0];
if(len(upc_matches)<=0):
return False;
LeftDigit = list(upc_matches[0]);
upc_matches_new = re.findall("(\d{2})(\d{2})", upc_matches[0]);
upc_matches_new = re.findall(r"(\d{2})(\d{2})", upc_matches[0]);
upc_matches_new= upc_matches_new[0];
LeftLeftDigit = upc_matches_new[0];
LeftRightDigit = upc_matches_new[1];
RightDigit = list(upc_matches[1]);
upc_matches_new = re.findall("(\d{2})(\d{2})", upc_matches[1]);
upc_matches_new = re.findall(r"(\d{2})(\d{2})", upc_matches[1]);
upc_matches_new= upc_matches_new[0];
RightLeftDigit = upc_matches_new[0];
RightRightDigit = upc_matches_new[1];
Expand Down
Loading

0 comments on commit 96da12b

Please sign in to comment.