How to use the skidl.logger.logger.warning function in skidl

To help you get started, we’ve selected a few skidl 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 / skidl / skidl / Net.py View on Github external
return nets[1]
                if fixed0 and fixed1:
                    log_and_raise(
                        logger,
                        ValueError,
                        "Cannot merge two nets with fixed names: {} and {}.".format(
                            name0, name1
                        ),
                    )
                if nets[1].is_implicit():

                    return nets[0]
                if nets[0].is_implicit():
                    return nets[1]
                if name0 != name1:
                    logger.warning(
                        "Merging two named nets ({name0} and {name1}) into {name0}.".format(
                            **locals()
                        )
                    )
                return nets[0]

            # More than two nets, so bisect the list into two smaller lists and
            # recursively find the best name from each list and then return the
            # best name of those two.
            mid_point = len(nets) // 2
            return select_name(
                [select_name(nets[0:mid_point]), select_name(nets[mid_point:])]
            )
github xesscorp / skidl / skidl / part_query.py View on Github external
"""Make a list out of whatever is given."""
        if isinstance(l, (list, tuple)):
            return l
        if not l:
            return []
        return [l]

    # Gather all the lib files from all the directories in the search paths.
    lib_files = list()
    for lib_dir in skidl.lib_search_paths[tool]:

        # Get all the library files in the search path.
        try:
            files = os.listdir(lib_dir)
        except (FileNotFoundError, OSError):
            logger.warning("Could not open directory '{}'".format(lib_dir))
            files = []

        files = [(lib_dir, l) for l in files if l.endswith(skidl.lib_suffixes[tool])]
        lib_files.extend(files)

    num_lib_files = len(lib_files)

    # Now search through the lib files for parts that match the search terms.
    for idx, (lib_dir, lib_file) in enumerate(lib_files):

        # If just entered a new lib file, yield the name of the file and
        # where it is within the total number of files to search.
        # (This is used for progress indicators.)
        yield "LIB", lib_file, idx + 1, num_lib_files

        # Parse the lib file to create a part library.
github xesscorp / skidl / skidl / Circuit.py View on Github external
def rmv_nets(self, *nets):
        """Remove some Net objects from the circuit."""
        for net in nets:
            if net.is_movable():
                if net.circuit == self and net in self.nets:
                    net.circuit = None
                    net.hierarchy = None
                    self.nets.remove(net)
                else:
                    logger.warning(
                        "Removing non-existent net {} from this circuit.".format(
                            net.name
                        )
                    )
            else:
                log_and_raise(
                    logger,
                    ValueError,
                    "Can't remove unmovable net {} from this circuit.".format(net.name),
                )
github xesscorp / skidl / skidl / Circuit.py View on Github external
def rmv_parts(self, *parts):
        """Remove some Part objects from the circuit."""
        for part in parts:
            if part.is_movable():
                if part.circuit == self and part in self.parts:
                    part.circuit = None
                    part.hierarchy = None
                    self.parts.remove(part)
                else:
                    logger.warning(
                        "Removing non-existent part {} from this circuit.".format(
                            part.ref
                        )
                    )
            else:
                log_and_raise(
                    logger,
                    ValueError,
                    "Can't remove part {} from this circuit.".format(part.ref),
                )
github xesscorp / skidl / skidl / netclass.py View on Github external
def __init__(self, name, **attribs):

        # This object will belong to the default Circuit object or the one
        # that's passed as a parameter.
        circuit = attribs.pop("circuit", builtins.default_circuit)

        # Assign net class name.
        self.name = name

        # Assign the other attributes to this object.
        for k, v in list(attribs.items()):
            setattr(self, k, v)

        # Is this net class already defined?
        if circuit.netclasses.get(name) is not None:
            logger.warning(
                "Cannot redefine existing net class {name}!".format(**locals())
            )
        else:
            circuit.netclasses[name] = self
github xesscorp / skidl / skidl / skidl.py View on Github external
###############################################################################
# Globals that are used by everything else.
###############################################################################

# Get SKiDL configuration.
skidl_cfg = SkidlCfg("/etc", "~", ".")

# If no configuration files were found, set some default lib search paths.
if "lib_search_paths" not in skidl_cfg:
    skidl_cfg["lib_search_paths"] = {KICAD: ["."], SKIDL: ["."], SPICE: ["."]}

    # Add the location of the default KiCad part libraries.
    try:
        skidl_cfg["lib_search_paths"][KICAD].append(os.environ["KICAD_SYMBOL_DIR"])
    except KeyError:
        logger.warning(
            "KICAD_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched."
        )

    # Add the location of the default SKiDL part libraries.
    default_skidl_libs = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), "libs"
    )
    skidl_cfg["lib_search_paths"][SKIDL].append(default_skidl_libs)

# Shortcut to library search paths.
lib_search_paths = skidl_cfg["lib_search_paths"]

# If no configuration files were found, set some default footprint search paths.
if "footprint_search_paths" not in skidl_cfg:
    dir_ = get_kicad_lib_tbl_dir()
    skidl_cfg["footprint_search_paths"] = {KICAD: [dir_], SKIDL: [dir_], SPICE: [dir_]}
github xesscorp / skidl / skidl / Net.py View on Github external
pn += self
            elif isinstance(pn, Net):
                if pn.circuit == self.circuit:
                    merge(pn)
                else:
                    log_and_raise(
                        logger,
                        ValueError,
                        "Can't attach nets in different circuits ({}, {})!".format(
                            pn.circuit.name, self.circuit.name
                        ),
                    )
            elif isinstance(pn, Pin):
                if not pn.part or pn.part.circuit == self.circuit:
                    if not pn.part:
                        logger.warning(
                            "Attaching non-part Pin {} to a Net {}.".format(
                                pn.name, self.name
                            )
                        )
                    connect_pin(pn)
                else:
                    log_and_raise(
                        logger,
                        ValueError,
                        "Can't attach a part to a net in different circuits ({}, {})!".format(
                            pn.part.circuit.name, self.circuit.name
                        ),
                    )
            else:
                log_and_raise(
                    logger,
github xesscorp / skidl / skidl / Circuit.py View on Github external
def rmv_buses(self, *buses):
        """Remove some buses from the circuit."""
        for bus in buses:
            if bus.is_movable():
                if bus.circuit == self and bus in self.buses:
                    bus.circuit = None
                    bus.hierarchy = None
                    self.buses.remove(bus)
                    for net in bus.nets:
                        self -= net
                else:
                    logger.warning(
                        "Removing non-existent bus {} from this circuit.".format(
                            bus.name
                        )
                    )
            else:
                log_and_raise(
                    logger,
                    ValueError,
                    "Can't remove unmovable bus {} from this circuit.".format(bus.name),
                )