MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / save

Method save

SLiCAP/SLiCAPprotos.py:683–731  ·  view source on GitHub ↗

Saves the snippet. If the path is absolute, it saves it in that location. Otherwise, the preffix and suffix are added according to format: - latex - prefix: project folder -> SLiCAP.ini -> [projectpaths] -> tex_snippets - su

(self, filenameOrPath: str | Path)

Source from the content-addressed store, hash-verified

681 return f'Snippet("{self.snippet}", format="{self.format}")'
682
683 def save(self, filenameOrPath: str | Path):
684 """
685 Saves the snippet.
686
687 If the path is absolute, it saves it in that location.
688 Otherwise, the preffix and suffix are added according to format:
689
690 - latex
691
692 - prefix: project folder -> SLiCAP.ini -> [projectpaths] -> tex_snippets
693 - suffix: '.tex'
694
695 - rst
696
697 - prefix: project folder -> SLiCAP.ini -> [projectpaths] -> rst_snippets
698 - suffix: '.rst'
699 - expressions and inline equations are appended to the file as:
700
701 \\|<variable name>\\| = <expr>\\|<inline equation>
702
703 - myst
704
705 - prefix: project folder -> SLiCAP.ini -> [projectpaths] -> myst_snippets
706 - suffix: '.md'
707
708 - html
709
710 - prefix: project folder -> SLiCAP.ini -> [projectpaths] -> html_snippets
711 - suffix: &#x27;.html
712
713 - md
714
715 - prefix: project folder -> SLiCAP.ini -> [projectpaths] -> md_snippets
716 - suffix: '.md'
717
718 """
719 if self.snippet != None:
720 if not filenameOrPath:
721 raise ValueError("No filename given to save snippet.")
722 if self.mode.lower() not in ["a", "w"]:
723 raise ValueError("Mode must be 'a' or 'w'.")
724 if isinstance(filenameOrPath, Path):
725 filenameOrPath = str(filenameOrPath)
726 if os.path.isabs(filenameOrPath):
727 filePath = filenameOrPath
728 else:
729 filePath = self._prefix + filenameOrPath + self._suffix
730 with open(filePath, self.mode) as f:
731 f.write(self.snippet)
732
733class _BaseFormatter:
734 """

Callers 14

parameters.pyFile · 0.45
matrix.pyFile · 0.45
laplace.pyFile · 0.45
models.pyFile · 0.45
ngspice.pyFile · 0.45
noise.pyFile · 0.45
sphinx_report.pyFile · 0.45
ttime.pyFile · 0.45
balanced.pyFile · 0.45
specifications.pyFile · 0.45
feedback.pyFile · 0.45
dcvar.pyFile · 0.45

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected