Skip to content

Commit d8393d3

Browse files
committed
Remove left-over files and add a script to warn about new ones
1 parent a40745f commit d8393d3

File tree

2 files changed

+17
-223
lines changed

2 files changed

+17
-223
lines changed

library/email_util.po

-222
This file was deleted.

manage_translation.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
from collections import Counter
1717
import os
1818
from dataclasses import dataclass
19+
from pathlib import Path
1920
from re import match, search
2021
from subprocess import call, run
2122
import sys
2223
from urllib.parse import unquote
24+
from warnings import warn
2325

2426
LANGUAGE = 'pl'
2527

@@ -91,6 +93,20 @@ def recreate_tx_config():
9193
'source_lang = en\n',
9294
)
9395
)
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)
94110

95111

96112
@dataclass
@@ -259,7 +275,7 @@ def average(averages, weights):
259275

260276

261277
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')
263279

264280
parser = ArgumentParser()
265281
parser.add_argument('cmd', nargs=1, choices=RUNNABLE_SCRIPTS)

0 commit comments

Comments
 (0)