mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-07-20 20:11:10 +00:00
refactor(codebase): format
This commit is contained in:
@@ -93,13 +93,17 @@ def ensure_package_installed(from_code, to_code):
|
||||
if pkg_to_install:
|
||||
print_info(f"Downloading package: {pkg_to_install}")
|
||||
argostranslate.package.install_from_path(pkg_to_install.download())
|
||||
print_success(f"Successfully installed package: {from_code} -> {to_code}")
|
||||
print_success(
|
||||
f"Successfully installed package: {from_code} -> {to_code}"
|
||||
)
|
||||
|
||||
# Refresh installed languages
|
||||
installed = argostranslate.translate.get_installed_languages()
|
||||
installed_dict = {lang.code: lang for lang in installed}
|
||||
else:
|
||||
print_error(f"Could not find a translation package for {from_code} -> {to_code}")
|
||||
print_error(
|
||||
f"Could not find a translation package for {from_code} -> {to_code}"
|
||||
)
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print_error(f"Failed to install language package: {e}")
|
||||
@@ -174,7 +178,9 @@ def translate_dict(data, translate_func, target_name=None):
|
||||
translated_temp = translate_func(temp_text)
|
||||
return restore_vars_from_tokens(translated_temp, vars_found)
|
||||
except Exception as e:
|
||||
print_warning(f"Failed to translate '{data}': {e}. Falling back to original.")
|
||||
print_warning(
|
||||
f"Failed to translate '{data}': {e}. Falling back to original."
|
||||
)
|
||||
return data
|
||||
else:
|
||||
return data
|
||||
@@ -184,7 +190,9 @@ def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Translate JSON localization files using Argos Translate."
|
||||
)
|
||||
parser.add_argument("--from", dest="from_lang", help="Source language code (e.g. 'en')")
|
||||
parser.add_argument(
|
||||
"--from", dest="from_lang", help="Source language code (e.g. 'en')"
|
||||
)
|
||||
parser.add_argument("--to", dest="to_lang", help="Target language code (e.g. 'zh')")
|
||||
parser.add_argument("--input", dest="input_file", help="Path to input JSON file")
|
||||
parser.add_argument("--output", dest="output_file", help="Path to output JSON file")
|
||||
@@ -232,7 +240,9 @@ def main():
|
||||
# Get Translator
|
||||
translate_func = get_translation_func(from_lang, to_lang)
|
||||
|
||||
print_info("Starting translation. This may take a moment depending on the file size...")
|
||||
print_info(
|
||||
"Starting translation. This may take a moment depending on the file size..."
|
||||
)
|
||||
translated_data = translate_dict(source_data, translate_func, target_name)
|
||||
|
||||
# Ensure output directory exists
|
||||
|
||||
@@ -240,7 +240,9 @@ def main(argv: list[str] | None = None) -> int:
|
||||
)
|
||||
|
||||
if _is_truthy(os.environ.get("MESHCHATX_SKIP_DOCS_FETCH")):
|
||||
logging.info("MESHCHATX_SKIP_DOCS_FETCH is set; skipping Reticulum manual fetch.")
|
||||
logging.info(
|
||||
"MESHCHATX_SKIP_DOCS_FETCH is set; skipping Reticulum manual fetch."
|
||||
)
|
||||
return 0
|
||||
|
||||
sources: list[str] = []
|
||||
|
||||
@@ -14,7 +14,9 @@ def _source_uri() -> str:
|
||||
server = (
|
||||
os.environ.get("GITHUB_SERVER_URL") or os.environ.get("GITEA_SERVER_URL") or ""
|
||||
).rstrip("/")
|
||||
repo = os.environ.get("GITHUB_REPOSITORY") or os.environ.get("GITEA_REPOSITORY") or ""
|
||||
repo = (
|
||||
os.environ.get("GITHUB_REPOSITORY") or os.environ.get("GITEA_REPOSITORY") or ""
|
||||
)
|
||||
if not server or not repo:
|
||||
return ""
|
||||
if server.startswith(("https://", "http://")):
|
||||
@@ -29,7 +31,9 @@ def _build_type() -> str:
|
||||
server = (
|
||||
os.environ.get("GITHUB_SERVER_URL") or os.environ.get("GITEA_SERVER_URL") or ""
|
||||
).rstrip("/")
|
||||
repo = os.environ.get("GITHUB_REPOSITORY") or os.environ.get("GITEA_REPOSITORY") or ""
|
||||
repo = (
|
||||
os.environ.get("GITHUB_REPOSITORY") or os.environ.get("GITEA_REPOSITORY") or ""
|
||||
)
|
||||
if server and repo:
|
||||
return f"{server}/{repo}/.gitea/workflows/build.yml"
|
||||
return "https://slsa.dev/provenance/v1"
|
||||
|
||||
Reference in New Issue
Block a user