13
13
import subprocess
14
14
import re
15
15
import os
16
- from licenseck import *
16
+ from licenseck import check_license
17
17
import snapshot
18
18
19
19
err = 0
22
22
tab_flag = "ignore-tidy-tab"
23
23
linelength_flag = "ignore-tidy-linelength"
24
24
25
- # Be careful to support Python 2.4, 2.6, and 3.x here!
26
- config_proc = subprocess .Popen (["git" , "config" , "core.autocrlf" ],
27
- stdout = subprocess .PIPE )
28
- result = config_proc .communicate ()[0 ]
29
-
30
- true = "true" .encode ('utf8' )
31
- autocrlf = result .strip () == true if result is not None else False
25
+ interesting_files = ['.rs' , '.py' , '.js' , '.sh' , '.c' , '.h' ]
26
+ uninteresting_files = ['miniz.c' , 'jquery' , 'rust_android_dummy' ]
32
27
33
28
34
29
def report_error_name_no (name , no , s ):
@@ -51,6 +46,34 @@ def do_license_check(name, contents):
51
46
if not check_license (name , contents ):
52
47
report_error_name_no (name , 1 , "incorrect license" )
53
48
49
+
50
+ def update_counts (current_name ):
51
+ global file_counts
52
+ global count_other_linted_files
53
+
54
+ _ , ext = os .path .splitext (current_name )
55
+
56
+ if ext in interesting_files :
57
+ file_counts [ext ] += 1
58
+ else :
59
+ count_other_linted_files += 1
60
+
61
+
62
+ def interesting_file (f ):
63
+ if any (x in f for x in uninteresting_files ):
64
+ return False
65
+
66
+ return any (os .path .splitext (f )[1 ] == ext for ext in interesting_files )
67
+
68
+
69
+ # Be careful to support Python 2.4, 2.6, and 3.x here!
70
+ config_proc = subprocess .Popen (["git" , "config" , "core.autocrlf" ],
71
+ stdout = subprocess .PIPE )
72
+ result = config_proc .communicate ()[0 ]
73
+
74
+ true = "true" .encode ('utf8' )
75
+ autocrlf = result .strip () == true if result is not None else False
76
+
54
77
current_name = ""
55
78
current_contents = ""
56
79
check_tab = True
@@ -63,30 +86,16 @@ def do_license_check(name, contents):
63
86
64
87
src_dir = sys .argv [1 ]
65
88
66
- try :
67
- count_lines = 0
68
- count_non_blank_lines = 0
69
- count_other_linted_files = 0
70
-
71
- interesting_files = ['.rs' , '.py' , '.js' , '.sh' , '.c' , '.h' ]
72
-
73
- file_counts = {ext : 0 for ext in interesting_files }
74
-
75
- def update_counts (current_name ):
76
- global file_counts
77
- global count_other_linted_files
78
-
79
- _ , ext = os .path .splitext (current_name )
89
+ count_lines = 0
90
+ count_non_blank_lines = 0
91
+ count_other_linted_files = 0
80
92
81
- if ext in interesting_files :
82
- file_counts [ext ] += 1
83
- else :
84
- count_other_linted_files += 1
93
+ file_counts = {ext : 0 for ext in interesting_files }
85
94
86
- all_paths = set ()
95
+ all_paths = set ()
87
96
97
+ try :
88
98
for (dirpath , dirnames , filenames ) in os .walk (src_dir ):
89
-
90
99
# Skip some third-party directories
91
100
skippable_dirs = {
92
101
'src/jemalloc' ,
@@ -105,14 +114,6 @@ def update_counts(current_name):
105
114
if any (d in dirpath for d in skippable_dirs ):
106
115
continue
107
116
108
- def interesting_file (f ):
109
- if "miniz.c" in f \
110
- or "jquery" in f \
111
- or "rust_android_dummy" in f :
112
- return False
113
-
114
- return any (os .path .splitext (f )[1 ] == ext for ext in interesting_files )
115
-
116
117
file_names = [os .path .join (dirpath , f ) for f in filenames
117
118
if interesting_file (f )
118
119
and not f .endswith ("_gen.rs" )
0 commit comments