"""Checks that keep the published repository honest: the README names only real commands, and no file carries a home path or a personal email address.""" import os, re, subprocess, sys, unittest from support import REPO, SisiCase def _tracked_or_untracked_files(): """Every file that would be published: tracked files plus untracked ones that .gitignore does not hide. Falls back to a directory walk when git is unavailable.""" try: r = subprocess.run(["git", "ls-files", "--cached", "--others", "--exclude-standard"], cwd=REPO, capture_output=True, text=True, timeout=30) if r.returncode == 0 and r.stdout.strip(): return [f for f in r.stdout.splitlines() if os.path.isfile(os.path.join(REPO, f))] except (OSError, subprocess.SubprocessError): pass out = [] for dp, dns, fns in os.walk(REPO): dns[:] = [d for d in dns if d not in (".git", "__pycache__")] out += [os.path.relpath(os.path.join(dp, n), REPO) for n in fns if not n.endswith(".pyc")] return out def _text(rel): try: with open(os.path.join(REPO, rel), "rb") as f: data = f.read() except OSError: return None if b"\0" in data: return None return data.decode("utf-8", "replace") # Paths under /home/ or /Users/ that are placeholders in tests and examples, not real people. _ALLOWED_HOME_USERS = {"alice", "bob", "user", "you", "name", "username", "example", "me"} HOME_RE = re.compile(r"(? %s" % (doc, target)) if __name__ == "__main__": unittest.main()