Coverage for eminus/psp/pade/__init__.py: 100.00%
0 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-08 12:59 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-08 12:59 +0000
1# SPDX-FileCopyrightText: 2021 The eminus developers
2# SPDX-License-Identifier: Apache-2.0
3"""PADE GTH pseudopotential files.
5Reference: Phys. Rev. B 54, 1703.
6"""
8if __name__ == "__main__":
9 import importlib.resources
10 import shutil
11 import urllib.request
12 import zipfile
14 try:
15 psp_path = importlib.resources.files("eminus.psp.pade")
16 except AttributeError:
17 with importlib.resources.path("eminus.psp", "pade") as p:
18 psp_path = p
19 file = "master.zip"
20 # Download files
21 url = f"https://github.com/cp2k/cp2k-data/archive/refs/heads/{file}"
22 urllib.request.urlretrieve(url, file) # noqa: S310
23 # Unpack files
24 with zipfile.ZipFile(file, "r") as fzip:
25 fzip.extractall()
26 # Move files
27 pade_path = psp_path.joinpath("cp2k-data-master/potentials/Goedecker/cp2k/pade")
28 for f in pade_path.iterdir():
29 shutil.move(str(f), psp_path.joinpath(f.name))
30 # Cleanup
31 psp_path.joinpath(file).unlink()
32 shutil.rmtree("cp2k-data-master")