mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Practracker: only consider files under "src/"
This commit is contained in:
@@ -3,22 +3,28 @@ import os
|
||||
# We don't want to run metrics for unittests, automatically-generated C files,
|
||||
# external libraries or git leftovers.
|
||||
EXCLUDE_SOURCE_DIRS = {"src/test/", "src/trunnel/", "src/rust/",
|
||||
"src/ext/", ".git/"}
|
||||
"src/ext/" }
|
||||
|
||||
EXCLUDE_FILES = {"orconfig.h"}
|
||||
|
||||
def _norm(p):
|
||||
return os.path.normcase(os.path.normpath(p))
|
||||
|
||||
def get_tor_c_files(tor_topdir):
|
||||
def get_tor_c_files(tor_topdir, include_dirs=None):
|
||||
"""
|
||||
Return a list with the .c and .h filenames we want to get metrics of.
|
||||
"""
|
||||
files_list = []
|
||||
exclude_dirs = { _norm(os.path.join(tor_topdir, p)) for p in EXCLUDE_SOURCE_DIRS }
|
||||
|
||||
if include_dirs is None:
|
||||
topdirs = [ tor_topdir ]
|
||||
else:
|
||||
topdirs = [ os.path.join(tor_topdir, inc) for inc in include_dirs ]
|
||||
|
||||
for root, directories, filenames in os.walk(tor_topdir):
|
||||
# TO THE REVIEWER: I will fix this indentation shortly. -nm
|
||||
for topdir in topdirs:
|
||||
for root, directories, filenames in os.walk(topdir):
|
||||
# Remove all the directories that are excluded.
|
||||
directories[:] = [ d for d in directories
|
||||
if _norm(os.path.join(root,d)) not in exclude_dirs ]
|
||||
|
||||
Reference in New Issue
Block a user