|
8 | 8 | # option. This file may not be copied, modified, or distributed
|
9 | 9 | # except according to those terms.
|
10 | 10 |
|
11 |
| -import sys, fileinput, subprocess, re, os |
| 11 | +import sys |
| 12 | +import fileinput |
| 13 | +import subprocess |
| 14 | +import re |
| 15 | +import os |
12 | 16 | from licenseck import *
|
13 | 17 | import snapshot
|
14 | 18 |
|
15 |
| -err=0 |
16 |
| -cols=100 |
17 |
| -cr_flag="ignore-tidy-cr" |
18 |
| -tab_flag="ignore-tidy-tab" |
19 |
| -linelength_flag="ignore-tidy-linelength" |
| 19 | +err = 0 |
| 20 | +cols = 100 |
| 21 | +cr_flag = "ignore-tidy-cr" |
| 22 | +tab_flag = "ignore-tidy-tab" |
| 23 | +linelength_flag = "ignore-tidy-linelength" |
20 | 24 |
|
21 | 25 | # Be careful to support Python 2.4, 2.6, and 3.x here!
|
22 |
| -config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ], |
23 |
| - stdout=subprocess.PIPE) |
24 |
| -result=config_proc.communicate()[0] |
| 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 | 32 |
|
26 |
| -true="true".encode('utf8') |
27 |
| -autocrlf=result.strip() == true if result is not None else False |
28 | 33 |
|
29 | 34 | def report_error_name_no(name, no, s):
|
30 | 35 | global err
|
31 | 36 | print("%s:%d: %s" % (name, no, s))
|
32 |
| - err=1 |
| 37 | + err = 1 |
| 38 | + |
33 | 39 |
|
34 | 40 | def report_err(s):
|
35 | 41 | report_error_name_no(fileinput.filename(), fileinput.filelineno(), s)
|
36 | 42 |
|
| 43 | + |
37 | 44 | def report_warn(s):
|
38 | 45 | print("%s:%d: %s" % (fileinput.filename(),
|
39 | 46 | fileinput.filelineno(),
|
40 | 47 | s))
|
41 | 48 |
|
| 49 | + |
42 | 50 | def do_license_check(name, contents):
|
43 | 51 | if not check_license(name, contents):
|
44 | 52 | report_error_name_no(name, 1, "incorrect license")
|
@@ -81,13 +89,13 @@ def do_license_check(name, contents):
|
81 | 89 | date, rev = snapshot.curr_snapshot_rev()
|
82 | 90 | if not hsh.startswith(rev):
|
83 | 91 | report_err("snapshot out of date (" + date
|
84 |
| - + "): " + line) |
| 92 | + + "): " + line) |
85 | 93 | else:
|
86 | 94 | if "SNAP" in line:
|
87 | 95 | report_warn("unmatched SNAP line: " + line)
|
88 | 96 |
|
89 | 97 | if check_tab and ('\t' in line and
|
90 |
| - "Makefile" not in fileinput.filename()): |
| 98 | + "Makefile" not in fileinput.filename()): |
91 | 99 | report_err("tab character")
|
92 | 100 | if check_cr and not autocrlf and '\r' in line:
|
93 | 101 | report_err("CR character")
|
|
0 commit comments