Coverage for eminus/psp/pade/__init__.py: 100.00%

0 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-18 08:43 +0000

1# SPDX-FileCopyrightText: 2021 The eminus developers 

2# SPDX-License-Identifier: Apache-2.0 

3"""PADE GTH pseudopotential files. 

4 

5Reference: Phys. Rev. B 54, 1703. 

6""" 

7 

8if __name__ == "__main__": 

9 import importlib.resources 

10 import shutil 

11 import urllib.request 

12 import zipfile 

13 

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")