mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Explicitly sorts the discovered metadata file, and defines ordering of validation messages, so the tools will output will be self-consistent. Change-Id: I9b263a16b151c014e5950638f066376469c701df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5379678 Commit-Queue: Jiewei Qian <qjw@chromium.org> Reviewed-by: Anne Redulla <aredulla@google.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
# Copyright 2023 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import os
|
|
from typing import List
|
|
|
|
# The base names that are known to be Chromium metadata files.
|
|
_METADATA_FILES = {
|
|
"README.chromium",
|
|
}
|
|
|
|
|
|
def is_metadata_file(path: str) -> bool:
|
|
"""Filter for metadata files."""
|
|
return os.path.basename(path) in _METADATA_FILES
|
|
|
|
|
|
def find_metadata_files(root: str) -> List[str]:
|
|
"""Finds all metadata files within the given root directory,
|
|
including subdirectories.
|
|
|
|
Args:
|
|
root: the absolute path to the root directory within which to
|
|
search.
|
|
|
|
Returns: the absolute full paths for all the metadata files within
|
|
the root directory, sorted in ascending order.
|
|
"""
|
|
metadata_files = []
|
|
|
|
for (dirpath, _, filenames) in os.walk(root, followlinks=True):
|
|
for filename in filenames:
|
|
if is_metadata_file(filename):
|
|
full_path = os.path.join(root, dirpath, filename)
|
|
metadata_files.append(full_path)
|
|
|
|
return sorted(metadata_files)
|