|
|
|
@ -47,13 +47,14 @@ path_cap_map = {
|
|
|
|
|
|
|
|
|
|
#TODO implement more shape types?
|
|
|
|
|
|
|
|
|
|
def build(patterns: Union[Pattern, Sequence[Pattern]],
|
|
|
|
|
def build(
|
|
|
|
|
patterns: Union[Pattern, Sequence[Pattern]],
|
|
|
|
|
units_per_micron: int,
|
|
|
|
|
layer_map: Optional[Dict[str, Union[int, Tuple[int, int]]]] = None,
|
|
|
|
|
*,
|
|
|
|
|
modify_originals: bool = False,
|
|
|
|
|
disambiguate_func: Optional[Callable[[Iterable[Pattern]], None]] = None,
|
|
|
|
|
annotations: Optional[annotations_t] = None
|
|
|
|
|
annotations: Optional[annotations_t] = None,
|
|
|
|
|
) -> fatamorgana.OasisLayout:
|
|
|
|
|
"""
|
|
|
|
|
Convert a `Pattern` or list of patterns to an OASIS stream, writing patterns
|
|
|
|
@ -153,10 +154,12 @@ def build(patterns: Union[Pattern, Sequence[Pattern]],
|
|
|
|
|
return lib
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write(patterns: Union[Sequence[Pattern], Pattern],
|
|
|
|
|
def write(
|
|
|
|
|
patterns: Union[Sequence[Pattern], Pattern],
|
|
|
|
|
stream: io.BufferedIOBase,
|
|
|
|
|
*args,
|
|
|
|
|
**kwargs):
|
|
|
|
|
**kwargs,
|
|
|
|
|
) -> None:
|
|
|
|
|
"""
|
|
|
|
|
Write a `Pattern` or list of patterns to a OASIS file. See `oasis.build()`
|
|
|
|
|
for details.
|
|
|
|
@ -171,11 +174,12 @@ def write(patterns: Union[Sequence[Pattern], Pattern],
|
|
|
|
|
lib.write(stream)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def writefile(patterns: Union[Sequence[Pattern], Pattern],
|
|
|
|
|
def writefile(
|
|
|
|
|
patterns: Union[Sequence[Pattern], Pattern],
|
|
|
|
|
filename: Union[str, pathlib.Path],
|
|
|
|
|
*args,
|
|
|
|
|
**kwargs,
|
|
|
|
|
):
|
|
|
|
|
) -> None:
|
|
|
|
|
"""
|
|
|
|
|
Wrapper for `oasis.write()` that takes a filename or path instead of a stream.
|
|
|
|
|
|
|
|
|
@ -198,7 +202,8 @@ def writefile(patterns: Union[Sequence[Pattern], Pattern],
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def readfile(filename: Union[str, pathlib.Path],
|
|
|
|
|
def readfile(
|
|
|
|
|
filename: Union[str, pathlib.Path],
|
|
|
|
|
*args,
|
|
|
|
|
**kwargs,
|
|
|
|
|
) -> Tuple[Dict[str, Pattern], Dict[str, Any]]:
|
|
|
|
@ -223,7 +228,8 @@ def readfile(filename: Union[str, pathlib.Path],
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read(stream: io.BufferedIOBase,
|
|
|
|
|
def read(
|
|
|
|
|
stream: io.BufferedIOBase,
|
|
|
|
|
clean_vertices: bool = True,
|
|
|
|
|
) -> Tuple[Dict[str, Pattern], Dict[str, Any]]:
|
|
|
|
|
"""
|
|
|
|
@ -496,7 +502,8 @@ def _placement_to_subpat(placement: fatrec.Placement, lib: fatamorgana.OasisLayo
|
|
|
|
|
return subpat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _subpatterns_to_placements(subpatterns: List[SubPattern]
|
|
|
|
|
def _subpatterns_to_placements(
|
|
|
|
|
subpatterns: List[SubPattern],
|
|
|
|
|
) -> List[fatrec.Placement]:
|
|
|
|
|
refs = []
|
|
|
|
|
for subpat in subpatterns:
|
|
|
|
@ -523,7 +530,8 @@ def _subpatterns_to_placements(subpatterns: List[SubPattern]
|
|
|
|
|
return refs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _shapes_to_elements(shapes: List[Shape],
|
|
|
|
|
def _shapes_to_elements(
|
|
|
|
|
shapes: List[Shape],
|
|
|
|
|
layer2oas: Callable[[layer_t], Tuple[int, int]],
|
|
|
|
|
) -> List[Union[fatrec.Polygon, fatrec.Path, fatrec.Circle]]:
|
|
|
|
|
# Add a Polygon record for each shape, and Path elements if necessary
|
|
|
|
@ -576,7 +584,8 @@ def _shapes_to_elements(shapes: List[Shape],
|
|
|
|
|
return elements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _labels_to_texts(labels: List[Label],
|
|
|
|
|
def _labels_to_texts(
|
|
|
|
|
labels: List[Label],
|
|
|
|
|
layer2oas: Callable[[layer_t], Tuple[int, int]],
|
|
|
|
|
) -> List[fatrec.Text]:
|
|
|
|
|
texts = []
|
|
|
|
@ -595,9 +604,10 @@ def _labels_to_texts(labels: List[Label],
|
|
|
|
|
return texts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def disambiguate_pattern_names(patterns,
|
|
|
|
|
def disambiguate_pattern_names(
|
|
|
|
|
patterns,
|
|
|
|
|
dup_warn_filter: Callable[[str], bool] = None, # If returns False, don't warn about this name
|
|
|
|
|
):
|
|
|
|
|
) -> None:
|
|
|
|
|
used_names = []
|
|
|
|
|
for pat in patterns:
|
|
|
|
|
sanitized_name = re.compile(r'[^A-Za-z0-9_\?\$]').sub('_', pat.name)
|
|
|
|
@ -625,7 +635,8 @@ def disambiguate_pattern_names(patterns,
|
|
|
|
|
used_names.append(suffixed_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def repetition_fata2masq(rep: Union[fatamorgana.GridRepetition, fatamorgana.ArbitraryRepetition, None]
|
|
|
|
|
def repetition_fata2masq(
|
|
|
|
|
rep: Union[fatamorgana.GridRepetition, fatamorgana.ArbitraryRepetition, None],
|
|
|
|
|
) -> Optional[Repetition]:
|
|
|
|
|
mrep: Optional[Repetition]
|
|
|
|
|
if isinstance(rep, fatamorgana.GridRepetition):
|
|
|
|
@ -643,7 +654,8 @@ def repetition_fata2masq(rep: Union[fatamorgana.GridRepetition, fatamorgana.Arbi
|
|
|
|
|
return mrep
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def repetition_masq2fata(rep: Optional[Repetition]
|
|
|
|
|
def repetition_masq2fata(
|
|
|
|
|
rep: Optional[Repetition],
|
|
|
|
|
) -> Tuple[Union[fatamorgana.GridRepetition,
|
|
|
|
|
fatamorgana.ArbitraryRepetition,
|
|
|
|
|
None],
|
|
|
|
@ -678,7 +690,8 @@ def annotations_to_properties(annotations: annotations_t) -> List[fatrec.Propert
|
|
|
|
|
return properties
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def properties_to_annotations(properties: List[fatrec.Property],
|
|
|
|
|
def properties_to_annotations(
|
|
|
|
|
properties: List[fatrec.Property],
|
|
|
|
|
propnames: Dict[int, NString],
|
|
|
|
|
propstrings: Dict[int, AString],
|
|
|
|
|
) -> annotations_t:
|
|
|
|
|