Skip to content

Commit fda1705

Browse files
committed
fix: expose moved format helper modules
1 parent 8393ecf commit fda1705

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

dpdata/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from __future__ import annotations
22

3+
from importlib import import_module
4+
from typing import TYPE_CHECKING
5+
36
from .bond_order_system import BondOrderSystem
47
from .formats import lammps, md, vasp
58
from .system import LabeledSystem, MultiSystems, System
@@ -9,10 +12,27 @@
912
except ImportError:
1013
from .__about__ import __version__
1114

15+
if TYPE_CHECKING:
16+
from . import cp2k, gaussian, qe
17+
18+
_FORMAT_MODULES = {"cp2k", "gaussian", "qe"}
19+
20+
21+
def __getattr__(name: str):
22+
if name in _FORMAT_MODULES:
23+
module = import_module(f"dpdata.formats.{name}")
24+
globals()[name] = module
25+
return module
26+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
27+
28+
1229
__all__ = [
1330
"__version__",
31+
"cp2k",
32+
"gaussian",
1433
"lammps",
1534
"md",
35+
"qe",
1636
"vasp",
1737
"System",
1838
"LabeledSystem",

dpdata/formats/cp2k/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import annotations
2+
3+
from . import cell, output
4+
5+
__all__ = ["cell", "output"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import annotations
2+
3+
from . import fchk, gjf, log
4+
5+
__all__ = ["fchk", "gjf", "log"]

dpdata/formats/qe/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import annotations
2+
3+
from . import scf, traj
4+
5+
__all__ = ["scf", "traj"]

0 commit comments

Comments
 (0)