Initial upload: TermDiagram v0.1.0
Some checks failed
CI / test (push) Failing after 18s
CI / build (push) Has been skipped
Release / release (push) Failing after 12s

This commit is contained in:
2026-01-29 22:28:12 +00:00
parent d87acfbf7b
commit 89dbaede67

View File

@@ -0,0 +1,32 @@
from pathlib import Path
from typing import List
class FileUtils:
@staticmethod
def get_files(
directory: str, extensions: List[str] = None, exclude: List[str] = None
) -> List[Path]:
exclude = exclude or []
files = []
for path in Path(directory).rglob("*"):
if path.is_file():
if extensions:
if path.suffix not in extensions:
continue
if any(str(path).startswith(e) for e in exclude):
continue
files.append(path)
return files
@staticmethod
def read_file(file_path: str) -> str:
try:
with open(file_path, "r", encoding="utf-8") as f:
return f.read()
except (IOError, UnicodeDecodeError):
return ""