File: get_submodule_paths.py

package info (click to toggle)
numpy 1%3A2.3.4%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 86,072 kB
  • sloc: python: 255,800; asm: 232,483; ansic: 212,593; cpp: 157,465; f90: 1,575; sh: 845; fortran: 567; makefile: 431; sed: 139; xml: 109; java: 97; perl: 82; cs: 62; javascript: 53; objc: 33; lex: 13; yacc: 9
file content (31 lines) | stat: -rw-r--r-- 1,083 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import glob
import os.path


def get_submodule_paths():
    '''
    Get paths to submodules so that we can exclude them from things like
    check_test_name.py, check_unicode.py, etc.
    '''
    root_directory = os.path.dirname(os.path.dirname(__file__))
    gitmodule_file = os.path.join(root_directory, '.gitmodules')
    with open(gitmodule_file) as gitmodules:
        data = gitmodules.read().split('\n')
        submodule_paths = [datum.split(' = ')[1] for datum in data if
                        datum.startswith('\tpath = ')]
        submodule_paths = [os.path.join(root_directory, path) for path in
                           submodule_paths]
    # vendored with a script rather than via gitmodules
    with open(
            os.path.join(root_directory, ".gitattributes"), "r"
    ) as attr_file:
        for line in attr_file:
            if "vendored" in line:
                pattern = line.split(" ", 1)[0]
                submodule_paths.extend(glob.glob(pattern))

    return submodule_paths


if __name__ == "__main__":
    print('\n'.join(get_submodule_paths()))