Skip to content

Commit

Permalink
Separate python files and UI files in the temporary PRO file (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Sep 7, 2020
1 parent c8369bc commit 38351f1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions qgispluginci/translation.py
Expand Up @@ -57,19 +57,25 @@ def update_strings(self):
"""
Update TS files from plugin source strings
"""
source_files = []
source_py_files = []
source_ui_files = []
relative_path = './{plugin_path}'.format(plugin_path=self.parameters.plugin_path)
for ext in ('py', 'ui'):
for file in glob.glob('{dir}/**/*.{ext}'.format(dir=self.parameters.plugin_path, ext=ext), recursive=True):
source_files.append(str(Path(file).relative_to(relative_path)))
file_path = str(Path(file).relative_to(relative_path))
if ext == 'py':
source_py_files.append(file_path)
else:
source_ui_files.append(file_path)

touch_file(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('SOURCES = {}\n'.format(' '.join(source_py_files)))
assert f.write('FORMS = {}\n'.format(' '.join(source_ui_files)))
assert f.write('TRANSLATIONS = {}\n'.format(Path(self.ts_file).relative_to(relative_path)))
f.flush()
f.close()
Expand Down

0 comments on commit 38351f1

Please sign in to comment.