Skip to content

Commit d158481

Browse files
committed
add tool to find facilities not getting a vera.org ID
Signed-off-by: John Seekins <john@robot-house.us>
1 parent 95642da commit d158481

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tools/find_missing_vera.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python3
2+
3+
import json
4+
import os
5+
import pprint
6+
import subprocess
7+
8+
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
9+
10+
11+
def _find_files(directory: str) -> os.DirEntry[str]:
12+
results = []
13+
with os.scandir(directory) as d:
14+
for f in d:
15+
if f.name.startswith("ice_detention_facilities") and f.name.endswith(".json"):
16+
results.append(f)
17+
final = results[0]
18+
for f in results:
19+
if f.stat().st_mtime > final.stat().st_mtime:
20+
final = f
21+
return final
22+
23+
24+
def main() -> None:
25+
res = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True)
26+
root_dir = [f for f in res.stdout.decode("utf-8").split("\n")][0]
27+
newest_file = _find_files(root_dir)
28+
with open(newest_file.path, "r") as f_in:
29+
data = json.load(f_in)
30+
missing_vera = {k: v for k, v in data["facilities"].items() if not v.get("vera_id", "")}
31+
pprint.pprint(missing_vera, indent=1, compact=True)
32+
print(f"Found {len(missing_vera.keys())} facilities with a missing vera.org ID")
33+
34+
35+
if __name__ == "__main__":
36+
main()

0 commit comments

Comments
 (0)