File: symbols-merge.py

package info (click to toggle)
vim-vimtex 2.16-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,660 kB
  • sloc: makefile: 367; python: 103
file content (34 lines) | stat: -rwxr-xr-x 869 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
"""Add symbols to complete files"""
import os


with open('tools/symbols') as f:
    D = dict([line.strip().split(' ') for line in f.readlines()])


def merge(filename):
    """Do the actions"""
    changed = False
    lines = []
    with open(filename) as f:
        for line in f.readlines():
            parts = line.strip().split()
            if len(parts) > 0:
                command = parts[0]
                symbol = D.get(command, '')
                if symbol:
                    changed = True
                    symbol = ' ' + symbol
                lines.append(command + symbol + "\n")

    if changed:
        print('Updated: ',filename)
        with open(filename, 'w') as f:
            for line in lines:
                f.write(line)


files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
    merge(f)