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

maurergroup / dfttoolkit / 15065810745

16 May 2025 09:56AM UTC coverage: 30.583% (+8.8%) from 21.747%
15065810745

Pull #59

github

b2c890
web-flow
Merge f52b00038 into e895278a4
Pull Request #59: Vibrations refactor

1164 of 3806 relevant lines covered (30.58%)

0.31 hits per line

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

0.0
dfttoolkit/utils/file_crawler.py
1
import os
×
2
from os.path import join
×
3

4

5
def find_all_aims_output_files(
×
6
    directory,
7
    include_restart=True,
8
    allow_all_out_files=False,
9
    allow_multiple_files=False,
10
):
11
    """Recursively searches for AIMS output files and returns their full filenames as a list."""
12
    aims_fnames = []
×
13

14
    for root, _directories, _files in os.walk(directory):
×
15
        fname_list = find_aims_output_file(
×
16
            root, allow_all_out_files, allow_multiple_files
17
        )
18

19
        if len(fname_list) > 0:
×
20
            for fname in fname_list:
×
21
                if include_restart:
×
22
                    aims_fnames.append(join(root, fname))
×
23
                else:
24
                    root_name = os.path.basename(os.path.normpath(root))
×
25
                    is_restart_folder = len(root_name) == len(
×
26
                        "restartXX"
27
                    ) and root_name.startswith("restart")
28
                    if not is_restart_folder:
×
29
                        aims_fnames.append(join(root, fname))
×
30

31
    return aims_fnames
×
32

33

34
def find_aims_output_file(
×
35
    calc_dir, allow_all_out_files=False, allow_multiple_files=False
36
):
37
    """Searches directory for output files."""
38
    return find_file(
×
39
        calc_dir,
40
        allow_all_out_files=allow_all_out_files,
41
        allow_multiple_files=allow_multiple_files,
42
        list_of_filenames=[
43
            "aims.out",
44
            "out.aims",
45
            "output",
46
            "output.aims",
47
            "aims.output",
48
        ],
49
    )
50

51

52
def find_vasp_output_file(calc_dir):
×
53
    """Searches directory for output files."""
54
    return find_file(calc_dir, allow_all_out_files=False, list_of_filenames=["outcar"])
×
55

56

57
def find_file(
×
58
    calc_dir,
59
    allow_all_out_files=False,
60
    allow_multiple_files=False,
61
    list_of_filenames=None,
62
):
63
    """Searches directory for output files."""
64
    if list_of_filenames is None:
×
65
        list_of_filenames = []
×
66
    allfiles = [f for f in os.listdir(calc_dir) if os.path.isfile(join(calc_dir, f))]
×
67
    filename = []
×
68
    for f in allfiles:
×
69
        if f.lower() in list_of_filenames:
×
70
            filename.append(f)
×
71

72
    if allow_all_out_files and len(filename) == 0:
×
73
        filename = [f for f in allfiles if f.endswith(".out")]
×
74

75
    if len(filename) > 1 and not allow_multiple_files:
×
76
        msg = f"Multiple output files found: {calc_dir}, {filename}"
×
77
        raise Exception(
×
78
            msg
79
        )
80
    return filename
×
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