21 mode = argv[1]
22 if mode not in ['absolute', 'relative']:
23 raise Exception("First argument must be 'absolute' or 'relative'")
24 directory = argv[2]
25 if mode in 'absolute' and not os.path.isabs(directory):
26 directory = os.path.realpath(directory)
27
28 pattern = None
30 pattern = re.compile(argv[3])
31
32 for root, directories, files in os.walk(directory):
33
34 for skip_dir in ['.git', 'gen', 'test']:
35 if skip_dir in directories:
36 directories.remove(skip_dir)
37
38
39
40 if pattern and root == directory:
41 directories[:] = filter(pattern.match, directories)
42
43 for filename in files:
44 if filename.endswith(
45 '.dart') and not filename.endswith('_test.dart'):
46 if mode in 'absolute':
47 fullname = os.path.join(directory, root, filename)
48 else:
49 fullname = os.path.relpath(os.path.join(root, filename))
50 fullname = fullname.replace(os.sep, '/')
52
53
def print(*args, **kwargs)