Skip to content

Commit

Permalink
Fixed all linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pescheck-bram committed Aug 21, 2024
1 parent d961e7b commit cf20b58
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions python_gpt_po/po_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ def disable_fuzzy_translations(po_file_path):
# Read the file content
with open(po_file_path, 'r', encoding='utf-8') as file:
content = file.read()

# Remove fuzzy markers from the content
content = content.replace('#, fuzzy\n', '')

# Write the updated content back to the file
with open(po_file_path, 'w', encoding='utf-8') as file:
file.write(content)

# Load the .po file and remove fuzzy flags from entries
po_file = polib.pofile(po_file_path)
fuzzy_entries = [entry for entry in po_file if 'fuzzy' in entry.flags]
for entry in fuzzy_entries:
entry.flags.remove('fuzzy')

# Remove 'Fuzzy' from the metadata if present
if po_file.metadata:
po_file.metadata.pop('Fuzzy', None)

# Save the updated .po file
po_file.save(po_file_path)
logging.info("Fuzzy translations disabled in file: %s", po_file_path)

except Exception as e:
logging.error("Error while disabling fuzzy translations in file %s: %s", po_file_path, e)

Expand All @@ -76,7 +76,7 @@ def log_translation_status(po_file_path, original_texts, translations):
"""Logs the status of translations for a .po file."""
total = len(original_texts)
translated = sum(1 for t in translations if t)

# Log a warning if there are untranslated texts
if translated < total:
logging.warning(
Expand Down Expand Up @@ -233,7 +233,7 @@ def get_translation_prompt(target_language, is_bulk):
@retry(stop=stop_after_attempt(3), wait=wait_fixed(2))
def perform_translation(self, texts, target_language, is_bulk=False):
"""Performs the actual translation using the OpenAI API."""
logging.info(f"Performing translation to: {target_language}") # Log the target language
logging.debug("Performing translation to: %s", target_language) # Log the target language
prompt = self.get_translation_prompt(target_language, is_bulk)
message = {
"role": "user",
Expand Down

0 comments on commit cf20b58

Please sign in to comment.