annotate tests/list-tree.py @ 51323:46280260d010

pytype: use "$(hg root)" instead of `hg root` to make shellcheck happier
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 18 Dec 2023 15:52:17 -0300
parents 6000f5b25c9b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35002
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
1 import argparse
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
2 import os
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
3
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
4 ap = argparse.ArgumentParser()
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
5 ap.add_argument('path', nargs='+')
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
6 opts = ap.parse_args()
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
7
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 35389
diff changeset
8
35002
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
9 def gather():
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
10 for p in opts.path:
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
11 if not os.path.exists(p):
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
12 return
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
13 if os.path.isdir(p):
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
14 yield p + os.path.sep
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
15 for dirpath, dirs, files in os.walk(p):
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
16 for d in dirs:
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
17 yield os.path.join(dirpath, d) + os.path.sep
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
18 for f in files:
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
19 yield os.path.join(dirpath, f)
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
20 else:
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
21 yield p
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
22
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 35389
diff changeset
23
35389
acff41957b34 tests: stabilize the sorted output of list-tree.py on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 35002
diff changeset
24 print('\n'.join(sorted(gather(), key=lambda x: x.replace(os.path.sep, '/'))))