redo library class naming
This commit is contained in:
parent
a07446808a
commit
f0a71bfb8b
13 changed files with 78 additions and 78 deletions
|
|
@ -18,7 +18,7 @@ from ezdxf.enums import TextEntityAlignment
|
|||
|
||||
from .utils import is_gzipped, tmpfile
|
||||
from .. import Pattern, Ref, PatternError, Label
|
||||
from ..library import Library, WrapROLibrary, WrapLibrary
|
||||
from ..library import ILibraryView, LibraryView, Library
|
||||
from ..shapes import Shape, Polygon, Path
|
||||
from ..repetition import Grid
|
||||
from ..utils import rotation_matrix_2d, layer_t
|
||||
|
|
@ -75,9 +75,9 @@ def write(
|
|||
#TODO consider supporting DXF arcs?
|
||||
if not isinstance(library, Library):
|
||||
if isinstance(library, dict):
|
||||
library = WrapROLibrary(library)
|
||||
library = LibraryView(library)
|
||||
else:
|
||||
library = WrapROLibrary(dict(library))
|
||||
library = LibraryView(dict(library))
|
||||
|
||||
pattern = library[top_name]
|
||||
subtree = library.subtree(top_name)
|
||||
|
|
@ -148,7 +148,7 @@ def readfile(
|
|||
filename: str | pathlib.Path,
|
||||
*args,
|
||||
**kwargs,
|
||||
) -> tuple[WrapLibrary, dict[str, Any]]:
|
||||
) -> tuple[Library, dict[str, Any]]:
|
||||
"""
|
||||
Wrapper for `dxf.read()` that takes a filename or path instead of a stream.
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ def readfile(
|
|||
|
||||
def read(
|
||||
stream: TextIO,
|
||||
) -> tuple[WrapLibrary, dict[str, Any]]:
|
||||
) -> tuple[Library, dict[str, Any]]:
|
||||
"""
|
||||
Read a dxf file and translate it into a dict of `Pattern` objects. DXF `Block`s are
|
||||
translated into `Pattern` objects; `LWPolyline`s are translated into polygons, and `Insert`s
|
||||
|
|
@ -190,7 +190,7 @@ def read(
|
|||
msp = lib.modelspace()
|
||||
|
||||
top_name, top_pat = _read_block(msp)
|
||||
mlib = WrapLibrary({top_name: top_pat})
|
||||
mlib = Library({top_name: top_pat})
|
||||
for bb in lib.blocks:
|
||||
if bb.name == '*Model_Space':
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ from .. import Pattern, Ref, PatternError, LibraryError, Label, Shape
|
|||
from ..shapes import Polygon, Path
|
||||
from ..repetition import Grid
|
||||
from ..utils import layer_t, normalize_mirror, annotations_t
|
||||
from ..library import LazyLibrary, WrapLibrary, MutableLibrary, Library
|
||||
from ..library import LazyLibrary, Library, ILibrary, ILibraryView
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -97,11 +97,11 @@ def write(
|
|||
library_name: Library name written into the GDSII file.
|
||||
Default 'masque-klamath'.
|
||||
"""
|
||||
if not isinstance(library, MutableLibrary):
|
||||
if not isinstance(library, ILibrary):
|
||||
if isinstance(library, dict):
|
||||
library = WrapLibrary(library)
|
||||
library = Library(library)
|
||||
else:
|
||||
library = WrapLibrary(dict(library))
|
||||
library = Library(dict(library))
|
||||
|
||||
# Create library
|
||||
header = klamath.library.FileHeader(
|
||||
|
|
@ -160,7 +160,7 @@ def readfile(
|
|||
filename: str | pathlib.Path,
|
||||
*args,
|
||||
**kwargs,
|
||||
) -> tuple[WrapLibrary, dict[str, Any]]:
|
||||
) -> tuple[Library, dict[str, Any]]:
|
||||
"""
|
||||
Wrapper for `read()` that takes a filename or path instead of a stream.
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ def readfile(
|
|||
def read(
|
||||
stream: IO[bytes],
|
||||
raw_mode: bool = True,
|
||||
) -> tuple[WrapLibrary, dict[str, Any]]:
|
||||
) -> tuple[Library, dict[str, Any]]:
|
||||
"""
|
||||
# TODO check GDSII file for cycles!
|
||||
Read a gdsii file and translate it into a dict of Pattern objects. GDSII structures are
|
||||
|
|
@ -208,7 +208,7 @@ def read(
|
|||
"""
|
||||
library_info = _read_header(stream)
|
||||
|
||||
mlib = WrapLibrary()
|
||||
mlib = Library()
|
||||
found_struct = records.BGNSTR.skip_past(stream)
|
||||
while found_struct:
|
||||
name = records.STRNAME.skip_and_read(stream)
|
||||
|
|
@ -511,7 +511,7 @@ def load_library(
|
|||
stream: IO[bytes],
|
||||
*,
|
||||
full_load: bool = False,
|
||||
postprocess: Callable[[Library, str, Pattern], Pattern] | None = None
|
||||
postprocess: Callable[[ILibraryView, str, Pattern], Pattern] | None = None
|
||||
) -> tuple[LazyLibrary, dict[str, Any]]:
|
||||
"""
|
||||
Scan a GDSII stream to determine what structures are present, and create
|
||||
|
|
@ -571,7 +571,7 @@ def load_libraryfile(
|
|||
*,
|
||||
use_mmap: bool = True,
|
||||
full_load: bool = False,
|
||||
postprocess: Callable[[Library, str, Pattern], Pattern] | None = None
|
||||
postprocess: Callable[[ILibraryView, str, Pattern], Pattern] | None = None
|
||||
) -> tuple[LazyLibrary, dict[str, Any]]:
|
||||
"""
|
||||
Wrapper for `load_library()` that takes a filename or path instead of a stream.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from fatamorgana.basic import PathExtensionScheme, AString, NString, PropStringR
|
|||
|
||||
from .utils import is_gzipped, tmpfile
|
||||
from .. import Pattern, Ref, PatternError, LibraryError, Label, Shape
|
||||
from ..library import WrapLibrary, MutableLibrary
|
||||
from ..library import Library, ILibrary
|
||||
from ..shapes import Polygon, Path, Circle
|
||||
from ..repetition import Grid, Arbitrary, Repetition
|
||||
from ..utils import layer_t, normalize_mirror, annotations_t
|
||||
|
|
@ -98,11 +98,11 @@ def build(
|
|||
Returns:
|
||||
`fatamorgana.OasisLayout`
|
||||
"""
|
||||
if not isinstance(library, MutableLibrary):
|
||||
if not isinstance(library, ILibrary):
|
||||
if isinstance(library, dict):
|
||||
library = WrapLibrary(library)
|
||||
library = Library(library)
|
||||
else:
|
||||
library = WrapLibrary(dict(library))
|
||||
library = Library(dict(library))
|
||||
|
||||
if layer_map is None:
|
||||
layer_map = {}
|
||||
|
|
@ -205,7 +205,7 @@ def readfile(
|
|||
filename: str | pathlib.Path,
|
||||
*args,
|
||||
**kwargs,
|
||||
) -> tuple[WrapLibrary, dict[str, Any]]:
|
||||
) -> tuple[Library, dict[str, Any]]:
|
||||
"""
|
||||
Wrapper for `oasis.read()` that takes a filename or path instead of a stream.
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ def readfile(
|
|||
|
||||
def read(
|
||||
stream: IO[bytes],
|
||||
) -> tuple[WrapLibrary, dict[str, Any]]:
|
||||
) -> tuple[Library, dict[str, Any]]:
|
||||
"""
|
||||
Read a OASIS file and translate it into a dict of Pattern objects. OASIS cells are
|
||||
translated into Pattern objects; Polygons are translated into polygons, and Placements
|
||||
|
|
@ -260,7 +260,7 @@ def read(
|
|||
layer_map[str(layer_name.nstring)] = layer_name
|
||||
library_info['layer_map'] = layer_map
|
||||
|
||||
mlib = WrapLibrary()
|
||||
mlib = Library()
|
||||
for cell in lib.cells:
|
||||
if isinstance(cell.name, int):
|
||||
cell_name = lib.cellnames[cell.name].nstring.string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue