Skip to content

Commit

Permalink
Change structure of validate()
Browse files Browse the repository at this point in the history
  • Loading branch information
duckduckgrayduck authored Sep 13, 2023
1 parent 6002c53 commit c0e3bdf
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ def setup_credential_file(self):

def validate(self):
"""Validate that we can run the OCR"""
print(self.get_document_count())
if self.get_document_count() == 0:
if self.get_document_count() is None:
self.set_message(
"It looks like no documents were selected. Search for some or "
"select them and run again."
)
return False
if not self.org_id:
elif not self.org_id:
self.set_message("No organization to charge.")
return False
num_pages = 0
for document in self.get_documents():
num_pages += document.page_count
resp = self.client.post(
f"organizations/{self.org_id}/ai_credits/",
json={"ai_credits": num_pages},
)
if resp.status_code != 200:
self.set_message("Error charging AI credits.")
return False
else:
num_pages = 0
for document in self.get_documents():
num_pages += document.page_count
resp = self.client.post(
f"organizations/{self.org_id}/ai_credits/",
json={"ai_credits": num_pages},
)
if resp.status_code != 200:
self.set_message("Error charging AI credits.")
return False
return True

def json_ocr(self, input_dir, filename):
Expand Down

0 comments on commit c0e3bdf

Please sign in to comment.