docling-core 2.6.0__py3-none-any.whl → 2.6.1__py3-none-any.whl

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.

Potentially problematic release.


This version of docling-core might be problematic. Click here for more details.

@@ -37,8 +37,8 @@ from docling_core.types.base import _JSON_POINTER_REGEX
37
37
  from docling_core.types.doc import BoundingBox, Size
38
38
  from docling_core.types.doc.base import ImageRefMode
39
39
  from docling_core.types.doc.labels import DocItemLabel, GroupLabel
40
+ from docling_core.types.doc.utils import relative_path
40
41
  from docling_core.types.legacy_doc.tokens import DocumentToken
41
- from docling_core.utils.file import relative_path
42
42
 
43
43
  Uint64 = typing.Annotated[int, Field(ge=0, le=(2**64 - 1))]
44
44
  LevelNumber = typing.Annotated[int, Field(ge=1, le=100)]
@@ -0,0 +1,48 @@
1
+ #
2
+ # Copyright IBM Corp. 2024 - 2024
3
+ # SPDX-License-Identifier: MIT
4
+ #
5
+
6
+ """Utils for document types."""
7
+
8
+ from pathlib import Path
9
+
10
+
11
+ def relative_path(src: Path, target: Path) -> Path:
12
+ """Compute the relative path from `src` to `target`.
13
+
14
+ Args:
15
+ src (str | Path): The source directory or file path (must be absolute).
16
+ target (str | Path): The target directory or file path (must be absolute).
17
+
18
+ Returns:
19
+ Path: The relative path from `src` to `target`.
20
+
21
+ Raises:
22
+ ValueError: If either `src` or `target` is not an absolute path.
23
+ """
24
+ src = Path(src).resolve()
25
+ target = Path(target).resolve()
26
+
27
+ # Ensure both paths are absolute
28
+ if not src.is_absolute():
29
+ raise ValueError(f"The source path must be absolute: {src}")
30
+ if not target.is_absolute():
31
+ raise ValueError(f"The target path must be absolute: {target}")
32
+
33
+ # Find the common ancestor
34
+ common_parts = []
35
+ for src_part, target_part in zip(src.parts, target.parts):
36
+ if src_part == target_part:
37
+ common_parts.append(src_part)
38
+ else:
39
+ break
40
+
41
+ # Determine the path to go up from src to the common ancestor
42
+ up_segments = [".."] * (len(src.parts) - len(common_parts))
43
+
44
+ # Add the path from the common ancestor to the target
45
+ down_segments = target.parts[len(common_parts) :]
46
+
47
+ # Combine and return the result
48
+ return Path(*up_segments, *down_segments)
@@ -15,6 +15,7 @@ import requests
15
15
  from pydantic import AnyHttpUrl, TypeAdapter, ValidationError
16
16
  from typing_extensions import deprecated
17
17
 
18
+ from docling_core.types.doc.utils import relative_path # noqa
18
19
  from docling_core.types.io import DocumentStream
19
20
 
20
21
 
@@ -168,43 +169,3 @@ def resolve_file_source(
168
169
  source=source,
169
170
  headers=headers,
170
171
  )
171
-
172
-
173
- def relative_path(src: Path, target: Path) -> Path:
174
- """Compute the relative path from `src` to `target`.
175
-
176
- Args:
177
- src (str | Path): The source directory or file path (must be absolute).
178
- target (str | Path): The target directory or file path (must be absolute).
179
-
180
- Returns:
181
- Path: The relative path from `src` to `target`.
182
-
183
- Raises:
184
- ValueError: If either `src` or `target` is not an absolute path.
185
- """
186
- src = Path(src).resolve()
187
- target = Path(target).resolve()
188
-
189
- # Ensure both paths are absolute
190
- if not src.is_absolute():
191
- raise ValueError(f"The source path must be absolute: {src}")
192
- if not target.is_absolute():
193
- raise ValueError(f"The target path must be absolute: {target}")
194
-
195
- # Find the common ancestor
196
- common_parts = []
197
- for src_part, target_part in zip(src.parts, target.parts):
198
- if src_part == target_part:
199
- common_parts.append(src_part)
200
- else:
201
- break
202
-
203
- # Determine the path to go up from src to the common ancestor
204
- up_segments = [".."] * (len(src.parts) - len(common_parts))
205
-
206
- # Add the path from the common ancestor to the target
207
- down_segments = target.parts[len(common_parts) :]
208
-
209
- # Combine and return the result
210
- return Path(*up_segments, *down_segments)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: docling-core
3
- Version: 2.6.0
3
+ Version: 2.6.1
4
4
  Summary: A python library to define and validate data types in Docling.
5
5
  Home-page: https://ds4sd.github.io/
6
6
  License: MIT
@@ -21,8 +21,9 @@ docling_core/types/__init__.py,sha256=MVRSgsk5focwGyAplh_TRR3dEecIXpd98g_u3zZ5HX
21
21
  docling_core/types/base.py,sha256=PusJskRVL19y-hq0BgXr5e8--QEqSqLnFNJ8UbOqW88,8318
22
22
  docling_core/types/doc/__init__.py,sha256=bEL4zKVOG7Wxm6xQrgF58mu-Teds9aSavuEAKVNhrTU,639
23
23
  docling_core/types/doc/base.py,sha256=_ttU8QI8wXDTQRUnN5n7L6D9wYFVLSAibxlFoMbgAsk,4557
24
- docling_core/types/doc/document.py,sha256=K6ixUeB0vyrnd3_ljM0Ed_8JBdltLPCsrGz7IoLgjUI,87094
24
+ docling_core/types/doc/document.py,sha256=8qVhet6eQtvju286zUkdOU0NXnkZ0AoOVAysMEZ3Aws,87099
25
25
  docling_core/types/doc/labels.py,sha256=A8vWP82VAeXO1rlCO0oDKo_Hb8uDeQe0myOTY3P03hk,1596
26
+ docling_core/types/doc/utils.py,sha256=YDOh_ZD1Y7OmCEDdCLJ_MO5K3HA67nc_acfhOK6WztU,1439
26
27
  docling_core/types/gen/__init__.py,sha256=C6TuCfvpSnSL5XDOFMcYHUY2-i08vvfOGRcdu6Af0pI,124
27
28
  docling_core/types/gen/generic.py,sha256=l4CZ4_Lb8ONG36WNJWbKX5hGKvTh_yU-hXp5hsm7uVU,844
28
29
  docling_core/types/io/__init__.py,sha256=7QYvFRaDE0AzBg8e7tvsVNlLBbCbAbQ9rP2TU8aXR1k,350
@@ -45,13 +46,13 @@ docling_core/types/rec/statement.py,sha256=YwcV4CbVaAbzNwh14yJ_6Py3Ww0XnUJrEEUiK
45
46
  docling_core/types/rec/subject.py,sha256=PRCERGTMs4YhR3_Ne6jogkm41zYg8uUWb1yFpM7atm4,2572
46
47
  docling_core/utils/__init__.py,sha256=VauNNpWRHG0_ISKrsy5-gTxicrdQZSau6qMfuMl3iqk,120
47
48
  docling_core/utils/alias.py,sha256=B6Lqvss8CbaNARHLR4qSmNh9OkB6LvqTpxfsFmkLAFo,874
48
- docling_core/utils/file.py,sha256=B1Iu8buqk_Yz4bhrGf7NyFIiYlsa_MC37vZLwQHqKLU,6876
49
+ docling_core/utils/file.py,sha256=GzX0pclvewwPoqHJSaVUuULzSJwJgkCUwgKgJ7G5ohQ,5628
49
50
  docling_core/utils/generate_docs.py,sha256=BdKAoduWXOc7YMvcmlhjoJOFlUxij1ybxglj6LZDtC8,2290
50
51
  docling_core/utils/generate_jsonschema.py,sha256=uNX1O5XnjyB5nA66XqZXTt3YbGuR2tyi_OhHepHYtZg,1654
51
52
  docling_core/utils/validate.py,sha256=3FmnxnKTDZC5J9OGxCL3U3DGRl0t0bBV1NcySXswdas,2031
52
53
  docling_core/utils/validators.py,sha256=azcrndLzhNkTWnbFSu9shJ5D3j_znnLrIFA5R8hzmGU,2798
53
- docling_core-2.6.0.dist-info/LICENSE,sha256=2M9-6EoQ1sxFztTOkXGAtwUDJvnWaAHdB9BYWVwGkIw,1087
54
- docling_core-2.6.0.dist-info/METADATA,sha256=LhnsqU5AgndZllazTDXe_acmPWQ6NuMuH_b6-d4K1gM,5519
55
- docling_core-2.6.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
56
- docling_core-2.6.0.dist-info/entry_points.txt,sha256=jIxlWv3tnO04irlZc0zfhqJIgz1bg9Hha4AkaLWSdUA,177
57
- docling_core-2.6.0.dist-info/RECORD,,
54
+ docling_core-2.6.1.dist-info/LICENSE,sha256=2M9-6EoQ1sxFztTOkXGAtwUDJvnWaAHdB9BYWVwGkIw,1087
55
+ docling_core-2.6.1.dist-info/METADATA,sha256=aHtmbajidCAFKmJiAq-sSW-rSjZhHAMsqSEfRrpYBes,5519
56
+ docling_core-2.6.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
57
+ docling_core-2.6.1.dist-info/entry_points.txt,sha256=jIxlWv3tnO04irlZc0zfhqJIgz1bg9Hha4AkaLWSdUA,177
58
+ docling_core-2.6.1.dist-info/RECORD,,