Swoop Utilities

Swoop provides a collection of utility classes and functions for working with Eagle files built on Swoop that we have built for our own use. They also serve as longer examples of how to use Swoop to do useful things to Eagle files.

ScanLayerVisitor

class Swoop.tools.ScanLayersVisitor(efp)[source]

Bases: Swoop.Swoop.EagleFilePartVisitor

A visitor to scan the file for all EagleFilePart objects a layer attribute and collected the names of all layers that are used somewhere in the file.

getDefinedLayers()[source]

Get a list of all the layers defined in the file.

Return type:List of str
getUnusedLayers()[source]

Get a list containing the names of unused layers.

Return type:List of str
getUsedLayers()[source]

Get a list of the names of layers used in the file.

Return type:List of str

ScanLibraryReferences

class Swoop.tools.ScanLibraryReferences(efp)[source]

Bases: Swoop.Swoop.EagleFilePartVisitor

A visitor to scan an EagleFile object and identify all the library components (Libraries, Symbols, Packages, Devicesets, and Devices) that are referenced in the file.

get_referenced_efps()[source]

Return a list of all the library components that are used.

Return type:List of EagleFilePart

mergeLayers

Swoop.tools.mergeLayers(src, dst, force=False)[source]

Merge layers from the EagleFile src into EagleFile dst. If there is some conflict between the two (different names for the same layer number or vice versa), then raise an exception (unless force == True)

Parameters:
  • src – The EagleFile to update.
  • dst – The EagleFile to draw layers from.
  • force – If True overwrite the layers. Otherwise, throw an SwoopError on conflict.

normalizeLayers

Swoop.tools.normalizeLayers(ef, layers, force=False)[source]

Clean up layers in a file. First, remove all unused layers, then merge in the layers from EagleFile object layers. If force == True, overwrite layers in ef with the layers even if there is a conflict.

Parameters:
  • ef – The EagleFile to update.
  • layers – The EagleFile to draw layers from.
  • force – If True overwrite the layers. Otherwise, throw an SwoopError on conflict.

rebuildBoardConnections

Swoop.tools.rebuildBoardConnections(sch, brd)[source]

Update the signals in brd to match the nets in sch. This will set up the connections, but won’t draw the air wires. You can use Eagle’s ripup command to rebuild those.

Parameters:
  • schSchematicFile object and source of the connection information.
  • brdBoardFile destination for then connection information.
Return type:

None

propagatePartToBoard

Swoop.tools.propagatePartToBoard(part, brd)[source]

Copy part to brd by creating a new Element and populating it accordingly. If the part already exists, it will be replaced.

Note

This function doesn’t update the board’s signals. You can run rebuildBoardConnections() to do that.

Parameters:
  • partPart object that to propagate.
  • brd – Destination :class`BoardFile`.
Return type:

None

removeDeadEFPs

Swoop.tools.CleanupEagle.removeDeadEFPs(ef)[source]

Remove all the unused items (symbols, packages, devices, and devicesets) from an eagle file.

Depending on the file type “unused” means different things:

  • For schematics: Any symbols, devices, packages, or devicesets that are not used in the schematic will be removed.
  • For boards: Any packages not used in the board will be removed.
  • For libraries: Any symbols or packages not mentioned in any deviceset or device will be removed.
Parameters:efpEagleFile to cleanse
Returns:self
Return type:EagleFile