Example #1
0
 def _dump_order_yaml(self, outfolder=None, register=False, session=None):
     self._build_yaml_data()
     with open(os.path.join(outfolder, 'order.yaml'), 'w') as f:
         f.write(yaml.dump(self._yaml_data, default_flow_style=False))
     if register is True:
         docstore.register_document(
                 serialno=self.serialno,
                 docpath=os.path.join(outfolder, 'order.yaml'),
                 doctype='PRODUCTION ORDER YAML',
                 verbose=False, efield=self.title,
                 session=session
         )
Example #2
0
 def _dump_order_yaml(self, outfolder=None, register=False, session=None):
     self._build_yaml_data()
     with open(os.path.join(outfolder, 'order.yaml'), 'w') as f:
         f.write(yaml.dump(self._yaml_data, default_flow_style=False))
     if register is True:
         docstore.register_document(
                 serialno=self.serialno,
                 docpath=os.path.join(outfolder, 'order.yaml'),
                 doctype='PRODUCTION ORDER YAML',
                 verbose=False, efield=self.title,
                 session=session
         )
Example #3
0
def generate_pcb_pricing(projfolder, noregen=True, forceregen=False):
    gpf = projfile.GedaProjectFile(projfolder)

    try:
        pcbparams = gpf.configsfile.configdata['pcbdetails']['params']
    except KeyError:
        logger.warning('Geda project does not seem have pcb details. '
                       'Not generating PCB pricing information : ' +
                       projfolder)
        return None

    try:
        if gpf.configsfile.configdata['pcbdetails']['params'][
                'panelize'] is True:
            logger.warning('Not obtaining pricing for panelized pcb : ' +
                           projfolder)
            return None
    except KeyError:
        pass

    try:
        searchparams = gpf.configsfile.configdata['pcbdetails'][
            'indicativepricing']
    except KeyError:
        searchparams = {
            'qty': 20,
            'dterm': 7,
        }

    pricingfp = os.path.join(gpf.configsfile.projectfolder, 'pcb',
                             'sourcing.yaml')

    if noregen is True:
        if os.path.exists(pricingfp):
            return pricingfp
    if forceregen is False:
        pcb_mtime = fsutils.get_file_mtime(
            os.path.join(gpf.configsfile.projectfolder, 'pcb',
                         gpf.pcbfile + '.pcb'))  # noqa
        outf_mtime = fsutils.get_file_mtime(pricingfp)
        if outf_mtime is not None and outf_mtime > pcb_mtime:
            logger.info('Skipping up-to-date ' + pricingfp)
            return pricingfp
    logger.info('Generating PCB Pricing for ' + pricingfp)

    pcbparams['qty'] = range(searchparams['qty'])
    sourcingdata = get_csil_prices(pcbparams)
    dumpdata = {'params': pcbparams, 'pricing': sourcingdata}

    with open(pricingfp, 'w') as pricingf:
        pricingf.write(yaml.dump(dumpdata))

    return pricingfp
Example #4
0
def generate_pcb_pricing(projfolder, noregen=True, forceregen=False):
    gpf = projfile.GedaProjectFile(projfolder)

    try:
        pcbparams = gpf.configsfile.configdata['pcbdetails']['params']
    except KeyError:
        logger.warning(
            'Geda project does not seem have pcb details. '
            'Not generating PCB pricing information : ' +
            projfolder)
        return None

    try:
        if gpf.configsfile.configdata['pcbdetails']['params']['panelize'] is True:
            logger.warning(
                'Not obtaining pricing for panelized pcb : ' + projfolder
            )
            return None
    except KeyError:
        pass

    try:
        searchparams = gpf.configsfile.configdata['pcbdetails']['indicativepricing']
    except KeyError:
        searchparams = {
            'qty': 20,
            'dterm': 7,
        }

    pricingfp = os.path.join(gpf.configsfile.projectfolder,
                             'pcb', 'sourcing.yaml')

    if noregen is True:
        if os.path.exists(pricingfp):
            return pricingfp
    if forceregen is False:
        pcb_mtime = fsutils.get_file_mtime(os.path.join(gpf.configsfile.projectfolder, 'pcb', gpf.pcbfile + '.pcb'))  # noqa
        outf_mtime = fsutils.get_file_mtime(pricingfp)
        if outf_mtime is not None and outf_mtime > pcb_mtime:
            logger.info('Skipping up-to-date ' + pricingfp)
            return pricingfp
    logger.info('Generating PCB Pricing for ' + pricingfp)

    pcbparams['qty'] = range(searchparams['qty'])
    sourcingdata = get_csil_prices(pcbparams)
    dumpdata = {'params': pcbparams,
                'pricing': sourcingdata}

    with open(pricingfp, 'w') as pricingf:
        pricingf.write(yaml.dump(dumpdata))

    return pricingfp
Example #5
0
 def dump_to_file(self, outfolder):
     with open(os.path.join(outfolder, 'snomap.yaml'), 'w') as f:
         self._snomap_dict['parentsno'] = self._parent_sno
         f.write(yaml.dump(self._snomap_dict, default_flow_style=False))
Example #6
0
 def dump_to_file(self, outfolder):
     with open(os.path.join(outfolder, 'snomap.yaml'), 'w') as f:
         self._snomap_dict['parentsno'] = self._parent_sno
         f.write(yaml.dump(self._snomap_dict, default_flow_style=False))