示例#1
0
文件: buygen.py 项目: johnpeck/jpeda
def sumreport(shortdict):
    sumfile = ('kit' + str(kitgen.kitnum) + '_summary.dat')
    descdict = partman.org2dict(kitgen.descfile)
    fos = open(kitgen.kitdir + "/" + sumfile,'w')
    fos.write('-*- mode: Org; mode: Auto-Revert; -*-' + '\n')
    fos.write('#+STARTUP: align' + '\n')
    fos.write('# \n')
    fos.write('# Add an x anywhere in the "Remove" column \n')
    fos.write('# and save this file to disqualify a vendor \n')
    fos.write('# for a given part. \n')
    fos.write('|-' + '\n')
    fos.write('|JRR part' + '|Quantity' + '|Vendor' + '|Remove' +
              '|Description|' + '\n')
    fos.write('| | | | |<70>|' + '\n') # Set description column width
    fos.write('|-' + '\n')
    for part in shortdict:
        if (shortdict[part] > 0):
            foundit = False # Did we find the part in any vendor file?
            for vendor in venlist:
                venfile = venpath + '/' + vendor + '.dat'
                if part in partman.org2dict(venfile):
                    if part in descdict:
                        fos.write('|' + str(part) + '|' +
                        str(shortdict[part]) + '|' + vendor + '| |' + 
                            descdict[part][0] + '\n')
                    else:
                        fos.write('|' + str(part) + '|' + 
                        str(shortdict[part]) + '|' + vendor + '| |' + 
                            'No description' + '\n')
                    fos.write('|-' + '\n')
                    foundit = True
            if not foundit: # The part was not found in any vendor file.
                fos.write('|' + str(part) + '|' + str(shortdict[part]) +
                          '|' + 'None' + '|' +'\n')
                fos.write('|-' + '\n')
                print('Part ' + str(part) + ' was not found in any vendor file :-(')
    fos.close()
    partman.multisort(kitgen.sumpath,0)
    print('* Wrote summary to ' + sumfile)
示例#2
0
文件: kitgen.py 项目: johnpeck/jpeda
def bomcost(pagelist):
    kitcostfile = ('kit' + str(kitnum) + '_cost.bom')
    fob = open(kitdir + '/' + kitcostfile,'w')
    partman.sortorg(costfile,0) # Sort the nomcost file
    costdict = partman.org2dict(costfile) # Maps JPart to unit price
    descdict = partman.org2dict(descfile) # Description dictionary
    bomqty = partcount(pagelist) # Maps JPart to quantity
    fob.write('-*- mode: Org; mode: Auto-Revert; -*-' + '\n')
    fob.write('#+STARTUP: align' + '\n')
    fob.write('#' + '\n')
    fob.write('|-' + '\n')
    fob.write('|JPart' + '|Kit Qty' + '|Each ($)' + '|Extended ($)' +
              '|Description|' + '\n')
    fob.write('| | | | |<70>|' + '\n') # To set description column width
    fob.write('|-' + '\n')
    costsum = 0
    for part in bomqty:
        fob.write('|' + part + '|' + str(bomqty[part]) + '|')
        if part in costdict:
            eachcost = float(costdict[part][0])
            extcost = bomqty[part] * eachcost
            fob.write('%0.2f'%eachcost + '|' + 
                      '%0.2f'%extcost)
            costsum += extcost
        else:
            fob.write('Unknown' + '|' + 'Unknown')
        if part in descdict:
            fob.write('|' + descdict[part][0] + '|' + '\n')
        else:
            fob.write('|' + 'unknown' + '|' + '\n')
        fob.write('|-' + '\n')
    fob.write('BOM cost is %0.2f'%costsum + '\n')
    fob.close()
    partman.multisort(kitdir + '/' + kitcostfile,0)
    fob = open(kitdir + '/' + kitcostfile,'a')
    fob.write('BOM cost is $%0.2f'%costsum + '\n')
    fob.close()
    print('* Nominal BOM cost breakdown written to ' + kitcostfile + 
          ' in emacs org-mode format.')
示例#3
0
def main():
    for filename in partfiles:
        longname = purchdir + '/' + filename
        print ('Sorting ' + filename + '...'),
        partman.multisort(longname,1)
        print 'done'