Passed
Push — master ( 37d872...ab6369 )
by Matěj
02:13
created

ensure_paths_are_short.main()   B

Complexity

Conditions 5

Size

Total Lines 17
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 15
nop 0
dl 0
loc 17
rs 8.5454
c 0
b 0
f 0
1
#!/usr/bin/env python2
2
3
from __future__ import print_function
4
5
import os
6
import sys
7
8
9
MAX_PATH_LEN = 200
10
11
12
def main():
13
    ssg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
14
    max_path = ""
15
    for dir_, _, files in os.walk(ssg_root):
16
        for file_ in files:
17
            path = os.path.relpath(os.path.join(dir_, file_), ssg_root)
18
            if len(path) > len(max_path):
19
                max_path = path
20
21
    print("The longest file path is '%s' at %i characters."
22
          % (max_path, len(max_path)))
23
24
    if len(max_path) > MAX_PATH_LEN:
25
        print("At least one file path is longer than %i characters. That may "
26
              "be problematic on some platforms." % (MAX_PATH_LEN),
27
              file=sys.stderr)
28
        sys.exit(1)
29
30
31
if __name__ == "__main__":
32
    main()
33