1
0
mirror of https://github.com/slgobinath/SafeEyes.git synced 2024-12-17 23:08:38 +01:00

setup.py: refactor mo building to use pathlib

This commit is contained in:
deltragon 2024-08-26 16:25:32 +02:00
parent 38b80b2ae9
commit 300cad2b8f

View File

@ -38,24 +38,22 @@ class BuildMoSubCommand(Command):
files = {} files = {}
localedir = 'safeeyes/config/locale' localedir = Path('safeeyes/config/locale')
po_dirs = [localedir + '/' + l + '/LC_MESSAGES/' po_dirs = [l.joinpath('LC_MESSAGES') for l in localedir.iterdir() if l.is_dir()]
for l in next(os.walk(localedir))[1]]
for po_dir in po_dirs: for po_dir in po_dirs:
po_files = [f po_files = [f
for f in next(os.walk(po_dir))[2] for f in po_dir.iterdir()
if os.path.splitext(f)[1] == '.po'] if f.is_file() and f.suffix == '.po']
for po_file in po_files: for po_file in po_files:
filename, _ = os.path.splitext(po_file) mo_file = po_file.with_suffix(".mo")
mo_file = filename + '.mo'
source_file = po_dir + po_file source_file = po_file
build_file = mo_file
build_file = po_dir + mo_file
if not self.editable_mode: if not self.editable_mode:
build_file = os.path.join(self.build_lib, build_file) build_file = Path(self.build_lib).joinpath(build_file)
files[build_file] = source_file files[str(build_file)] = str(source_file)
self.files = files self.files = files
return files return files