Coverage for eminus/psp/pbe/__init__.py: 100.00%
0 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-01 11:47 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-01 11:47 +0000
1# SPDX-FileCopyrightText: 2021 The eminus developers
2# SPDX-License-Identifier: Apache-2.0
3"""PBE GTH pseudopotential files.
5Reference: Theor. Chem. Acc. 114, 145.
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.pbe")
16 except AttributeError:
17 with importlib.resources.path("eminus.psp", "pbe") 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 gth_path = psp_path.joinpath("cp2k-data-master/potentials/Goedecker/cp2k/pbe")
28 for f in gth_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")