|
10 | 10 |
|
11 | 11 | import contextlib
|
12 | 12 | import datetime
|
13 |
| -import fnmatch |
14 | 13 | import glob
|
15 | 14 | import inspect
|
16 | 15 | import os
|
@@ -277,77 +276,6 @@ def do_zip_mods():
|
277 | 276 | zf.write("coverage/__main__.py", "__main__.py")
|
278 | 277 |
|
279 | 278 |
|
280 |
| -def do_check_eol(): |
281 |
| - """Check files for incorrect newlines and trailing white space.""" |
282 |
| - |
283 |
| - ignore_dirs = [ |
284 |
| - '.svn', '.hg', '.git', |
285 |
| - '.tox*', |
286 |
| - '*.egg-info', |
287 |
| - '_build', |
288 |
| - '_spell', |
289 |
| - 'tmp', |
290 |
| - 'help', |
291 |
| - ] |
292 |
| - checked = set() |
293 |
| - |
294 |
| - def check_file(fname, crlf=True, trail_white=True): |
295 |
| - """Check a single file for white space abuse.""" |
296 |
| - fname = os.path.relpath(fname) |
297 |
| - if fname in checked: |
298 |
| - return |
299 |
| - checked.add(fname) |
300 |
| - |
301 |
| - line = None |
302 |
| - with open(fname, "rb") as f: |
303 |
| - for n, line in enumerate(f, start=1): |
304 |
| - if crlf: |
305 |
| - if b"\r" in line: |
306 |
| - print(f"{fname}@{n}: CR found") |
307 |
| - return |
308 |
| - if trail_white: |
309 |
| - line = line[:-1] |
310 |
| - if not crlf: |
311 |
| - line = line.rstrip(b'\r') |
312 |
| - if line.rstrip() != line: |
313 |
| - print(f"{fname}@{n}: trailing white space found") |
314 |
| - return |
315 |
| - |
316 |
| - if line is not None and not line.strip(): |
317 |
| - print(f"{fname}: final blank line") |
318 |
| - |
319 |
| - def check_files(root, patterns, **kwargs): |
320 |
| - """Check a number of files for white space abuse.""" |
321 |
| - for where, dirs, files in os.walk(root): |
322 |
| - for f in files: |
323 |
| - fname = os.path.join(where, f) |
324 |
| - for p in patterns: |
325 |
| - if fnmatch.fnmatch(fname, p): |
326 |
| - check_file(fname, **kwargs) |
327 |
| - break |
328 |
| - for ignore_dir in ignore_dirs: |
329 |
| - ignored = [] |
330 |
| - for dir_name in dirs: |
331 |
| - if fnmatch.fnmatch(dir_name, ignore_dir): |
332 |
| - ignored.append(dir_name) |
333 |
| - for dir_name in ignored: |
334 |
| - dirs.remove(dir_name) |
335 |
| - |
336 |
| - check_files("coverage", ["*.py"]) |
337 |
| - check_files("coverage/ctracer", ["*.c", "*.h"]) |
338 |
| - check_files("coverage/htmlfiles", ["*.html", "*.scss", "*.css", "*.js"]) |
339 |
| - check_files("tests", ["*.py"]) |
340 |
| - check_files("tests", ["*,cover"], trail_white=False) |
341 |
| - check_files("tests/js", ["*.js", "*.html"]) |
342 |
| - check_file("setup.py") |
343 |
| - check_file("igor.py") |
344 |
| - check_file("Makefile") |
345 |
| - check_files(".", ["*.rst", "*.txt"]) |
346 |
| - check_files(".", ["*.pip"]) |
347 |
| - check_files(".github", ["*"]) |
348 |
| - check_files("ci", ["*"]) |
349 |
| - |
350 |
| - |
351 | 279 | def print_banner(label):
|
352 | 280 | """Print the version of Python."""
|
353 | 281 | try:
|
|
0 commit comments