Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Create temporary .pro file to make pylupdate5 work with unicode chars #19

Merged
merged 1 commit into from Jul 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 19 additions & 4 deletions qgispluginci/translation.py
@@ -1,6 +1,7 @@

import glob
import subprocess
from pathlib import Path
from pytransifex import Transifex
from qgispluginci.parameters import Parameters
from qgispluginci.exceptions import TranslationFailed, TransifexNoResource, TransifexManyResources
Expand Down Expand Up @@ -56,14 +57,28 @@ def update_strings(self):
"""
Update TS files from plugin source strings
"""
cmd = [self.parameters.pylupdate5_path, '-noobsolete']
source_files = []
for ext in ('py', 'ui'):
for file in glob.glob('{dir}/**/*.{ext}'.format(dir=self.parameters.plugin_path, ext=ext), recursive=True):
cmd.append(file)
source_files.append(str(Path(file).relative_to('./qgis_plugin_ci_testing')))

touch_file(self.ts_file)
cmd.append('-ts')
cmd.append(self.ts_file)

project_file = Path(self.parameters.plugin_path).joinpath(self.parameters.plugin_name + '.pro')

with open(project_file, 'w') as f:
assert f.write('CODECFORTR = UTF-8\n')
assert f.write('SOURCES = {}\n'.format(' '.join(source_files)))
assert f.write('TRANSLATIONS = {}\n'.format(Path(self.ts_file).relative_to('./qgis_plugin_ci_testing')))
f.flush()
f.close()

cmd = [self.parameters.pylupdate5_path, '-noobsolete', str(project_file)]

output = subprocess.run(cmd, capture_output=True, text=True)

project_file.unlink()

if output.returncode != 0:
raise TranslationFailed(output.stderr)
else:
Expand Down