• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

maurergroup / dfttoolkit / 12448697655

21 Dec 2024 09:47PM UTC coverage: 24.863% (+3.1%) from 21.747%
12448697655

push

github

a7cc32
web-flow
Merge pull request #24 from maurergroup/dependabot/pip/sphinx-8.1.3

Bump sphinx from 7.4.7 to 8.1.3

773 of 3109 relevant lines covered (24.86%)

0.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
dfttoolkit/utils/run_utils.py
1
import os.path
1✔
2
from functools import wraps
1✔
3

4

5
def no_repeat(
1✔
6
    original_func=None,
7
    *,
8
    output_file: str = "aims.out",
9
    calc_dir: str = "./",
10
    force: bool = False,
11
):
12
    """
13
    Don't repeat the calculation if aims.out exists in the calculation directory.
14

15
    Parameters
16
    ----------
17
    output_file : str, default='aims.out'
18
        The name of the output file to check for.
19
    calc_dir : str, default="./"
20
        The directory where the calculation is performed
21
    force : bool, default=False
22
        If True, the calculation is performed even if aims.out exists in the calculation
23
        directory.
24

25
    Raises
26
    -------
27
    ValueError
28
        if the `calc_dir` kwarg is not a directory
29
    """
30

31
    def _no_repeat(func):
1✔
32
        @wraps(func)
1✔
33
        def wrapper(*args, **kwargs):
1✔
34
            # Override calc_dir in decorator call if given in func
35
            if "calc_dir" in kwargs:
1✔
36
                check_dir = kwargs["calc_dir"]
×
37
            else:
38
                check_dir = calc_dir
1✔
39

40
            if not os.path.isdir(check_dir):
1✔
41
                raise ValueError(f"{check_dir} is not a directory.")
1✔
42
            if force:
1✔
43
                return func(*args, **kwargs)
1✔
44
            if not os.path.isfile(f"{check_dir}/{output_file}"):
1✔
45
                return func(*args, **kwargs)
1✔
46
            else:
47
                print(f"aims.out already exists in {check_dir}. Skipping calculation.")
1✔
48

49
        return wrapper
1✔
50

51
    if original_func:
1✔
52
        return _no_repeat(original_func)
×
53

54
    return _no_repeat
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc