File: check.py

package info (click to toggle)
rime-emoji 0.0~git20250331.3dd83a2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 232 kB
  • sloc: python: 14; makefile: 4
file content (17 lines) | stat: -rw-r--r-- 541 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import re

errors: list[tuple[str, int, str]] = []

for name in ('emoji_category.txt', 'emoji_word.txt'):
    with open(f'opencc/{name}') as file:
        lines = file.readlines()
    for i, line in enumerate(lines):
        match = re.match(r'(\S+)\t(\S+)( \S+)+', line)
        if not match or match.group(1) != match.group(2):
            errors.append((name, i + 1, line[:-1] if line.endswith('\n') else line))

if errors:
    print('Format error')
    for error in errors:
        print(f'{error[0]}:{error[1]} {error[2]}')
    exit(1)