How to use the kicost.global_vars.logger.warning 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 / edas / generic_csv.py View on Github external
def corresponent_header_value(key, vals):
        # Get the correspondent first valid value of `vals` look from a key
        # in `header`, but using `header_file` to access `vals`. Used to get
        # the designator reference `refs` and quantity `qty`.
        idx = [i for i, x in enumerate(header) if x==key]
        value = None
        for i in idx:
            if len(idx)>1 and value!=None and value!=vals[ header_file[i] ]:
                logger.warning('Found different duplicated information for \'{}\': \'{}\'=!\'{}\'. Will be used the last.'.format(
                    key, value, vals[ header_file[i] ])
                    )
            value = vals[ header_file[i] ]
            if value:
                break
        return value
github xesscorp / KiCost / kicost / edas / generic_csv.py View on Github external
content = re.sub('\t+', '\t', content)

    # Determine the column delimiter used in the CSV file.
    try:
        dialect = csv.Sniffer().sniff(content, [',',';','\t'])
    except csv.Error:
        # If the CSV file only has a single column of data, there may be no
        # delimiter so just set the delimiter to a comma.
        dialect = csv.Sniffer().sniff(',,,', [','])

    # The first line in the file must be the column header.
    content = content.splitlines()
    logger.log(DEBUG_OVERVIEW, 'Getting CSV header...')
    header_file = next(csv.reader(content,delimiter=dialect.delimiter))
    if len(set(header_file))
github xesscorp / KiCost / kicost / edas / tools.py View on Github external
# (reference, description, ...).
            # First search for the used fields to manufacture/distributor numbers
            # and how many subparts are in them. Use the loop also to extract the
            # manufacture/distributor codes in list. Use the maximum of them.
            founded_fields = []
            subparts_qty = 0
            subparts_manf_code = dict()
            for field_code in FIELDS_MANF:
                if field_code in part:
                    subparts_qty_field = len( subpart_list(part[field_code]) )
                    subparts_qty = max(subparts_qty, subparts_qty_field) # Quantity of sub parts.
                    # Print a warning and an user tip in the case of different subpart quantities
                    # associated in different `manf#`/distributors# of the same component.
                    if subparts_qty_field!=subparts_qty:
                        problem_manf_code = (field_code if subparts_qty>subparts_qty_field else field_code_last)
                        logger.warning('Found a different subpart quantity between the code fields {c} and {lc}.\n\tYou should consider use \"{pc}={m}\" on {r} to disambiguate that.'.format(
                                        c=field_code_last, lc=field_code, r=part_ref,
                                        pc=problem_manf_code,
                                        m=';'.join(subpart_list(part[problem_manf_code])+['']*abs(subparts_qty - subparts_qty_field))
                                  ))
                    field_code_last = field_code
                    
                    founded_fields += [field_code]
                    subparts_manf_code[field_code] = subpart_list(part[field_code])
            if not founded_fields:
                split_components[part_ref] = part
                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: