Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
list_dart_files Namespace Reference

Functions

 main (argv)
 

Detailed Description

Tool for listing Dart source files.

If the first argument is 'relative', the script produces paths relative to the
current working directory. If the first argument is 'absolute', the script
produces absolute paths.

Usage:
  python3 tools/list_dart_files.py {absolute, relative} <directory> <pattern>

Function Documentation

◆ main()

list_dart_files.main (   argv)

Definition at line 20 of file list_dart_files.py.

20def main(argv):
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
29 if len(argv) > 3:
30 pattern = re.compile(argv[3])
31
32 for root, directories, files in os.walk(directory):
33 # We only care about actual source files, not generated code or tests.
34 for skip_dir in ['.git', 'gen', 'test']:
35 if skip_dir in directories:
36 directories.remove(skip_dir)
37
38 # If we are looking at the root directory, filter the immediate
39 # subdirectories by the given pattern.
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, '/')
51 print(fullname)
52
53
void print(void *str)
Definition bridge.cpp:126
Definition main.py:1