Beispiel #1
0
def rmchecked():
    fin = open(kitgen.sumpath,'r')
    fot = open('junk.dat','w')
    rawfile = fin.read()
    for line in rawfile.split('\n'):
        if partman.iscom(line) or line.startswith('-*-'):
            fot.write(line + '\n') # Copy the first few comment lines
    fot.write('|-' + '\n')
    if len(partman.orgheader(kitgen.sumpath)[1]) == 0:
        for item in partman.orgheader(kitgen.sumpath)[0]: #Write the table header
            fot.write('|' + item)
        fot.write('|' + '\n')
        fot.write('|-' + '\n')
    else:
        for item in partman.orgheader(kitgen.sumpath)[0]: #Write the table header
            fot.write('|' + item)
        fot.write('|' + '\n')
        for item in partman.orgheader(kitgen.sumpath)[1]: #Write the table customizations
            fot.write('|' + item)
        fot.write('|' + '\n')
        fot.write('|-' + '\n')
    for line in rawfile.split('\n'):
        if partman.isorgdata(line):
            fields = line.split('|')
            if partman.isjrrpart(fields[1]) and len(fields[4].strip()) == 0:
            #fields[0] will be ''
                fot.write(line + '\n')
                fot.write('|-' + '\n')
    fot.close()
    fin.close()
    os.remove(kitgen.sumpath)
    os.rename('junk.dat',kitgen.sumpath)
Beispiel #2
0
def hasrepeat():
    fis = open(kitgen.sumpath,'r')
    rawfile = fis.read()
    partqty = {}
    repeats = False
    for line in rawfile.split('\n'):
        if partman.isorgdata(line):
            fields = line.split('|')
            if partman.isjrrpart(fields[1]): #fields[0] will be ''
                jrrpart = fields[1].strip()
                if jrrpart in partqty:
                    partqty[jrrpart] += 1
                    repeats = True
                    print('--fix--> Part ' + jrrpart + ' is repeated.')
                else:
                    partqty[jrrpart] = 1
    fis.close()
    return repeats