From 5b0f1aecb6c72e599258a80e5dc46f6d4958197e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Fri, 10 Feb 2023 10:55:27 +0100 Subject: [PATCH] fix: remove unused functions --- robotoff/prediction/ocr/core.py | 36 +-------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/robotoff/prediction/ocr/core.py b/robotoff/prediction/ocr/core.py index 69898f4dcf..fb5064ac09 100644 --- a/robotoff/prediction/ocr/core.py +++ b/robotoff/prediction/ocr/core.py @@ -4,11 +4,9 @@ import requests -from robotoff.off import generate_json_ocr_url, get_barcode_from_path, split_barcode from robotoff.prediction.types import Prediction -from robotoff.settings import BaseURLProvider from robotoff.types import JSONType, PredictionType -from robotoff.utils import get_logger, http_session, jsonl_iter, jsonl_iter_fp +from robotoff.utils import get_logger, jsonl_iter, jsonl_iter_fp from .brand import find_brands from .category import find_category @@ -50,22 +48,6 @@ } -def fetch_images_for_ean(ean: str): - url = BaseURLProvider.world() + "/api/v0/product/{}.json?fields=images".format(ean) - images = http_session.get(url).json() - return images - - -def get_json_for_image(barcode: str, image_id: str) -> Optional[JSONType]: - url = generate_json_ocr_url(barcode, image_id) - r = http_session.get(url) - - if r.status_code == 404: - return None - - return r.json() - - def get_ocr_result( ocr_url: str, session: requests.Session, error_raise: bool = True ) -> Optional[OCRResult]: @@ -123,22 +105,6 @@ def extract_predictions( raise ValueError(f"unknown prediction type: {prediction_type}") -def is_barcode(text: str): - return text.isdigit() - - -def get_source( - image_name: str, json_path: Optional[str] = None, barcode: Optional[str] = None -) -> str: - if not barcode: - barcode = get_barcode_from_path(str(json_path)) - - if not barcode: - raise ValueError("invalid JSON path: {}".format(json_path)) - - return "/{}/{}.jpg" "".format("/".join(split_barcode(barcode)), image_name) - - def ocr_content_iter(items: Iterable[JSONType]) -> Iterable[tuple[Optional[str], dict]]: for item in items: if "content" in item: