GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/tools/check-imports.py at master · juliens/node Expand file tree/ Copy pathcheck-imports.pyMore file actions executable file ·42 lines (33 loc) · 1.29 KB / Copy pathcheck-imports.pyFile metadata and controlsexecutable file ·42 lines (33 loc) · 1.29 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 #!/usr/bin/env python from __future__ import print_function import glob import re import sys def do_exist(file_name, lines, imported): if not any(not re.match('using \w+::{0};'.format(imported), line) and re.search(imported, line) for line in lines): print('File "{0}" does not use "{1}"'.format(file_name, imported)) return False return True def is_valid(file_name): with open(file_name) as source_file: lines = [line.strip() for line in source_file] usings, importeds, line_numbers, valid = [], [], [], True for idx, line in enumerate(lines, 1): matches = re.search(r'^using (\w+::(\w+));$', line) if matches: line_numbers.append(idx) usings.append(matches.group(1)) importeds.append(matches.group(2)) valid = all([do_exist(file_name, lines, imported) for imported in importeds]) sorted_usings = sorted(usings, key=lambda x: x.lower()) if sorted_usings != usings: print("using statements aren't sorted in '{0}'.".format(file_name)) for num, actual, expected in zip(line_numbers, usings, sorted_usings): if actual != expected: print('\tLine {0}: Actual: {1}, Expected: {2}' .format(num, actual, expected)) return False else: return valid sys.exit(0 if all(map(is_valid, glob.iglob('src/*.cc'))) else 1) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |