Skip to content

Commit 57ad89b

Browse files
committed
---
yaml --- r: 188372 b: refs/heads/auto c: 9569691 h: refs/heads/master v: v3
1 parent 9139dac commit 57ad89b

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: f1eebb8f371cf2703ca1d4096f974d037938ece8
13+
refs/heads/auto: 956969162dd199682c16f40e9b124acc853e3992
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/etc/tidy.py

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import subprocess
1414
import re
1515
import os
16-
from licenseck import *
16+
from licenseck import check_license
1717
import snapshot
1818

1919
err = 0
@@ -22,13 +22,8 @@
2222
tab_flag = "ignore-tidy-tab"
2323
linelength_flag = "ignore-tidy-linelength"
2424

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']
3227

3328

3429
def report_error_name_no(name, no, s):
@@ -51,6 +46,34 @@ def do_license_check(name, contents):
5146
if not check_license(name, contents):
5247
report_error_name_no(name, 1, "incorrect license")
5348

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+
5477
current_name = ""
5578
current_contents = ""
5679
check_tab = True
@@ -63,30 +86,16 @@ def do_license_check(name, contents):
6386

6487
src_dir = sys.argv[1]
6588

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
8092

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}
8594

86-
all_paths = set()
95+
all_paths = set()
8796

97+
try:
8898
for (dirpath, dirnames, filenames) in os.walk(src_dir):
89-
9099
# Skip some third-party directories
91100
skippable_dirs = {
92101
'src/jemalloc',
@@ -105,14 +114,6 @@ def update_counts(current_name):
105114
if any(d in dirpath for d in skippable_dirs):
106115
continue
107116

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-
116117
file_names = [os.path.join(dirpath, f) for f in filenames
117118
if interesting_file(f)
118119
and not f.endswith("_gen.rs")

0 commit comments

Comments
 (0)