Add function to compare translated strings between two commits by guilhermesrc · Pull Request #138 · python/python-docs-pt-br · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Add function to compare translated strings between two commits #138

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

Open
wants to merge 8 commits into
base: 3.12
Choose a base branch
from
28 changes: 28 additions & 0 deletions .github/scripts/get_translated_strings_between_commits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import subprocess
from pathlib import Path
import re

absolute_path = Path(__file__).resolve().parents[2]
pattern_translated_strings = r'Translated:\s+(\d+)'


def run_os_command(command):
try:
return subprocess.check_output(command, shell=True, text=True)
except subprocess.CalledProcessError as e:
print(f"Error executing command '{command}': {e}")
return None


def get_translated_commit_strings(commit_hash):
run_os_command(f"git switch --force {commit_hash} --detach")
pocount_of_commit = run_os_command(f"pocount {absolute_path}/*.po {absolute_path}/**/*.po")
all_translated_results = re.findall(pattern_translated_strings, pocount_of_commit, re.DOTALL)
total_of_translated_commit_strings = int(all_translated_results[-1])
return total_of_translated_commit_strings


def get_difference_between_translated_commits_strings(commit_hash1, commit_hash2):
commit_hash1_count = get_translated_commit_strings(commit_hash1)
commit_hash2_count = get_translated_commit_strings(commit_hash2)
return commit_hash1_count - commit_hash2_count

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.