From 7a38c6cd110d76c34d684d815f6e0d0e09bbd5bf Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Thu, 21 Nov 2024 14:13:46 +0100 Subject: [PATCH] Implement reading cube files from a content string (#9) --- cubehandler/cube.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cubehandler/cube.py b/cubehandler/cube.py index 96330a6..f16c31e 100644 --- a/cubehandler/cube.py +++ b/cubehandler/cube.py @@ -140,6 +140,10 @@ def from_file(cls, filepath, read_data=True): c = cls.from_file_handle(f, read_data=read_data) return c + @classmethod + def from_content(cls, content, read_data=True): + return cls.from_file_handle(io.StringIO(content), read_data=read_data) + def write_cube_file(self, filename, low_precision=False): natoms = len(self.ase_atoms)