File: test_executable.py

package info (click to toggle)
sympy 1.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 36,784 kB
  • sloc: python: 460,598; xml: 359; makefile: 162; sh: 59; lisp: 4
file content (25 lines) | stat: -rwxr-xr-x 733 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
"""
Test that only executable files have an executable bit set
"""
from __future__ import print_function

import os

from get_sympy import path_hack
base_dir = path_hack()

def test_executable(path):
    if not os.path.isdir(path):
        if os.access(path, os.X_OK):
            with open(path, 'r') as f:
                if f.readline()[:2] != "#!":
                    exn_msg = "File at " + path + " either should not be executable or should have a shebang line"
                    raise OSError(exn_msg)
    else:
        for file in os.listdir(path):
            if file in ('.git', 'venv_main'):
                continue
            test_executable(os.path.join(path, file))

test_executable(base_dir)