MCPcopy Create free account
hub / github.com/idank/explainshell / collect_gz_files

Function collect_gz_files

explainshell/util.py:113–131  ·  view source on GitHub ↗

Expand a list of files/directories into absolute .gz file paths. Paths starting with '@' are treated as files containing one path per line.

(paths: list[str])

Source from the content-addressed store, hash-verified

111
112
113def collect_gz_files(paths: list[str]) -> list[str]:
114 """Expand a list of files/directories into absolute .gz file paths.
115
116 Paths starting with '@' are treated as files containing one path per line.
117 """
118 expanded = _expand_file_lists(paths)
119 result: list[str] = []
120 for path in expanded:
121 if os.path.isdir(path):
122 result.extend(
123 sorted(glob.glob(os.path.join(path, "**", "*.gz"), recursive=True))
124 )
125 elif not path.endswith(".gz"):
126 raise ValueError(
127 f"expected a .gz file but got '{path}' — did you mean '@{path}'?"
128 )
129 else:
130 result.append(path)
131 return [os.path.abspath(p) for p in result]
132
133
134def fmt_tokens(n: int) -> str:

Callers 3

test_accepts_gz_fileMethod · 0.90
run_benchFunction · 0.90

Calls 1

_expand_file_listsFunction · 0.85

Tested by 2

test_accepts_gz_fileMethod · 0.72