How to use the kicost.globals.logger.isEnabledFor function in kicost

To help you get started, we’ve selected a few kicost examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xesscorp / KiCost / kicost / eda_tools / eda_tools.py View on Github external
Put the components groups in the spreadsheet rows in a spefic order
       using the reference string of the components. The order is defined
       by BOM_ORDER.
       @param components Part components in a `list()` of `dict()`, format given by the EDA modules.
       @return Same as input.
    '''

    logger.log(DEBUG_OVERVIEW, 'Sorting the groups for better visualization...')

    ref_identifiers = re.split('(?0:
            # If found more than one group with the reference, use the 'manf#'
            # as second order criterian.
            if len(component_groups_ref_match)>1:
                try:
                    for item in component_groups_ref_match:
                        component_groups_order_old.remove(item)
                except ValueError:
                    pass
github xesscorp / KiCost / kicost / eda_tools / eda_tools.py View on Github external
#considering "." and "/" marks.
            if len(re.sub('[\.\/]','',strings[0])) < len(re.sub('[\.\/]','',strings[1])):
                qty = strings[0].strip()
                part = strings[1].strip()
            else:
                qty = strings[1].strip()
                part = strings[0].strip()
        else:
            qty = '1'
            part = strings[0].strip() + strings[1].strip()
        if qty=='':
            qty = '1'
    else:
        qty = '1'
        part = ''.join(strings)
    if logger.isEnabledFor(DEBUG_OBSESSIVE):
        print('part/qty>>', subpart, '\t\tpart>>', part, '\tqty>>', qty)
    return qty, part
github xesscorp / KiCost / kicost / eda_tools / eda_tools.py View on Github external
continue # If not manf/distributor code pass to next.
            # Divide the `manf` manufacture name.
            try:
                subparts_manf = subpart_list(part['manf'])
                if len(subparts_manf)!=subparts_qty:
                    if len(subparts_manf)==1:
                        # If just one `manf`assumes that is for all.
                        subparts_manf = [subparts_manf[0]]*subparts_qty
                    else:
                        # Exception `manf` and `manf#` length doesn't macth, fill with '' at the end.
                        subparts_manf.extend(['']*(subparts_qty-len(subparts_manf)))
            except KeyError:
                subparts_manf = ['']*subparts_qty
                pass

            if logger.isEnabledFor(DEBUG_DETAILED):
                print(part_ref, '>>', founded_fields)

            # Second, if more than one subpart, split the sub parts as
            # new components with the same description, footprint, and
            # so on... Get the subpart.
            if subparts_qty>1:
                # Remove the actual part from the list.
                part_actual = part
                part_actual_value = part_actual['value']
                subpart_part = ''
                subpart_qty = ''
                # Add the splited subparts.
                for subparts_index in range(subparts_qty):
                    # Create a sub component based on the main component with
                    # the subparts. Modify the designator and the part. Create
                    # a sub quantity field.
github xesscorp / KiCost / kicost / eda_tools / eda_tools.py View on Github external
'''@brief Take the components grouped quantity.
       
       Calculate the string of the quantity of the group parsing the
       referente (design) quantity and the sub quantity (in case that
       was a sub part of a manufacture/distributor code).
       In the case of the multifiles BOM (and futere revision of the
       code) just use the 'manf#_qty' field that in `group_parts()`
       recorded the quantities used in each project.
       
       @param components Part component `dict()`, format given by the EDA modules.
       @return Quantity of the manf# part used.
    '''
    try:
        qty = component.fields.get('manf#_qty')

        if logger.isEnabledFor(DEBUG_OBSESSIVE):
            print('Qty>>',component.refs,'>>', qty, '*',
                    component.fields.get('manf#'))

        if isinstance(qty, list):
            # Multifiles BOM case, the quantities in the list represent
            # each project read by the order. Do not `CEILING` because
            # this is will be made in the total columns that sum all
            # the quantities needed in all projects BOMs.
            string = ['={{}}*({qp})'.format(qp=i) for i in qty]
        else:
            if qty != '1' and qty != None:
                string = '=CEILING({{}}*({q})*{qty},1)'.format(
                                q=qty,
                                qty=len(component.refs))
            else:
                string = '={{}}*{qty}'.format(qty=len(component.refs))
github xesscorp / KiCost / kicost / eda_tools / eda_tools.py View on Github external
# part, do not add.
                        # e.g. U1:{'manf#':'PARTG1;PARTG2;PARTG3', 'mouser#''PARTM1;PARTM2'}
                        # result:
                        # U1.1:{'manf#':'PARTG1', 'mouser#':'PARTM1'}
                        # U1.2:{'manf#':'PARTG2', 'mouser#':'PARTM2'}
                        # U1.3:{'manf#':'PARTG3'}
                        try:
                            p_manf_code = subparts_manf_code[field_manf_dist_code][subparts_index]
                            subpart_actual['value'] = '{v} - p{idx}/{total}'.format(
                                            v=part_actual_value,
                                            idx=subparts_index+1,
                                            total=subparts_qty)
                            subpart_qty, subpart_part = manf_code_qtypart(p_manf_code)
                            subpart_actual[field_manf_dist_code] = subpart_part
                            subpart_actual[field_manf_dist_code+'_qty'] = subpart_qty
                            if logger.isEnabledFor(DEBUG_OBSESSIVE):
                                print(subpart_actual)
                        except IndexError:
                            pass
                    # Update the splitted `manf`(manufactures names).
                    if subparts_manf[subparts_index]!=REPLICATE_MANF:
                        # If the actual manufacture name is the defined as `REPLICATE_MANF`
                        # replicate the last one.
                        p_manf = subparts_manf[subparts_index]
                    subpart_actual['manf'] = p_manf
                    # Update the description and reference of the part.
                    ref = part_ref + SUB_SEPRTR + str(subparts_index + 1)
                    splitted_components[ref] = subpart_actual
            else:
                part_actual = part.copy()
                for field_manf_dist_code in founded_fields:
                    # When one "single subpart" also use the logic of quantity.
github xesscorp / KiCost / kicost / eda_tools / eda_tools.py View on Github external
# replicate the last one.
                        p_manf = subparts_manf[subparts_index]
                    subpart_actual['manf'] = p_manf
                    # Update the description and reference of the part.
                    ref = part_ref + SUB_SEPRTR + str(subparts_index + 1)
                    splitted_components[ref] = subpart_actual
            else:
                part_actual = part.copy()
                for field_manf_dist_code in founded_fields:
                    # When one "single subpart" also use the logic of quantity.
                    try:
                        p_manf_code = subparts_manf_code[field_manf_dist_code][0]
                        part_qty, part_part = manf_code_qtypart(p_manf_code)
                        part_actual[field_manf_dist_code] = part_part
                        part_actual[field_manf_dist_code+'_qty'] = part_qty
                        if logger.isEnabledFor(DEBUG_OBSESSIVE):
                            print(part)
                        splitted_components[part_ref] = part_actual
                    except IndexError:
                        pass
        except KeyError:
            continue

    return splitted_components