cove-scripts/count_parentheses.py
2025-10-23 01:44:36 +02:00

31 lines
750 B
Python

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