gn/highest_version_dir.py
raw| 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2017 Google Inc. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file. |
| 7 | |
| 8 | from __future__ import print_function |
| 9 | |
| 10 | import os |
| 11 | import re |
| 12 | import sys |
| 13 | |
| 14 | dirpath = sys.argv[1] |
| 15 | regex = re.compile(sys.argv[2]) |
| 16 | |
| 17 | print(sorted(filter(regex.match, os.listdir(dirpath)))[-1]) |