Skip to content

Commit

Permalink
Ran pylint and black
Browse files Browse the repository at this point in the history
  • Loading branch information
duckduckgrayduck committed Jan 23, 2024
1 parent 718cf63 commit 8fbf7ba
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ def validate(self):
"select them and run again."
)
return False
else:
num_pages = 0
for document in self.get_documents():
num_pages += document.page_count
try:
self.charge_credits(num_pages)
except ValueError:
return False
except APIError:
return False
num_pages = 0
for document in self.get_documents():
num_pages += document.page_count
try:
self.charge_credits(num_pages)
except ValueError:
return False
except APIError:
return False
return True

def convert_coordinates(self, polygon, page_width, page_height):
Expand Down Expand Up @@ -68,7 +67,8 @@ def main(self):
)
for document in self.get_documents():
poller = document_analysis_client.begin_analyze_document(
"prebuilt-read", document=document.pdf)
"prebuilt-read", document=document.pdf
)
result = poller.result()
pages = []
for i, page in enumerate(result.pages):
Expand Down Expand Up @@ -102,14 +102,17 @@ def main(self):

page_chunk_size = 100 # Set your desired chunk size
for i in range(0, len(pages), page_chunk_size):
chunk = pages[i:i + page_chunk_size]
resp = self.client.patch(f"documents/{document.id}/", json={"pages": chunk})
chunk = pages[i : i + page_chunk_size]
resp = self.client.patch(
f"documents/{document.id}/", json={"pages": chunk}
)
resp.raise_for_status()
while True:
time.sleep(10)
if document.status == "success": # Break out of for loop if document status becomes success
if (
document.status == "success"
): # Break out of for loop if document status becomes success
break



if __name__ == "__main__":
Expand Down

0 comments on commit 8fbf7ba

Please sign in to comment.