EagleFile Base Class¶
Swoop provides one class for each of the three Eagle file types:
EagleBoard
, EagleSchematic
, and EagleLibrary
. Each
of them are subclasses of the EagleFile
base class. The base class
provides functions for parsing, verifying, and writing Eagle files.
Swoop and the Eagle File Format¶
Swoop has two goals in terms of conformance to the Eagle file format. The first is that Swoop should be able to read any Eagle file produced by a version of Eagle it supports (currently 6.5-7.2), by Swoop, or by a combination of the two.
Second, Swoop should only output files that conform to a modified version of
the DTD. This modified DTD is provided with the Swoop distribution. It is
based on the DTD that ships with Eagle, but it includes changes to accomodate
files that we observe Eagle to produce in practice. You can see the changes we
have made by looking at eagle.dtd.diff
in the source distribution of Swoop.
Swoop also aspires to produce output that specifies a valid Eagle schematic,
library, or board. This is challenging, since CadSoft doesn’t publish a
detailed specification of the file format’s semantics (the DTD just specifies
its syntax). By default, EagleFile
performs a set of sanity checks
before writing out the file. If you find that a file produced by Swoop (with
the sanity checks enabled) produces error when loaded by Eagle, please consider
filing a bug report.
EagleFile¶
-
class
Swoop.
EagleFile
[source]¶ Bases:
Swoop.Swoop.EagleFilePart
Base class for Eagle files. It handle opening, parsing, validation, associated errors, writing output, and the mapping between layer numbers and layer names.
This class also serves a factory class for
EagleFilePart
objects. Calling thenew_*()
methods on anEagleFile
, yields new objects that include any Swoop extensions that have been applied.-
add_layer
(layer)[source]¶ Add a layer to this file.
Parameters: layer – The Layer
to add.Return type: None
-
find_library_by_name
(l)[source]¶ Lookup a library by name and return it.
Parameters: l – Library name. Return type: Library
orNone
if the library is not present.
-
classmethod
from_file
(filename, bestEffort=True)[source]¶ Loads a Eagle file from a .sch, .lbr, or .brd file. A synonym for
EagleFile.open()
Parameters: - filename – Filename to load.
- bestEffort – If
True
, load the file even if it doesn’t conform to the DTD.
Returns: A new
BoardFile
,LibraryFile
, orSchematicFile
object
-
get_layers
()[source]¶ Get a map of names to Layer objects
Return type: Map of EagleFilePart
objects keyed by layer name.
-
get_layersByNumber
()[source]¶ Get a map of numbers to Layer objects.
Return type: Map of EagleFilePart
objects keyed by layer number.
-
classmethod
open
(filename, bestEffort=True)[source]¶ Loads a Eagle file from a .sch, .lbr, or .brd file. A synonym for
EagleFile.from_file()
Parameters: - filename – Filename to load.
- bestEffort – If
True
, load the file even if it doesn’t conform to the DTD.
Returns: A new
BoardFile
,LibraryFile
, orSchematicFile
object
-
remove_layer
(layer)[source]¶ Remove a layer.
Parameters: layer – Layer
object, layer name, or layer number that should be deleted.Return type: None
-