content-understanding-sdk 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: content-understanding-sdk
3
+ Version: 0.0.1
4
+ Summary: Python SDK for Azure Content Understanding API
5
+ Author-email: Umang <umang.rajawat@nihilent.com>
6
+ License: MIT
7
+ Keywords: azure,content-understanding,sdk,api,document-processing
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: requests>=2.31.0
20
+
21
+ # Content Understanding SDK
22
+
23
+ Python SDK for Azure Content Understanding API.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install content-understanding-sdk
@@ -0,0 +1,8 @@
1
+ # Content Understanding SDK
2
+
3
+ Python SDK for Azure Content Understanding API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install content-understanding-sdk
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "content-understanding-sdk"
7
+ version = "0.0.1"
8
+ description = "Python SDK for Azure Content Understanding API"
9
+ readme = { file = "README.md", content-type = "text/markdown" }
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+
13
+ authors = [
14
+ { name = "Umang", email = "umang.rajawat@nihilent.com" }
15
+ ]
16
+
17
+ keywords = ["azure", "content-understanding", "sdk", "api", "document-processing"]
18
+
19
+ classifiers = [
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ ]
30
+
31
+ dependencies = [
32
+ "requests>=2.31.0"
33
+ ]
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ # src/content_understanding_client/__init__.py
2
+
3
+ from .client import ContentUnderstandingClient
4
+
5
+ __all__ = ["ContentUnderstandingClient"]
@@ -0,0 +1,71 @@
1
+ # src/content_understanding_client/client.py
2
+
3
+ import json
4
+ import time
5
+ import logging
6
+ import requests
7
+
8
+
9
+ class ContentUnderstandingClient:
10
+ def __init__(self, endpoint: str, api_key: str, api_version: str):
11
+ logging.info("Initializing ContentUnderstandingClient")
12
+ if not endpoint or not api_key or not api_version:
13
+ raise ValueError("endpoint, api_key, and api_version are required")
14
+
15
+ self.endpoint = endpoint.rstrip("/")
16
+ self.api_key = api_key
17
+ self.api_version = api_version
18
+ self.base_headers = {
19
+ "Ocp-Apim-Subscription-Key": api_key,
20
+ }
21
+
22
+ def begin_analyze(self, analyzer_id: str, file_bytes: bytes):
23
+ analyze_url = (
24
+ f"{self.endpoint}/contentunderstanding/analyzers/"
25
+ f"{analyzer_id}:analyze?api-version={self.api_version}"
26
+ )
27
+
28
+ headers = {
29
+ "Content-Type": "application/octet-stream",
30
+ **self.base_headers,
31
+ }
32
+
33
+ response = requests.post(analyze_url, headers=headers, data=file_bytes)
34
+ response.raise_for_status()
35
+
36
+ operation_location = response.headers.get("operation-location")
37
+ if not operation_location:
38
+ raise RuntimeError("operation-location header missing")
39
+
40
+ return operation_location
41
+
42
+ def poll_result(
43
+ self,
44
+ operation_location: str,
45
+ timeout_seconds: int = 600,
46
+ polling_interval_seconds: int = 2,
47
+ ):
48
+ start_time = time.time()
49
+
50
+ while True:
51
+ if time.time() - start_time > timeout_seconds:
52
+ raise TimeoutError(
53
+ f"Polling timed out after {timeout_seconds} seconds."
54
+ )
55
+
56
+ response = requests.get(
57
+ operation_location, headers=self.base_headers
58
+ )
59
+ response.raise_for_status()
60
+
61
+ result = response.json()
62
+ status = result.get("status", "").lower()
63
+
64
+ if status == "succeeded":
65
+ return result
66
+ if status == "failed":
67
+ raise RuntimeError(
68
+ f"Analysis failed: {json.dumps(result, indent=2)}"
69
+ )
70
+
71
+ time.sleep(polling_interval_seconds)
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: content-understanding-sdk
3
+ Version: 0.0.1
4
+ Summary: Python SDK for Azure Content Understanding API
5
+ Author-email: Umang <umang.rajawat@nihilent.com>
6
+ License: MIT
7
+ Keywords: azure,content-understanding,sdk,api,document-processing
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: requests>=2.31.0
20
+
21
+ # Content Understanding SDK
22
+
23
+ Python SDK for Azure Content Understanding API.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install content-understanding-sdk
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/content_understanding_sdk/__init__.py
4
+ src/content_understanding_sdk/client.py
5
+ src/content_understanding_sdk.egg-info/PKG-INFO
6
+ src/content_understanding_sdk.egg-info/SOURCES.txt
7
+ src/content_understanding_sdk.egg-info/dependency_links.txt
8
+ src/content_understanding_sdk.egg-info/requires.txt
9
+ src/content_understanding_sdk.egg-info/top_level.txt