comparison tests/list-tree.py @ 35217:aa905f9cdcda stable

tests: write and use a custom helper script to avoid find's -printf -printf on find is a GNU-ism and will be banned in an upcoming check-code change. Differential Revision: https://phab.mercurial-scm.org/D1597
author Augie Fackler <augie@google.com>
date Tue, 05 Dec 2017 16:55:41 -0500
parents
children acff41957b34
comparison
equal deleted inserted replaced
35198:759234670d19 35217:aa905f9cdcda
1 from __future__ import (
2 absolute_import,
3 print_function,
4 )
5
6 import argparse
7 import os
8
9 ap = argparse.ArgumentParser()
10 ap.add_argument('path', nargs='+')
11 opts = ap.parse_args()
12
13 def gather():
14 for p in opts.path:
15 if not os.path.exists(p):
16 return
17 if os.path.isdir(p):
18 yield p + os.path.sep
19 for dirpath, dirs, files in os.walk(p):
20 for d in dirs:
21 yield os.path.join(dirpath, d) + os.path.sep
22 for f in files:
23 yield os.path.join(dirpath, f)
24 else:
25 yield p
26
27 print('\n'.join(sorted(gather())))