CODEX revised with following function: 1. GDS building, 2. different user group with different authority.
This commit is contained in:
+18
-11
@@ -16,8 +16,9 @@ class PdkAsset:
|
||||
class PdkRegistry:
|
||||
"""Resolve public PDK component names to metadata and public GDS assets."""
|
||||
|
||||
def __init__(self, public_root: str):
|
||||
def __init__(self, public_root: str, prefer_full_gds: bool = False):
|
||||
self.public_root = os.path.abspath(public_root)
|
||||
self.prefer_full_gds = prefer_full_gds
|
||||
self._asset_cache = {}
|
||||
|
||||
def resolve(self, component: str) -> PdkAsset:
|
||||
@@ -60,20 +61,26 @@ class PdkRegistry:
|
||||
def _find_gds(self, key: str, yaml_path: Optional[str]) -> Optional[str]:
|
||||
search_dir = os.path.dirname(yaml_path) if yaml_path else os.path.join(self.public_root, *key.split("/"))
|
||||
name = key.split("/")[-1]
|
||||
candidates = [
|
||||
os.path.join(search_dir, f"{name}_BB.gds"),
|
||||
os.path.join(search_dir, f"{name}.gds"),
|
||||
]
|
||||
if self.prefer_full_gds:
|
||||
candidates = [
|
||||
os.path.join(search_dir, f"{name}.gds"),
|
||||
os.path.join(search_dir, f"{name}_BB.gds"),
|
||||
]
|
||||
else:
|
||||
candidates = [
|
||||
os.path.join(search_dir, f"{name}_BB.gds"),
|
||||
os.path.join(search_dir, f"{name}.gds"),
|
||||
]
|
||||
for candidate in candidates:
|
||||
if self._inside_root(candidate) and os.path.exists(candidate):
|
||||
return os.path.abspath(candidate)
|
||||
if os.path.isdir(search_dir):
|
||||
for filename in sorted(os.listdir(search_dir)):
|
||||
if filename.lower().endswith("_bb.gds"):
|
||||
return os.path.join(search_dir, filename)
|
||||
for filename in sorted(os.listdir(search_dir)):
|
||||
if filename.lower().endswith(".gds"):
|
||||
return os.path.join(search_dir, filename)
|
||||
gds_files = sorted(filename for filename in os.listdir(search_dir) if filename.lower().endswith(".gds"))
|
||||
full_files = [filename for filename in gds_files if not filename.lower().endswith("_bb.gds")]
|
||||
bb_files = [filename for filename in gds_files if filename.lower().endswith("_bb.gds")]
|
||||
ordered = (full_files + bb_files) if self.prefer_full_gds else (bb_files + full_files)
|
||||
if ordered:
|
||||
return os.path.join(search_dir, ordered[0])
|
||||
return None
|
||||
|
||||
def _load_yaml(self, yaml_path: Optional[str]) -> Optional[dict]:
|
||||
|
||||
Reference in New Issue
Block a user