Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix bug with md2po --no-obsolete #318

Merged
merged 3 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 45 additions & 20 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,49 @@ set -ex

rm -rf build dist
export TMPDIR=/var/tmp/
export PYI_LOG_LEVEL=WARN

pyinstaller -y --onefile \
--optimize 2 \
--name md2po \
--copy-metadata mdpo \
src/mdpo/md2po/__main__.py
pyinstaller -y --onefile \
--optimize 2 \
--name po2md \
--copy-metadata mdpo \
src/mdpo/po2md/__main__.py
pyinstaller -y --onefile \
--optimize 2 \
--name md2po2md \
--copy-metadata mdpo \
src/mdpo/md2po2md/__main__.py
pyinstaller -y --onefile \
--optimize 2 \
--name mdpo2html \
--copy-metadata mdpo \
src/mdpo/mdpo2html/__main__.py
mdpo() {
pyinstaller -y --onefile \
--optimize 2 \
--name md2po \
--copy-metadata mdpo \
src/mdpo/md2po/__main__.py
}

po2md() {
pyinstaller -y --onefile \
--optimize 2 \
--name po2md \
--copy-metadata mdpo \
src/mdpo/po2md/__main__.py
}

md2po2md() {
pyinstaller -y --onefile \
--optimize 2 \
--name md2po2md \
--copy-metadata mdpo \
src/mdpo/md2po2md/__main__.py
}

mdpo2html() {
pyinstaller -y --onefile \
--optimize 2 \
--name mdpo2html \
--copy-metadata mdpo \
src/mdpo/mdpo2html/__main__.py
}

# Parallel build on Linux
if [ $(uname) = "Linux" ]; then
mdpo &
po2md &
md2po2md &
mdpo2html
else
mdpo
po2md
md2po2md
mdpo2html
fi
5 changes: 3 additions & 2 deletions src/mdpo/md2po/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,11 +1044,12 @@ def _parse(content):
self.found_entries,
)
elif self.mark_not_found_as_obsolete:
mark_not_found_entries_as_obsoletes(
obsoletes = mark_not_found_entries_as_obsoletes(
self.pofile,
self.found_entries,
)
self.obsoletes = True
if not self.obsoletes:
self.obsoletes = obsoletes

if self.metadata:
self.pofile.metadata.update(self.metadata)
Expand Down
3 changes: 3 additions & 0 deletions src/mdpo/po.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def mark_not_found_entries_as_obsoletes(
will be marked as obsoletes.
entries (list): Entries to search against.
"""
obsolete = False
for entry in pofile:
if not find_entry_in_entries(
entry,
Expand All @@ -78,8 +79,10 @@ def mark_not_found_entries_as_obsoletes(
pofile.remove(entry)
else:
entry.obsolete = True
obsolete = True
else:
entry.obsolete = False
return obsolete


def remove_not_found_entries(pofile, entries):
Expand Down
5 changes: 1 addition & 4 deletions tests/test_unit/test_md2po/test_md2po_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,12 +771,9 @@ def test_no_obsolete(capsys, arg, tmp_file):
pofile, exitcode = run([arg, '-p', filename, '--no-location', 'Bye'])
stdout, stderr = capsys.readouterr()

assert exitcode == 3
assert exitcode == 0
assert f'{pofile}\n' == expected_output
assert stdout == expected_output
assert stderr == (
f"Obsolete messages found at {filename} and passed '--no-obsolete'\n"
)


@pytest.mark.parametrize('arg', ('--no-empty-msgstr',))
Expand Down
Loading