Skip to content

Commit 1e8ddbb

Browse files
only check the file type for pro mode for now.
1 parent 030d397 commit 1e8ddbb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

python/content_understanding_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _get_headers(
140140
return headers
141141

142142
@staticmethod
143-
def is_supported_type_by_file_ext(file_ext: str, is_document: bool=False) -> bool:
143+
def is_supported_doc_type_by_file_ext(file_ext: str, is_document: bool=False) -> bool:
144144
"""
145145
Checks if the given file extension is supported.
146146
@@ -158,7 +158,7 @@ def is_supported_type_by_file_ext(file_ext: str, is_document: bool=False) -> boo
158158
return file_ext.lower() in supported_types
159159

160160
@staticmethod
161-
def is_supported_type_by_file_path(file_path: Path, is_document: bool=False) -> bool:
161+
def is_supported_doc_type_by_file_path(file_path: Path, is_document: bool=False) -> bool:
162162
"""
163163
Checks if the given file path has a supported file type.
164164
@@ -172,7 +172,7 @@ def is_supported_type_by_file_path(file_path: Path, is_document: bool=False) ->
172172
if not file_path.is_file():
173173
return False
174174
file_ext = file_path.suffix.lower()
175-
return AzureContentUnderstandingClient.is_supported_type_by_file_ext(file_ext, is_document)
175+
return AzureContentUnderstandingClient.is_supported_doc_type_by_file_ext(file_ext, is_document)
176176

177177
def get_all_analyzers(self) -> Dict[str, Any]:
178178
"""
@@ -332,11 +332,11 @@ def begin_analyze(self, analyzer_id: str, file_location: str) -> Response:
332332
"data": base64.b64encode(f.read_bytes()).decode("utf-8")
333333
}
334334
for f in file_path.rglob("*")
335-
if f.is_file() and self.is_supported_type_by_file_path(f, is_document=True)
335+
if f.is_file() and self.is_supported_doc_type_by_file_path(f, is_document=True)
336336
]
337337
}
338338
headers = {"Content-Type": "application/json"}
339-
elif file_path.is_file() and self.is_supported_type_by_file_path(file_path):
339+
elif file_path.is_file():
340340
with open(file_location, "rb") as file:
341341
data = file.read()
342342
headers = {"Content-Type": "application/octet-stream"}
@@ -453,7 +453,7 @@ def _get_analyze_list(
453453
for dirpath, _, filenames in os.walk(reference_docs_folder):
454454
for filename in filenames:
455455
_, file_ext = os.path.splitext(filename)
456-
if self.is_supported_type_by_file_ext(file_ext, is_document=True):
456+
if self.is_supported_doc_type_by_file_ext(file_ext, is_document=True):
457457
file_path = os.path.join(dirpath, filename)
458458
result_file_name = filename + self.OCR_RESULT_FILE_SUFFIX
459459
analyze_list.append(
@@ -483,7 +483,7 @@ def _get_upload_only_list(
483483
for dirpath, _, filenames in os.walk(reference_docs_folder):
484484
for filename in filenames:
485485
_, file_ext = os.path.splitext(filename)
486-
if self.is_supported_type_by_file_ext(file_ext, is_document=True):
486+
if self.is_supported_doc_type_by_file_ext(file_ext, is_document=True):
487487
file_path = os.path.join(dirpath, filename)
488488
result_file_name = filename + self.OCR_RESULT_FILE_SUFFIX
489489
result_file_path = os.path.join(dirpath, result_file_name)
@@ -505,7 +505,7 @@ def _get_upload_only_list(
505505
if original_filename in filenames:
506506
# skip result.json files corresponding to the file with supported document type
507507
_, original_file_ext = os.path.splitext(original_filename)
508-
if self.is_supported_type_by_file_ext(original_file_ext, is_document=True):
508+
if self.is_supported_doc_type_by_file_ext(original_file_ext, is_document=True):
509509
continue
510510
else:
511511
raise ValueError(

0 commit comments

Comments
 (0)