Skip to content

Commit

Permalink
Merge pull request #1668 from freedomofpress/verify-mo-py3.8-compat
Browse files Browse the repository at this point in the history
chore: make `verify-mo.py` compatible with `securedrop`
  • Loading branch information
cfm authored Sep 28, 2023
2 parents 3167b91 + 84eb631 commit 3afd720
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions scripts/verify-mo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
import os
import shlex
import subprocess
from collections.abc import Iterator
from pathlib import Path
from types import TracebackType
from typing import Optional, Set
from typing import Any, Iterator, Optional, Set

import polib
from translate.tools.pocompile import convertmo
Expand All @@ -34,7 +32,8 @@
parser.add_argument(
"locale",
nargs="+",
help="""one or more locale directories, each of which must contain an "LC_MESSAGES" directory""",
help="""one or more locale directories, each of which must contain an
"LC_MESSAGES" directory""",
)
parser.add_argument(
"--domain", default="messages", help="""the gettext domain to load (defaults to "messages")"""
Expand All @@ -60,9 +59,9 @@ def __enter__(self) -> "CatalogVerifier":

def __exit__(
self,
exc_type: Optional[type[BaseException]],
exc_value: Optional[BaseException],
traceback: Optional[TracebackType],
exc_type: Optional[Any],
exc_value: Optional[Any],
traceback: Optional[Any],
) -> None:
"""Clean up."""

Expand Down Expand Up @@ -99,7 +98,7 @@ def diffoscope_args(self, a: Path, b: Path, filtered: bool = True) -> Iterator[s
for stray in self.strays:
yield f"--diff-mask {shlex.quote(stray)}" # tell diffoscope to mask strays
yield "| grep -Fv '[masked]'" # ignore things we've masked
yield "| grep -E '│ (-|\+)msg(id|str)'" # ignore context; we only care about real diffs
yield "| grep -E '│ (-|\\+)msg(id|str)'" # ignore context; we only care about real diffs

def diffoscope_call(
self, a: Path, b: Path, filtered: bool = True
Expand All @@ -113,7 +112,8 @@ def diffoscope_call(
# We silence Bandit and Semgrep warnings on `shell=True`
# because we want to inherit the Python virtual environment
# in which we're invoked.
return subprocess.run( # nosec B602 nosemgrep: python.lang.security.audit.subprocess-shell-true.subprocess-shell-true
# nosemgrep: python.lang.security.audit.subprocess-shell-true.subprocess-shell-true
return subprocess.run( # nosec B602
cmd,
capture_output=True,
env=os.environ,
Expand Down

0 comments on commit 3afd720

Please sign in to comment.