summaryrefslogtreecommitdiff
path: root/gerbonara/cam.py
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2022-06-18 23:50:43 +0200
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2022-06-18 23:50:43 +0200
commitfa7a526883bdd35aca780b653af96169fd843aa8 (patch)
treeec4bce189881b81a209bf0e1778fe83a065b18b0 /gerbonara/cam.py
parent6833bf8657d038415cfb08091c85327e3a6d6154 (diff)
downloadgerbonara-fa7a526883bdd35aca780b653af96169fd843aa8.tar.gz
gerbonara-fa7a526883bdd35aca780b653af96169fd843aa8.tar.bz2
gerbonara-fa7a526883bdd35aca780b653af96169fd843aa8.zip
Add CachedLazyCamFile
Diffstat (limited to 'gerbonara/cam.py')
-rw-r--r--gerbonara/cam.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/gerbonara/cam.py b/gerbonara/cam.py
index 2cc57ba..fb69e5c 100644
--- a/gerbonara/cam.py
+++ b/gerbonara/cam.py
@@ -416,3 +416,23 @@ class LazyCamFile:
""" Copy this Gerber file to the new path. """
shutil.copy(self.original_path, filename)
+class CachedLazyCamFile:
+ def __init__(self, klass, data, original_path, *args, **kwargs):
+ self._class = klass
+ self._data = data
+ self.original_path = original_path
+ self._args = args
+ self._kwargs = kwargs
+
+ @cached_property
+ def instance(self):
+ return self._class.from_string(self._data, filename=self.original_path, *self._args, **self._kwargs)
+
+ @property
+ def is_lazy(self):
+ return True
+
+ def save(self, filename, *args, **kwargs):
+ """ Copy this Gerber file to the new path. """
+ Path(filename).write_text(self._data)
+