Skip to content

Commit

Permalink
format products
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianMindee committed Oct 11, 2023
1 parent 2b34142 commit 16ca8e0
Show file tree
Hide file tree
Showing 33 changed files with 151 additions and 65 deletions.
5 changes: 3 additions & 2 deletions mindee/product/barcode_reader/barcode_reader_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ def __str__(self) -> str:
codes_2d = f"\n { ' ' * 13 }".join(
[str(item) for item in self.codes_2d],
)

return clean_out_string(f":Barcodes 1D: {codes_1d}\n" f":Barcodes 2D: {codes_2d}\n")
return clean_out_string(
f":Barcodes 1D: {codes_1d}\n" f":Barcodes 2D: {codes_2d}\n"
)
1 change: 0 additions & 1 deletion mindee/product/cropper/cropper_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
class CropperV1Document(Prediction):
"""Document data for Cropper, API version 1."""


def __str__(self) -> str:
return ""
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ def __str__(self) -> str:
license_plates = f"\n { ' ' * 16 }".join(
[str(item) for item in self.license_plates],
)

return clean_out_string(f":License Plates: {license_plates}\n")
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Taxes,
)
from mindee.product.financial_document.financial_document_v1_line_item import (
FinancialDocumentV1LineItem,
FinancialDocumentV1LineItem,
)


Expand Down Expand Up @@ -213,7 +213,6 @@ def __str__(self) -> str:
supplier_payment_details = f"\n { ' ' * 26 }".join(
[str(item) for item in self.supplier_payment_details],
)

return clean_out_string(
f":Locale: {self.locale}\n"
f":Invoice Number: {self.invoice_number}\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def __init__(
)

def __str__(self) -> str:

return clean_out_string(
f":IBAN: {self.iban}\n"
f":Account Holder's Name: {self.account_holder_name}\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mindee.parsing.common import Prediction, StringDict, clean_out_string
from mindee.parsing.standard import StringField
from mindee.product.fr.bank_account_details.bank_account_details_v2_bban import (
BankAccountDetailsV2Bban,
BankAccountDetailsV2Bban,
)


Expand Down Expand Up @@ -48,7 +48,6 @@ def __init__(
)

def __str__(self) -> str:

return clean_out_string(
f":Account Holder's Names: {self.account_holders_names}\n"
f":Basic Bank Account Number:\n{self.bban.to_field_list()}\n"
Expand Down
1 change: 0 additions & 1 deletion mindee/product/fr/carte_vitale/carte_vitale_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __str__(self) -> str:
given_names = f"\n { ' ' * 15 }".join(
[str(item) for item in self.given_names],
)

return clean_out_string(
f":Given Name(s): {given_names}\n"
f":Surname: {self.surname}\n"
Expand Down
1 change: 0 additions & 1 deletion mindee/product/fr/id_card/id_card_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def __str__(self) -> str:
given_names = f"\n { ' ' * 15 }".join(
[str(item) for item in self.given_names],
)

return clean_out_string(
f":Identity Number: {self.id_number}\n"
f":Given Name(s): {given_names}\n"
Expand Down
1 change: 0 additions & 1 deletion mindee/product/fr/id_card/id_card_v2_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def __str__(self) -> str:
given_names = f"\n { ' ' * 15 }".join(
[str(item) for item in self.given_names],
)

return clean_out_string(
f":Nationality: {self.nationality}\n"
f":Card Access Number: {self.card_access_number}\n"
Expand Down
3 changes: 2 additions & 1 deletion mindee/product/fr/id_card/id_card_v2_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ def __init__(

def __str__(self) -> str:
return clean_out_string(
f":Document Type: {self.document_type}\n" f":Document Sides: {self.document_side}\n" + f"{super().__str__()}"
f":Document Type: {self.document_type}\n"
f":Document Sides: {self.document_side}\n" + f"{super().__str__()}"
)
1 change: 0 additions & 1 deletion mindee/product/invoice/invoice_v4_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def __str__(self) -> str:
supplier_payment_details = f"\n { ' ' * 26 }".join(
[str(item) for item in self.supplier_payment_details],
)

return clean_out_string(
f":Locale: {self.locale}\n"
f":Invoice Number: {self.invoice_number}\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ def __str__(self) -> str:
receipts = f"\n { ' ' * 18 }".join(
[str(item) for item in self.receipts],
)

return clean_out_string(f":List of Receipts: {receipts}\n")
1 change: 0 additions & 1 deletion mindee/product/passport/passport_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def __str__(self) -> str:
given_names = f"\n { ' ' * 15 }".join(
[str(item) for item in self.given_names],
)

return clean_out_string(
f":Country Code: {self.country}\n"
f":ID Number: {self.id_number}\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def __str__(self) -> str:
recipient_company_registration = f"\n { ' ' * 33 }".join(
[str(item) for item in self.recipient_company_registration],
)

return clean_out_string(
f":Locale: {self.locale}\n"
f":Issuer Name: {self.issuer_name}\n"
Expand Down
1 change: 0 additions & 1 deletion mindee/product/receipt/receipt_v5_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def __str__(self) -> str:
supplier_company_registrations = f"\n { ' ' * 32 }".join(
[str(item) for item in self.supplier_company_registrations],
)

return clean_out_string(
f":Expense Locale: {self.locale}\n"
f":Purchase Category: {self.category}\n"
Expand Down
1 change: 0 additions & 1 deletion mindee/product/us/bank_check/bank_check_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def __str__(self) -> str:
payees = f"\n { ' ' * 8 }".join(
[str(item) for item in self.payees],
)

return clean_out_string(
f":Check Issue Date: {self.date}\n"
f":Amount: {self.amount}\n"
Expand Down
3 changes: 2 additions & 1 deletion mindee/product/us/bank_check/bank_check_v1_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ def __str__(self) -> str:
[str(item) for item in self.signatures_positions],
)
return clean_out_string(
f":Check Position: {self.check_position}\n" f":Signature Positions: {signatures_positions}\n" + f"{super().__str__()}"
f":Check Position: {self.check_position}\n"
f":Signature Positions: {signatures_positions}\n" + f"{super().__str__()}"
)
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def __init__(
)

def __str__(self) -> str:

return clean_out_string(
f":State: {self.state}\n"
f":Driver License ID: {self.driver_license_id}\n"
Expand Down
3 changes: 2 additions & 1 deletion mindee/product/us/driver_license/driver_license_v1_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ def __init__(

def __str__(self) -> str:
return clean_out_string(
f":Photo: {self.photo}\n" f":Signature: {self.signature}\n" + f"{super().__str__()}"
f":Photo: {self.photo}\n"
f":Signature: {self.signature}\n" + f"{super().__str__()}"
)
1 change: 0 additions & 1 deletion mindee/product/us/w9/w9_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
class W9V1Document(Prediction):
"""Document data for W9, API version 1."""


def __str__(self) -> str:
return ""
4 changes: 2 additions & 2 deletions mindee/product/us/w9/w9_v1_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __init__(

def __str__(self) -> str:
return clean_out_string(

f":Name: {self.name}\n"
f":SSN: {self.ssn}\n"
f":Address: {self.address}\n"
Expand All @@ -108,5 +107,6 @@ def __str__(self) -> str:
f":W9 Revision Date: {self.w9_revision_date}\n"
f":Signature Position: {self.signature_position}\n"
f":Signature Date Position: {self.signature_date_position}\n"
f":Tax Classification LLC: {self.tax_classification_llc}\n" + f"{super().__str__()}"
f":Tax Classification LLC: {self.tax_classification_llc}\n"
+ f"{super().__str__()}"
)
8 changes: 6 additions & 2 deletions tests/product/barcode_reader/test_barcode_reader_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def complete_page_0() -> Page[BarcodeReaderV1Document]:
return Page(BarcodeReaderV1Document, json_data["document"]["inference"]["pages"][0])


def test_complete_doc(complete_doc: Document[BarcodeReaderV1Document, Page[BarcodeReaderV1Document]]):
def test_complete_doc(
complete_doc: Document[BarcodeReaderV1Document, Page[BarcodeReaderV1Document]]
):
reference_str = open(
PRODUCT_DATA_DIR / "barcode_reader" / "response_v1" / "summary_full.rst",
"r",
Expand All @@ -44,7 +46,9 @@ def test_complete_doc(complete_doc: Document[BarcodeReaderV1Document, Page[Barco
assert str(complete_doc) == reference_str


def test_empty_doc(empty_doc: Document[BarcodeReaderV1Document, Page[BarcodeReaderV1Document]]):
def test_empty_doc(
empty_doc: Document[BarcodeReaderV1Document, Page[BarcodeReaderV1Document]]
):
prediction = empty_doc.inference.prediction
assert len(prediction.codes_1d) == 0
assert len(prediction.codes_2d) == 0
Expand Down
8 changes: 6 additions & 2 deletions tests/product/eu/license_plate/test_license_plate_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def complete_page_0() -> Page[LicensePlateV1Document]:
return Page(LicensePlateV1Document, json_data["document"]["inference"]["pages"][0])


def test_complete_doc(complete_doc: Document[LicensePlateV1Document, Page[LicensePlateV1Document]]):
def test_complete_doc(
complete_doc: Document[LicensePlateV1Document, Page[LicensePlateV1Document]]
):
reference_str = open(
PRODUCT_DATA_DIR / "license_plates" / "response_v1" / "summary_full.rst",
"r",
Expand All @@ -44,7 +46,9 @@ def test_complete_doc(complete_doc: Document[LicensePlateV1Document, Page[Licens
assert str(complete_doc) == reference_str


def test_empty_doc(empty_doc: Document[LicensePlateV1Document, Page[LicensePlateV1Document]]):
def test_empty_doc(
empty_doc: Document[LicensePlateV1Document, Page[LicensePlateV1Document]]
):
prediction = empty_doc.inference.prediction
assert len(prediction.license_plates) == 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@


@pytest.fixture
def complete_doc() -> Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]:
def complete_doc() -> (
Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]
):
json_data = json.load(
open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "complete.json")
open(
PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "complete.json"
)
)
return Document(BankAccountDetailsV1, json_data["document"])


@pytest.fixture
def empty_doc() -> Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]:
def empty_doc() -> (
Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]
):
json_data = json.load(
open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "empty.json")
)
Expand All @@ -30,12 +36,20 @@ def empty_doc() -> Document[BankAccountDetailsV1Document, Page[BankAccountDetail
@pytest.fixture
def complete_page_0() -> Page[BankAccountDetailsV1Document]:
json_data = json.load(
open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "complete.json")
open(
PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "complete.json"
)
)
return Page(
BankAccountDetailsV1Document, json_data["document"]["inference"]["pages"][0]
)
return Page(BankAccountDetailsV1Document, json_data["document"]["inference"]["pages"][0])


def test_complete_doc(complete_doc: Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]):
def test_complete_doc(
complete_doc: Document[
BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]
]
):
reference_str = open(
PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "summary_full.rst",
"r",
Expand All @@ -44,7 +58,11 @@ def test_complete_doc(complete_doc: Document[BankAccountDetailsV1Document, Page[
assert str(complete_doc) == reference_str


def test_empty_doc(empty_doc: Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]):
def test_empty_doc(
empty_doc: Document[
BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]
]
):
prediction = empty_doc.inference.prediction
assert prediction.iban.value is None
assert prediction.account_holder_name.value is None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@


@pytest.fixture
def complete_doc() -> Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]:
def complete_doc() -> (
Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]
):
json_data = json.load(
open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "complete.json")
open(
PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "complete.json"
)
)
return Document(BankAccountDetailsV2, json_data["document"])


@pytest.fixture
def empty_doc() -> Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]:
def empty_doc() -> (
Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]
):
json_data = json.load(
open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "empty.json")
)
Expand All @@ -30,12 +36,20 @@ def empty_doc() -> Document[BankAccountDetailsV2Document, Page[BankAccountDetail
@pytest.fixture
def complete_page_0() -> Page[BankAccountDetailsV2Document]:
json_data = json.load(
open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "complete.json")
open(
PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "complete.json"
)
)
return Page(
BankAccountDetailsV2Document, json_data["document"]["inference"]["pages"][0]
)
return Page(BankAccountDetailsV2Document, json_data["document"]["inference"]["pages"][0])


def test_complete_doc(complete_doc: Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]):
def test_complete_doc(
complete_doc: Document[
BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]
]
):
reference_str = open(
PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "summary_full.rst",
"r",
Expand All @@ -44,7 +58,11 @@ def test_complete_doc(complete_doc: Document[BankAccountDetailsV2Document, Page[
assert str(complete_doc) == reference_str


def test_empty_doc(empty_doc: Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]):
def test_empty_doc(
empty_doc: Document[
BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]
]
):
prediction = empty_doc.inference.prediction
assert prediction.account_holders_names.value is None
assert prediction.bban.bban_bank_code is None
Expand Down
8 changes: 6 additions & 2 deletions tests/product/fr/carte_vitale/test_carte_vitale_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def complete_page_0() -> Page[CarteVitaleV1Document]:
return Page(CarteVitaleV1Document, json_data["document"]["inference"]["pages"][0])


def test_complete_doc(complete_doc: Document[CarteVitaleV1Document, Page[CarteVitaleV1Document]]):
def test_complete_doc(
complete_doc: Document[CarteVitaleV1Document, Page[CarteVitaleV1Document]]
):
reference_str = open(
PRODUCT_DATA_DIR / "carte_vitale" / "response_v1" / "summary_full.rst",
"r",
Expand All @@ -44,7 +46,9 @@ def test_complete_doc(complete_doc: Document[CarteVitaleV1Document, Page[CarteVi
assert str(complete_doc) == reference_str


def test_empty_doc(empty_doc: Document[CarteVitaleV1Document, Page[CarteVitaleV1Document]]):
def test_empty_doc(
empty_doc: Document[CarteVitaleV1Document, Page[CarteVitaleV1Document]]
):
prediction = empty_doc.inference.prediction
assert len(prediction.given_names) == 0
assert prediction.surname.value is None
Expand Down
4 changes: 3 additions & 1 deletion tests/product/invoice/test_invoice_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def complete_page_0() -> Page[InvoiceV4Document]:
return Page(InvoiceV4Document, json_data["document"]["inference"]["pages"][0])


def test_complete_doc(complete_doc: Document[InvoiceV4Document, Page[InvoiceV4Document]]):
def test_complete_doc(
complete_doc: Document[InvoiceV4Document, Page[InvoiceV4Document]]
):
reference_str = open(
PRODUCT_DATA_DIR / "invoices" / "response_v4" / "summary_full.rst",
"r",
Expand Down
Loading

0 comments on commit 16ca8e0

Please sign in to comment.