def get_reader(elec_inven_data_idx): sdict = config.ELECTRONICS_INVENTORY_DATA[elec_inven_data_idx] reader = None if sdict['type'] == 'QuazarStockXLS': fpath = sdict['fpath'] if not os.path.isabs(fpath): fpath = config.get_svn_path(fpath) sname = sdict['sname'] location = sdict['location'] tfpath = sdict['tfpath'] reader = get_stockxlsreader(fpath, sname, location, tfpath) if reader is not None: return reader else: logger.error("Could not find reader for: " "ELECTRONICS_INVENTORY_DATA." + str(elec_inven_data_idx))
def get_reader(elec_inven_data_idx): sdict = copy(config.ELECTRONICS_INVENTORY_DATA[elec_inven_data_idx]) reader = None invtype = sdict.pop('type') if invtype == 'QuazarStockXLS': if not os.path.isabs(sdict['fpath']): sdict['fpath'] = config.get_svn_path(sdict['fpath']) sdict['xlf'] = libreoffice.get_xlf(sdict.pop('fpath')) reader = StockXlsReader(**sdict) elif invtype == 'TallyStock': from tendril.utils.connectors.tally.stock import InventoryTallyReader reader = InventoryTallyReader(**sdict) if reader is not None: return reader else: logger.error("Could not find reader for: " "ELECTRONICS_INVENTORY_DATA." + str(elec_inven_data_idx))
def gen_canonical_transform(elec_inven_data_idx, regen=True): sdict = config.ELECTRONICS_INVENTORY_DATA[elec_inven_data_idx] if sdict['type'] == 'QuazarStockXLS': fpath = sdict['fpath'] if not os.path.isabs(fpath): fpath = config.get_svn_path(fpath) sname = sdict['sname'] location = sdict['location'] tfpath = sdict['tfpath'] rdr = get_stockxlsreader(fpath, sname, location, tfpath) outp = tfpath outf = fsutils.VersionedOutputFile(outp) outw = csv.writer(outf) outw.writerow( ('Current', 'gEDA Current', 'Ideal', 'Status', 'In Symlib') ) for line in rdr.row_gen: if regen and rdr.tf.has_contextual_repr(line[0]): if gsymlib.is_recognized(rdr.tf.get_canonical_repr(line[0])): in_symlib = 'YES' else: in_symlib = '' outw.writerow((line[0], rdr.tf.get_canonical_repr(line[0]), rdr.tf.get_ideal_repr(line[0]), rdr.tf.get_status(line[0]), in_symlib,)) else: if gsymlib.is_recognized(line[0]): in_symlib = True else: in_symlib = False outw.writerow((line[0], line[0], line[0], 'NEW', in_symlib)) outf.close()