Beispiel #1
0
 def get_bar_code(str_code):
     """
     生成防伪码的条形码
     :param str_code: 防伪码
     """
     encoder = EAN13Encoder(str_code)
     encoder.save("barcode\\" + str_code + ".png")
Beispiel #2
0
def number7(choice):
    mainid = input_check("\033[1;32m     请输入EN13的国家代码(3位) :\33[0m", 3,
                         3)  #输入三位国家代码
    compid = input_check("\033[1;32m     请输入EAN13的企业代码(4位):\33[0m", 3,
                         4)  #输入四位企业代码
    incount = input_check("\033[1;32m     请输入要生成的条形码数量:\33[0m", 1,
                          0)  #输入要生成的条形码数量
    while int(incount) == 0:
        incount = input_check("\033[1;32m     请输入要生成的条形码数量:\33[0m", 1,
                              0)  # 输入要生成的条形码数量
    mkdir("barcode")  #判断保存条形码的文件是否存在,若不存在则创建
    for j in range(int(incount)):  #批量生成条形码
        strone = ''
        for i in range(5):  #生成条形码的5位 3+4+5=12 还有一位是校验位
            strone = strone + str(random.choice(number))
        barcode = mainid + compid + strone  #生成12位的条形码
        #计算条形码的校验位
        evensum = int(barcode[1]) + int(barcode[3]) + int(barcode[5]) + int(barcode[7]) +\
        int(barcode[9]) + int(barcode[11])
        oddsum = int(barcode[0]) + int(barcode[2]) + int(barcode[4]) + int(barcode[6]) +\
        int(barcode[8]) + int(barcode[10])
        checkbit = int((10 - (evensum * 3 + oddsum) % 10) % 10)  #计算校验位
        barcode = barcode + str(checkbit)  #组成完整的13位EAN13条形码
        print(barcode)
        encoder = EAN13Encoder(barcode)  #生成条形码
        encoder.save("barcode\\" + barcode + ".png")  #保存条形码信息图片
Beispiel #3
0
def scode7(schoice):
    mainid = inputbox("\033[1;32m     请输入EN13的国家代码(3位) :\33[0m", 3,
                      3)  # 输入3位国家代码
    # while int(mainid) < 1 or len(mainid) != 3:   # 验证输入是否为3位数字(转为整数后小于1和长度不等于3,重新输入)
    #     mainid = inputbox("\033[1;32m     请输入EAN13的国家代码(3位)::\33[0m", 1, 0)
    compid = inputbox("\033[1;32m     请输入EAN13的企业代码(4位):\33[0m", 3,
                      4)  # 输入4位企业代码
    # while int(compid) < 1 or len(compid) != 4:   # 验证输入是否为4位数字
    #     compid = inputbox("\033[1;32m     请输入EAN13的企业代码(4位):\33[0m", 1, 0)
    incount = inputbox("\033[1;32m     请输入要生成的条形码数量:\33[0m", 1,
                       0)  # 输入要生成的条形码数量
    while int(incount) == 0:  # 输入信息转为整数后等于0,重新输入
        incount = inputbox("\033[1;32m     请输入要生成的条形码数量:\33[0m", 1, 0)
    mkdir("barcode")  # 判断保存条形码的文件夹是否存在,不存在,则创建该文件夹
    for j in range(int(incount)):  # 批量生成条形码
        strone = ''  # 清空存储单条条形码的变量
        for i in range(5):  # 生成条形码的6位(除国家代码、企业代码和校验位之外的6位)数字
            strone = strone + str(random.choice(number))
        barcode = mainid + compid + strone  # 把国家代码、企业代码和新生成的随机码进行组合
        # 计算条形码的校验位
        evensum = int(barcode[1]) + int(barcode[3]) + int(barcode[5]) + int(
            barcode[7]) + int(barcode[9]) + int(barcode[11])  # 偶数位
        oddsum = int(barcode[0]) + int(barcode[2]) + int(barcode[4]) + int(
            barcode[6]) + int(barcode[8]) + int(barcode[10])
        # checkbit=int(10-(evensum *3 + oddsum)%10)
        checkbit = int((10 - (evensum * 3 + oddsum) % 10) % 10)
        barcode = barcode + str(checkbit)  # 组成完整的EAN13条形码的13位数字
        print(barcode)
        encoder = EAN13Encoder(barcode)  # 调用EAN13Encoder生成条形码
        encoder.save("barcode\\" + barcode + ".png")  # 保存条形码信息图片到文件
Beispiel #4
0
def scode6(cmd):
    '''条形码批量生成'''
    mainid = input_box('请输入国家代码(3位):', 1, 0)
    while int(mainid) < 1 or len(mainid) > 3:
        '''当输入的国家代码小于1整数或者长度小于3时,重新输入'''
        mainid = input_box('请输入国家代码:', 1, 0)
    compid = input_box('请输入企业代码(4位):', 1, 0)
    while int(compid) < 1 or len(compid) > 4:
        '''当输入的企业代码小于1整数或者长度小于4时,重新输入'''
        compid = input_box('请输入企业代码(4位):', 1, 0)
    incount = input_box('请输入要生成条形码的数量:', 1, 0)
    while int(incount) == 0:
        '''输入生成条形码的数量为0时,重新输入'''
        incount = input_box('请输入要生成条形码的数量:', 1, 0)
    mkdir('barcode')  #判断条形码的文件夹是否存在,如果不存在,则创建
    for j in range(int(incount)):
        strone = ''
        for i in range(5):
            strone += str(random.choice(number))
        barcode = mainid + compid + strone  #把国家代码,机器码,随机生成的代码进行组合
        #极端条形码的校检位
        evensum = int(barcode[1]) + int(barcode[3]) + int(barcode[5]) + int(
            barcode[7]) + int(barcode[9]) + int(barcode[11])
        oddsm = int(barcode[2]) + int(barcode[4]) + int(barcode[6]) + int(
            barcode[8]) + int(barcode[10])
    checkbit = int(10 - ((evensum * 3 + oddsm) % 10) % 10)
    barcode += str(checkbit)  #组成完整的13位条形码
    encoder = EAN13Encoder(barcode)  #调用EAN13模块生成条形码
    encoder.save('barcode\\' + barcode + '.png')
Beispiel #5
0
def generate_code7(choice):
    """
    生成条形码
    :param choice:
    :return:
    """
    main_id = input_box("请输入EN13的国家代码(3位)", 1, 0)
    while int(main_id) < 1 or len(main_id) != 3:
        main_id = input_box("请输入EN13的国家代码(3位)", 1, 0)

    com_id = input_box("请输入企业代码(4位)", 1, 0)
    while int(com_id) < 1 or len(com_id) != 4:
        com_id = input_box("请输入企业代码(4位)", 1, 0)

    in_count = input_box("请输入要生成的条形码数量:", 1, 0)
    while int(in_count) == 0:
        in_count = input_box("请输入要生成的条形码数量:", 1, 0)

    mkdir("barcode")
    for i in range(int(in_count)):
        str_one = ''
        for j in range(5):
            str_one = str_one + str(random.choice(number))
        barcode = main_id + com_id + str_one
        # 计算条形码的校验位
        even_sum = int(barcode[1]) + int(barcode[3]) + int(barcode[5]) + int(
            barcode[7]) + int(barcode[9]) + int(barcode[11])
        odd_sum = int(barcode[0]) + int(barcode[2]) + int(barcode[4]) + int(
            barcode[6]) + int(barcode[8]) + int(barcode[10])

        check_bit = int((10 - (even_sum * 3 + odd_sum) % 10) % 10)
        barcode = barcode + str(check_bit)
        encoder = EAN13Encoder(barcode)
        encoder.save("barcode\\" + barcode + ".png")
Beispiel #6
0
    def test_against_generated(self):
        """Compare the output of this library with generated barcodes"""

        for index, string in enumerate(EAN13Test.test_strings):
            encoder = EAN13Encoder(string)
            encoder.save('test.png')

            import filecmp
            self.assertTrue(
                filecmp.cmp('test.png',
                            'pystrich/ean13/test_img/%d.png' % (index + 1)))
Beispiel #7
0
    def create_barcode(self):
        """生产条形码"""
        code_name = "".join([
            STORAGE_CONFIG["BARCODE"]["ADDR"],
            STORAGE_CONFIG["BARCODE"]["COM"], self.code
        ])
        encoder = EAN13Encoder(code_name)

        file_path = "".join(
            [STORAGE_CONFIG["BARCODE"]["PATH"], code_name, ".png"])
        encoder.save(file_path)
        return file_path
Beispiel #8
0
def scode7(choice):
    codes = []
    country_id = input_box(
        "\033[1;32m     Please enter the 3-digit country id: \33[0m", 1, 0)
    while len(country_id) != 3 or int(country_id) < 1:
        country_id = input_box(
            "\033[1;32m     Please enter the 3-digit country id: \33[0m", 1, 0)

    company_id = input_box(
        "\033[1;32m     Please enter the 4-digit company id: \33[0m", 1, 0)
    while len(company_id) != 4 or int(country_id) < 1:
        company_id = input_box(
            "\033[1;32m     Please enter the 4-digit company id: \33[0m", 1, 0)

    count = input_box(
        "\033[1;32m     Please enter the number of codes you want to generate: \33[0m",
        1, 0)
    while count == "0":
        count = input_box(
            "\033[1;32m     Please enter the number of codes you want to generate: \33[0m",
            1, 0)

    mkdir("barcode")
    while len(codes) != int(count):
        code = country_id + company_id
        part = ""
        for i in range(5):
            part = part + random.choice(number)
        code = code + part
        # calc the last digit of code
        even_sum = int(code[1]) + int(code[3]) + int(code[5]) + int(
            code[7]) + int(code[9]) + int(code[11])
        odd_sum = int(code[0]) + int(code[2]) + int(code[4]) + int(
            code[6]) + int(code[8]) + int(code[10])
        check_bit = (even_sum * 3 + odd_sum) % 10
        check_bit = (10 - check_bit) % 10
        code = code + str(check_bit)

        if code not in codes:
            codes.append(code)

    # generate barcode
    for code in codes:
        encoder = EAN13Encoder(code)
        encoder.save("barcode\\" + code + ".jpg")
Beispiel #9
0
def get_barcode_image(code, codetype='ean13'):
    from PIL import Image
    from io import BytesIO
    from pystrich.code128 import Code128Encoder
    from pystrich.ean13 import EAN13Encoder
    from pystrich.code39 import Code39Encoder
    codermap = {
        'code128': lambda code: Code128Encoder(code, options={'height': 100}),
        'ean13': lambda code: EAN13Encoder(code),
        'code39': lambda code: Code39Encoder(code, options={'height': 100}),
    }
    codetype = codetype.lower()
    if codetype not in codermap:
        import warnings
        warnings.warn('unsupported barcode type "%s"' % (codetype))
    else:
        encoder = codermap[codetype](code)
        img = Image.open(BytesIO(encoder.get_imagedata(4)))
        return img
Beispiel #10
0
def scode7(schoice):
    mainid = inputbox("\033[1;32m    请输入EN13的国家代码(3位):\033[0m", 1, 0)
    while int(mainid) < 1 or len(mainid) != 3:
        mainid = inputbox("\033[1;32m    请输入EN13的国家代码(3位):\033[0m", 1, 0)
    compid = inputbox("\033[1;32m    请输入EN13的企业代码(4位):\033[0m", 1, 0)
    while int(compid) < 1 or len(compid) != 4:
        compid = inputbox("\033[1;32m    请输入EN13的企业代码(4位):\033[0m", 1, 0)
    incount = inputbox("\033[1;32m    请输入您要生成的条形码数量:\33[0m", 1, 0)
    mkdir("barcode")
    for j in range(int(incount)):
        strone = ""
        for i in range(5):
            strone = strone + str(random.choice(number))
        barcode = mainid + compid + strone
        evensum = sum(range(1, 12, 2))
        oddsum = sum(range(0, 12, 2))
        checkbit = int((10 - (evensum * 3 + oddsum) % 10) % 10)
        barcode = barcode + str(checkbit)
        encoder = EAN13Encoder(barcode)
        encoder.save("barcode\\" + barcode + ".png")
Beispiel #11
0
    def test_check_digit(self):
        """Make sure the check digit calculation works"""

        # test includes the full range of check digits
        check_digits = {
            "012345678901": 2,
            "007567816412": 5,
            "750103131130": 9,
            "000000000000": 0,
            "000000010101": 1,
            "000000001111": 2,
            "000000000111": 3,
            "000000000101": 4,
            "000000001011": 5,
            "000000001001": 6,
            "000000000001": 7,
            "000000001010": 8,
            "000000000010": 9
        }
        for code, check in check_digits.items():
            enc = EAN13Encoder(code)
            self.assertEqual(enc.check_digit, check)
def scode7(schoice):
    mainid = inputbox('\033[1;32m  请输入EN13的国家代码(3位):\033[0m', 1, 0)
    while int(mainid) < 1 or len(mainid) != 3:
        mainid = inputbox('\033[1;32m  请输入EN13的国家代码(3位):\033[0m', 1, 0)
    compid = inputbox('\033[1;32m  请输入企业代码(4位):\033[0m', 1, 0)
    while int(compid) < 1 or len(compid) != 4:
        compid = inputbox('\033[1;32m  请输入EN13的企业代码(4位):\033[0m', 1, 0)
    incount = inputbox('\033[1;32m  请输入要生成的条形码数量:\033[0m', 1, 0)
    while incount == 0:
        incount = inputbox('\033[1;32m  请输入要生成的条形码数量:\033[0m', 1, 0)
    mkdir('barcode')
    for j in range(int(incount)):
        strone = ''
        for i in range(5):
            strone = strone + str(random.choice(number))
        barcode = mainid + compid + strone
        evensum = int(barcode[1]) + int(barcode[3]) + int(barcode[5]) + int(barcode[7]) + int(barcode[9]) + int(
            barcode[11])
        oddsum = int(barcode[2]) + int(barcode[4]) + int(barcode[6]) + int(barcode[8]) + int(barcode[10])
        checkbit = int(10 - ((evensum * 3 + oddsum) % 10) % 10)
        barcode = barcode + str(checkbit)
        encoder = EAN13Encoder(barcode)
        encoder.save('barcode\\' + barcode + '.png')
Beispiel #13
0
def wfile(sstr, sfile, typeis, smsg, datapath,count):
    """
    在特定的资料夹内将列表内的内容写入到对应的文件内,写入完成后后显示条形码的内容
    并且在对话框中显示已完成
    sstr: 含有条形码的列表
    sfile: 待写入条形码的文件名
    typeis: "":表示显示完成的对话框,"no": 不显示完成的对话框
    smsg: 对话框提示的内容
    datapath: 写入条形码对应的文件路径
    count: 生成验证码的数量
    """
    mkdir(datapath)
    file = datapath + '/' + sfile
    with open(file, 'a+') as f:
        wrlist = sstr
        pdata = ""
        for i in range(len(wrlist)):
            f.write(str(wrlist[i] + "\n"))
            pdata += str(wrlist[i])
    print("\033[1;31m" + pdata +  "\033[0m")
    if typeis != "no":
        tk.messagebox.showinfo("提示", smsg + str(len(wrlist)) + "\n 防伪码存放位置: " + filename)
        root.withdraw()

def scompare(sstr,file):
    """
        比较验证码是否有重复,无重复就返回该验证码,否则返回"0"
        sstr:  验证码
        file:  验证码保存文件的列表
    """
    if os.path.exists(file):
        with open(file, 'r') as f:
            mark = True
            for i in f:
                if i == sstr:
                    mark = False
                    break
        if mark == False:
            return "0"
        else:
            return sstr
    else:
        return sstr

def scode1(schoice):
    """生成6位数防伪码"""
    counter = 0
    file = "scode" + schoice + ".txt"
    in_count = inputbox("\033[1;31m 请输入需要生成6位验证码的数量:  \033[0m", 1, 0)
    while int(in_count) == 0:
        in_count = inputbox("\033[1;31m 请输入需要生成6位验证码的数量:  \033[0m", 1, 0)
    randstr.clear()
    while int(in_count) >= counter:
        randfir = ""
        for i in range(6):
            randfir += random.choice(number)
        if scompare(randfir, file) != "0":
            randstr.append(randfir)
            counter += 1
    smsg = "已生成6位验证码共计: "
    wfile(randstr, file, "", smsg, codepath)
    
def scode2(schoice):
    """生成9位防伪码,前三位为产品系列码."""
    counter = 0
    file = "scode" + schoice + ".txt"
    smsg = "已生成的9位验证码数量为: "
    code_start = inputbox("\033[1; 31m 请输入产品系列的数字起始码(3位): \033[0m", 1, 3) 
    while int(code_start) == 0:
        code_start = inputbox("\033[1; 31m 请输入产品系列的数字起始码(3位): \033[0m", 1, 3)
    in_count = inputbox("\033[1;31m 请输入需要生成9位验证码的数量:  \033[0m", 1, 0)
    while int(in_count) == 0:
        in_count = inputbox("\033[1;31m 请输入需要生成9位验证码的数量:  \033[0m", 1, 0)
    randstr.clear()
    while (int(in_count)) >= counter:
        randfir = ''
        for i in range(6):
            randfir += random.choice(number)
        randfir = code_start + randfir
        if scompare(randfir, file) != "0"
            counter += 1
            randstr.append(randfir)
    wfile(randstr, file, "", smsg, codepath)
    
def scode3(schoice):
    """生成25位字母数字组成的验证码"""
    counter = 0
    file = "scode" + schoice + ".txt"
    smsg = "已生成的25位防伪码数量为:  "
    in_count = inputbox("\033[1;31m 请输入需要生成25位验证码的数量:  \033[0m", 1, 0)
    while int(in_count) == 0:
        in_count = inputbox("\033[1;31m 请输入需要生成25位验证码的数量:  \033[0m", 1, 0)
    randstr.clear()
    while int(in_count) >= counter:
        randfir = ''
        for i in range(25):
            randfir += random.choice(letter)
        randsec = randfir[0:5] + '-' + randfir[5:10] + '-' + randfir[10:15] + '-' + randfir[15:20] + '-' + randfir[20:25]
        if scompare(randsec, file) != "0":
            randstr.append(randsec)
            counter += 1
    wfile(randstr, file, "", smsg, codepath)
    
def scode4(schoice):
    """
    生成12位智能数据验证码,其中3位为字母,字母位置随机
    字母第一位:地区
    字母第二位:颜色
    字母第三位:级别
    """
    counter = 0
    in_type = inputbox("\033[1;31m 请输入3位数据分析验证码的值(ex:abc):  \033[0m", 2, 3)
    while len(in_type) != 3:
        in_type = inputbox("\033[1;31m 请输入3位数据分析验证码的值(ex:abc):  \033[0m", 2, 3)
    in_count = inputbox("\033[1;31m 请输入需要生成12位智能数据验证码的数量:  \033[0m", 1, 0)
    while int(in_count) == 0:
        in_count = inputbox("\033[1;31m 请输入需要生成12位智能数据验证码的数量:  \033[0m", 1, 0)
    ff_code(in_type, in_count)
    
ff_code(in_type, in_count, schoice):
    """
    根据字母验证码及验证码的数量,生成12位的智能数据分析验证码
    in_type: 验证码智能验证的值,共三位,第一位代表地区,第二位代表颜色,第三位代表产品级别,字母位置随机
    in_count:验证码生成的数量
    """
    counter = 0
    file = 'scode' + schoice + ".txt"
    smsg = "已生成的12为智能数据验证码的数量为:  "
    randstr.clear()
    first = in_type[0].upper()
    second = in_type[1].upper()
    third = in_type[2].upper()
    position = random.sample(number, 3)
    while int(in_count) >= counter:
        randfir = ''
        for i in range(9):
            randfir += random.choice(number)
        randsec = randfir[0:int(position[0])] + first + randfir[int(position[0]):int(positon[1])] + second + randfir[int(position[1]):int(position[2])] + third + randfir[int(position[2]:9)]
        if scompare(randsec, file) != "0":
            randstr.append(randsec)
            counter += 1
    wfile(randstr, file, "", smsg, codepath)

def scode5(schoice):
    default_file = r"/home/echo/learngit/collpull/mrsoft.mri"
    file_path = tk.filedialog.askopenfile(filetypes=[("Text file", "*.mri")],title=u"请选择自动防伪码智能批处理文件:  ", initialdir=(os.path.expanduser(default_file))
    codelist = openfile(file_path)
    for item in codelist:
        itema = item.split()[0]
        itemb = item.split()[1]
        ff_code(itema, itemb, schoice="4")

def scode6(schoice):
    """
        根据输入的国家代码,企业代码及数量生成EAN13条形码
    """
    counter = 0    
    file = scode + schoice + ".txt"       
    smsg = "EAN13条形码生成的数量为:  "                 
    country_code = inputbox("请输入EAN13条形码的国家代码:  ", 3, 3)
    while country_code == "0":
        country_code = inputbox("请输入EAN13条形码的国家代码:  ", 3, 3)
    corp_code = inputbox("请输入EAN13条形码的企业代码:  ", 3, 4)
    while corp_code == "0":
        corp_code = inputbox("请输入EAN13条形码的企业代码:  ", 3, 3)
    quantity = inputbox("请输入生成EAN13条形码的数量:  ", 1, 0)
    while quantity == "0":
        quantity = inputbox("请输入生成EAN13条形码的数量:  ", 1, 0)
    randstr.clear()
    while quantity >= counter:
        randfir = ""
        for i in range(5):
            randfir += random.choice(number)
        randfir = country_code + corp_code + randfir
        evennum = int(randfir[1]) + int(randfir[3]) + int(randfir[5]) + int(randfir[7]) + int(randfir[9]) + int(randfir[11])
        oddnum = int(randfir[0]) + int(randfir[2]) + int(randfir[4]) + int(randfir[6]) + int(randfir[8]) + int(randfir[10])   
        checkbit = (10 - ((oddnum*3 + evennum)%10)%10)
        randfir += str(checkbit)
        if barcode_check(randfir, barcode) != "0":
            bar_code = EAN13Encoder(randfir)
            bar_code.save(barcode + '/' + 'randfir' + ".png")
            
def barcode_check(sstr, barcode):
    mkdir(barcode)
    mark = True
    for root,dirs,files in os.walk(barcode):
        filenames = files
    for fname in filenames:
        fname = fname.split('.')[0]
            if fname == sstr:
                mark = False
                break
    if mark == False:
        return "0"
    else:
        return sstr
                
                

def scode7(schoice):
    """
    生成qrcode,并保存到固定的路径.
    """
    counter = 0
    in_count = inputbox("请输入qrcode二维码的国家代码:  ", 3, 3)
    while in_count == "0":
        in_count = inputbox("请输入qrcode二维码的国家代码:  ", 3, 3)
    mkdir(qrcode)
    while int(in_count) >= counter:
        strone = ''
        for i in range(12):
            strone += random.choice(number)
        if barcode_check(strone, qrcode) != "0":
            encoder = qrcode.make(strone)
            encoder.save(qrcode + '/' + 'strone' + '.png')

def lottery():
    file = r"lottery.ini"
    file_path = tk.filedialog.askopenfilename(filetypes=[("Ini file", "*.ini")], title=u"请选择包含抽奖号码的文件: ", initialdir=(os.path.expanduser(file)))
    codelist = openfile(file_path)
    
            
def menu():
    """
    ----------------------------------------------------------------------------------------------------
    ---------------------                    企业编码生成系统                       ----------------------
    |
    |                            1.生成6位数字防伪码(ex:213456)
    |                            2.生成9位系列产品数字防伪码(ex:23682392)
    |                            3.生成25位混合产品序列号(xxxxx-xxxxx-xxxxx-xxxxx-xxxxx)
    |                            4.生成含数据分析功能的防伪码(ex:234U23S999I2)
    |                            5.智能批量生成含数据分析功能的防伪码(ex:234U23S999I2)
    |                            6.EAN-13条形码批量生成
    |                            7.二维码批量输出
    |                            8.企业粉丝抽奖
    |                            0.退出系统
    |---------------------------------------------------------------------------------------------------
    """
        
# -*-coding:utf-8-*-
# Author: Liu Jing
# Data: 2020  20:24
# File Name: test
# import qrcode
#
# encoder = qrcode.make('http://www.baidu.com')
# encoder.save('baidu.png')
# encoder.show()
import random

print(random.choice('12446578'))
from pystrich.ean13 import EAN13Encoder
encoder = EAN13Encoder('4655343452456')
encoder.save('4655343452456.png')
Beispiel #15
0
path = r"/home/echo/learngit/codepull/codeauto.mri"
root = tk.Tk()
file_path = tk.filedialog.askopenfilename(
    filetypes=[("Text file", "*.mri")],
    title=u"请选择要处理的文件",
    initialdir=(os.path.expanduser(path)))
with open(file_path, 'r') as f:
    file_list = f.read()
#file_list = openfile(file_path)

code_list = file_list.split("\n")
print(code_list)

s = "9301028183401"
encode = EAN13Encoder(s)
encode.save(s + ".png")

sstr = ['239232323.png', '282930232.png', '234923943.png']
file = r"/home/echo/test"


def filename_trans(sstr, file):
    if not os.path.exists(file):
        os.mkdir(file)
    for root, dirs, files in os.walk(file):
        flist = files
    print(flist)


def main():
Beispiel #16
0
 def test_encoding(self):
     """Make the the left and right encodings work"""
     enc = EAN13Encoder("750103131130")
     left, right = enc.encode()
     self.assertEqual(left, "011000101001110011001010011101111010110011")
     self.assertEqual(right, "100001011001101100110100001011100101110100")
Beispiel #17
0
def transfer(s):
    encoder = EAN13Encoder(s)
    encoder.save(s + ".jpg")
Beispiel #18
0
"""Generate test images for EAN13 barcode encoder"""

from pystrich.ean13 import EAN13Encoder
from pystrich.ean13.test_ean13 import EAN13Test

for index, string in enumerate(EAN13Test.test_strings):
    enc = EAN13Encoder(string)
    enc.save("pystrich/ean13/test_img/%d.png" % (index + 1))
Beispiel #19
0
"""Example code for ean13 library"""
__revision__ = "$Revision$"

from pystrich.ean13 import EAN13Encoder
import sys
import logging

logging.getLogger("ean13").setLevel(logging.DEBUG)
logging.getLogger("ean13").addHandler(logging.StreamHandler(sys.stdout))

if __name__ == "__main__":
    encoder = EAN13Encoder(sys.argv[1])
    encoder.save("test.png")
Beispiel #20
0
 def test_parity(self):
     """Test the parity calculations"""
     enc = EAN13Encoder("750103131130")
     self.assertEqual(enc.get_parity(), (1, 0, 1, 0, 1, 0))