cove-scripts/count_parentheses.py

24 lines
522 B
Python

import json
from argparse import ArgumentParser
from pathlib import Path
from typing import Counter
def main():
parser = ArgumentParser()
parser.add_argument("path", type=Path)
args = parser.parse_args()
chars = Counter[str]()
with open(args.path) as f:
print("Reading lines")
for line in f:
content = json.loads(line)["content"]
chars += Counter(content)
for c in "()[]{}<>":
print(f"{c} - {chars[c]:6}")
if __name__ == "__main__":
main()