|
16 | 16 | from collections import Counter
|
17 | 17 | import os
|
18 | 18 | from dataclasses import dataclass
|
| 19 | +from pathlib import Path |
19 | 20 | from re import match, search
|
20 | 21 | from subprocess import call, run
|
21 | 22 | import sys
|
22 | 23 | from urllib.parse import unquote
|
| 24 | +from warnings import warn |
23 | 25 |
|
24 | 26 | LANGUAGE = 'pl'
|
25 | 27 |
|
@@ -91,6 +93,20 @@ def recreate_tx_config():
|
91 | 93 | 'source_lang = en\n',
|
92 | 94 | )
|
93 | 95 | )
|
| 96 | + warn_about_files_to_delete() |
| 97 | + |
| 98 | +def warn_about_files_to_delete(): |
| 99 | + files = list(_get_files_to_delete()) |
| 100 | + if not files: |
| 101 | + return |
| 102 | + warn(f'Found {len(files)} file(s) to delete: {", ".join(files)}.') |
| 103 | + |
| 104 | +def _get_files_to_delete(): |
| 105 | + with open('.tx/config') as config_file: |
| 106 | + config = config_file.read() |
| 107 | + for file in Path().rglob('*.po'): |
| 108 | + if os.fsdecode(file) not in config: |
| 109 | + yield os.fsdecode(file) |
94 | 110 |
|
95 | 111 |
|
96 | 112 | @dataclass
|
@@ -259,7 +275,7 @@ def average(averages, weights):
|
259 | 275 |
|
260 | 276 |
|
261 | 277 | if __name__ == "__main__":
|
262 |
| - RUNNABLE_SCRIPTS = ('fetch', 'recreate_tx_config', 'recreate_readme') |
| 278 | + RUNNABLE_SCRIPTS = ('fetch', 'recreate_tx_config', 'recreate_readme', 'warn_about_files_to_delete') |
263 | 279 |
|
264 | 280 | parser = ArgumentParser()
|
265 | 281 | parser.add_argument('cmd', nargs=1, choices=RUNNABLE_SCRIPTS)
|
|
0 commit comments