misc fixes

This commit is contained in:
Jan Petykiewicz 2023-02-07 14:24:34 -08:00
parent d079b44883
commit cca6b90830
3 changed files with 7 additions and 4 deletions

View File

@ -345,6 +345,7 @@ class FlatBuilder(PortList):
other_copy.mirror2d(mirrored) other_copy.mirror2d(mirrored)
other_copy.rotate_around(pivot, rotation) other_copy.rotate_around(pivot, rotation)
other_copy.translate_elements(offset) other_copy.translate_elements(offset)
other_copy.ports.clear()
self.pattern.append(other_copy) self.pattern.append(other_copy)
return self return self

View File

@ -44,7 +44,7 @@ def _rename_patterns(lib: 'Library', name: str) -> str:
return name return name
stem = name.split('$')[0] stem = name.split('$')[0]
return lib.get_name(stem) return lib.get_name(stem)
class Library(Mapping[str, 'Pattern'], metaclass=ABCMeta): class Library(Mapping[str, 'Pattern'], metaclass=ABCMeta):
@ -493,7 +493,7 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
Returns: Returns:
(name, pattern) tuple (name, pattern) tuple
""" """
from .pattern import Pattern from .pattern import NamedPattern
#name = self.get_name(base_name) #name = self.get_name(base_name)
npat = NamedPattern(name) npat = NamedPattern(name)
self[name] = npat self[name] = npat
@ -550,7 +550,7 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
if internal_conflicts: if internal_conflicts:
raise LibraryError('Renamed patterns conflict with un-renamed names in `other`' + pformat(internal_conflicts)) raise LibraryError('Renamed patterns conflict with un-renamed names in `other`' + pformat(internal_conflicts))
conflicts = set(self.keys()) & renamed conflicts = set(self.keys()) & set(rename_map.values())
if conflicts: if conflicts:
raise LibraryError('Unresolved duplicate keys encountered in library merge: ' + pformat(conflicts)) raise LibraryError('Unresolved duplicate keys encountered in library merge: ' + pformat(conflicts))
@ -559,6 +559,8 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
for old_name, new_name in rename_map.items(): for old_name, new_name in rename_map.items():
temp.rename(old_name, new_name, move_references=True) temp.rename(old_name, new_name, move_references=True)
for key in temp.keys():
self._merge(key, temp, key)
else: else:
for key in other.keys(): for key in other.keys():
@ -592,6 +594,7 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
name = tree.top name = tree.top
else: else:
tree.library.rename(tree.top, name, move_references=True) tree.library.rename(tree.top, name, move_references=True)
tree.top = name
self.add(tree.library, rename_theirs=rename_theirs) self.add(tree.library, rename_theirs=rename_theirs)
return name return name

View File

@ -83,7 +83,6 @@ def data_to_ports(
Returns: Returns:
The updated `pattern`. Port labels are not removed. The updated `pattern`. Port labels are not removed.
""" """
print(f'TODO pat2dev {name}')
if pattern.ports: if pattern.ports:
logger.warning(f'Pattern {name if name else pattern} already had ports, skipping data_to_ports') logger.warning(f'Pattern {name if name else pattern} already had ports, skipping data_to_ports')
return pattern return pattern