refactor: share env-bool parsing and logging setup
env_utils.env_bool replaces duplicated truthy parsing in config and rembg_cli. logging_config.configure_logging unifies entry-point setup. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+2
-7
@@ -18,12 +18,7 @@ import sys
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _env_bool(name: str, default: bool) -> bool:
|
||||
raw = os.environ.get(name)
|
||||
if raw is None:
|
||||
return default
|
||||
return raw.strip().lower() in {"1", "true", "yes", "on"}
|
||||
from .env_utils import env_bool
|
||||
|
||||
|
||||
def main() -> int:
|
||||
@@ -42,7 +37,7 @@ def main() -> int:
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
model = os.environ.get("REMBG_MODEL", "u2net")
|
||||
alpha = _env_bool("REMBG_ALPHA", True)
|
||||
alpha = env_bool("REMBG_ALPHA", True)
|
||||
session = new_session(model)
|
||||
output_path.write_bytes(
|
||||
remove(
|
||||
|
||||
Reference in New Issue
Block a user