summaryrefslogtreecommitdiff
path: root/espanso/update_from_assets.py
blob: c1afcce9dc50dba2c93cfbb65dc7990934cdb498 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python3

import os


def generate(path, output_file, prefix):
    files = [
        f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))
    ]

    with open(output_file, 'w') as f:
        f.write('matches:\n')

        for file in files:
            path_wo_ext = os.path.splitext(file)[0]
            f.write('  - trigger: ;;' + prefix + path_wo_ext + '\n')
            f.write(
                '    image_path: $CONFIG/' + path + '/' + file + '\n')


if __name__ == '__main__':
    generate('assets/img', 'match/img.yml', 'i')