MCPcopy Create free account
hub / github.com/alibaba/GraphScope / _ExpandDirectories

Function _ExpandDirectories

analytical_engine/misc/cpplint.py:6820–6849  ·  view source on GitHub ↗

Searches a list of filenames and replaces directories in the list with all files descending from those directories. Files with extensions not in the valid extensions list are excluded. Args: filenames: A list of files or directories Returns: A list of all files that are members of

(filenames)

Source from the content-addressed store, hash-verified

6818 return filenames
6819
6820def _ExpandDirectories(filenames):
6821 """Searches a list of filenames and replaces directories in the list with
6822 all files descending from those directories. Files with extensions not in
6823 the valid extensions list are excluded.
6824
6825 Args:
6826 filenames: A list of files or directories
6827
6828 Returns:
6829 A list of all files that are members of filenames or descended from a
6830 directory in filenames
6831 """
6832 expanded = set()
6833 for filename in filenames:
6834 if not os.path.isdir(filename):
6835 expanded.add(filename)
6836 continue
6837
6838 for root, _, files in os.walk(filename):
6839 for loopfile in files:
6840 fullname = os.path.join(root, loopfile)
6841 if fullname.startswith('.' + os.path.sep):
6842 fullname = fullname[len('.' + os.path.sep):]
6843 expanded.add(fullname)
6844
6845 filtered = []
6846 for filename in expanded:
6847 if os.path.splitext(filename)[1][1:] in GetAllExtensions():
6848 filtered.append(filename)
6849 return filtered
6850
6851def _FilterExcludedFiles(fnames):
6852 """Filters out files listed in the --exclude command line switch. File paths

Callers 1

ParseArgumentsFunction · 0.85

Calls 4

GetAllExtensionsFunction · 0.85
addMethod · 0.65
appendMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected