Skip to content

Commit 964d587

Browse files
committed
alterando biblioteca de manipulação com o sistema e retirando try excepts desnecessarios
1 parent 1ad887c commit 964d587

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed
Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os
1+
import subprocess
22
from pathlib import Path
33
import re
44

@@ -8,29 +8,21 @@
88

99
def run_os_command(command):
1010
try:
11-
return os.popen(command).read()
12-
except Exception as e:
13-
print(f"Error executing OS command: {e}")
14-
return ""
11+
return subprocess.check_output(command, shell=True, text=True)
12+
except subprocess.CalledProcessError as e:
13+
print(f"Error executing command '{command}': {e}")
14+
return None
1515

1616

1717
def get_translated_commit_strings(commit_hash):
18-
try:
19-
run_os_command(f"git switch --force {commit_hash} --detach")
20-
pocount_of_commit = run_os_command(f"pocount {absolute_path}/*.po {absolute_path}/**/*.po")
21-
all_translated_results = re.findall(pattern_translated_strings, pocount_of_commit, re.DOTALL)
22-
total_of_translated_commit_strings = int(all_translated_results[-1])
23-
return total_of_translated_commit_strings
24-
except Exception as e:
25-
print(f"Error getting translated strings count: {e}")
26-
return 0
18+
run_os_command(f"git switch --force {commit_hash} --detach")
19+
pocount_of_commit = run_os_command(f"pocount {absolute_path}/*.po {absolute_path}/**/*.po")
20+
all_translated_results = re.findall(pattern_translated_strings, pocount_of_commit, re.DOTALL)
21+
total_of_translated_commit_strings = int(all_translated_results[-1])
22+
return total_of_translated_commit_strings
2723

2824

2925
def get_difference_between_translated_commits_strings(commit_hash1, commit_hash2):
30-
try:
31-
commit_hash1_count = get_translated_commit_strings(commit_hash1)
32-
commit_hash2_count = get_translated_commit_strings(commit_hash2)
33-
return commit_hash1_count - commit_hash2_count
34-
except Exception as e:
35-
print(f"Error calculating the difference between translated strings counts: {e}")
36-
return 0
26+
commit_hash1_count = get_translated_commit_strings(commit_hash1)
27+
commit_hash2_count = get_translated_commit_strings(commit_hash2)
28+
return commit_hash1_count - commit_hash2_count

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