Skip to content

Commit a77da15

Browse files
committed
refatorando run_os_command e get_translated_strings_between_commits.py
1 parent bbc6015 commit a77da15

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

.github/scripts/get_translated_strings_between_commits.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
pattern_translated_strings = r'Translated:\s+(\d+)'
88

99

10-
def run_git_command(command):
10+
def run_os_command(command):
1111
try:
1212
return os.popen(command).read()
1313
except Exception as e:
14-
print(f"Error executing Git command: {e}")
14+
print(f"Error executing OS command: {e}")
1515
return ""
1616

1717

1818
def get_translated_commit_strings(commit_hash):
1919
try:
20-
run_git_command(f"git switch {commit_hash} --detach")
21-
output = os.popen(f"pocount {absolute_path}/*.po {absolute_path}/**/*.po").read()
22-
all_translated_results = re.findall(pattern_translated_strings, output, re.DOTALL)
23-
translated_commit_strings = int(all_translated_results[-1])
24-
return translated_commit_strings
20+
run_os_command(f"git switch --force {commit_hash} --detach")
21+
pocount_of_commit = run_os_command(f"pocount {absolute_path}/*.po {absolute_path}/**/*.po")
22+
all_translated_results = re.findall(pattern_translated_strings, pocount_of_commit, re.DOTALL)
23+
total_of_translated_commit_strings = int(all_translated_results[-1])
24+
return total_of_translated_commit_strings
2525
except Exception as e:
2626
print(f"Error getting translated strings count: {e}")
2727
return 0
@@ -35,9 +35,3 @@ def get_difference_between_translated_commits_strings(commit_hash1, commit_hash2
3535
except Exception as e:
3636
print(f"Error calculating the difference between translated strings counts: {e}")
3737
return 0
38-
39-
40-
hash1 = "69ff2f8a3141f5aad0f968e76675830a158660c6"
41-
hash2 = "fa5d1cea27abe701398ee8fe7ee5ba285fafeee2"
42-
43-
print(get_difference_between_translated_commits_strings(hash1, hash2))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy