Skip to content

Commit 9dddb72

Browse files
committed
fix: One more clean up
1 parent 128508c commit 9dddb72

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

src/c2pa/c2pa.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,35 @@ def load_settings(settings: str, format: str = "json") -> None:
530530
raise C2paError(error)
531531

532532

533+
def read_ingredient_file(
534+
path: Union[str, Path], data_dir: Union[str, Path]) -> str:
535+
"""Read a C2PA ingredient from a file.
536+
537+
Args:
538+
path: Path to the file to read
539+
data_dir: Directory to write binary resources to
540+
541+
Returns:
542+
The ingredient as a JSON string
543+
544+
Raises:
545+
C2paError: If there was an error reading the file
546+
"""
547+
container = _StringContainer()
548+
549+
container._path_str = str(path).encode('utf-8')
550+
container._data_dir_str = str(data_dir).encode('utf-8')
551+
552+
result = _lib.c2pa_read_ingredient_file(
553+
container._path_str, container._data_dir_str)
554+
return _parse_operation_result_for_error(result)
555+
556+
533557
def read_file(path: Union[str, Path],
534558
data_dir: Union[str, Path]) -> str:
535559
"""Read a C2PA manifest from a file.
536560
537-
.. deprecated:: 0.10.12
561+
.. deprecated:: 0.10.0
538562
This function is deprecated and will be removed in a future version.
539563
Please use the Reader class for reading C2PA metadata instead.
540564
Example:
@@ -569,30 +593,6 @@ def read_file(path: Union[str, Path],
569593
return _parse_operation_result_for_error(result)
570594

571595

572-
def read_ingredient_file(
573-
path: Union[str, Path], data_dir: Union[str, Path]) -> str:
574-
"""Read a C2PA ingredient from a file.
575-
576-
Args:
577-
path: Path to the file to read
578-
data_dir: Directory to write binary resources to
579-
580-
Returns:
581-
The ingredient as a JSON string
582-
583-
Raises:
584-
C2paError: If there was an error reading the file
585-
"""
586-
container = _StringContainer()
587-
588-
container._path_str = str(path).encode('utf-8')
589-
container._data_dir_str = str(data_dir).encode('utf-8')
590-
591-
result = _lib.c2pa_read_ingredient_file(
592-
container._path_str, container._data_dir_str)
593-
return _parse_operation_result_for_error(result)
594-
595-
596596
def sign_file(
597597
source_path: Union[str, Path],
598598
dest_path: Union[str, Path],
@@ -602,7 +602,7 @@ def sign_file(
602602
) -> str:
603603
"""Sign a file with a C2PA manifest.
604604
605-
.. deprecated:: 0.10.12
605+
.. deprecated:: 0.10.0
606606
This function is deprecated and will be removed in a future version.
607607
Please use the Builder class for signing and the Reader class for reading signed data instead.
608608

tests/test_unit_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,10 @@ def test_stream_flush_after_close(self):
673673

674674
class TestLegacyAPI(unittest.TestCase):
675675
def setUp(self):
676+
# Filter specific deprecation warnings for legacy API tests
677+
warnings.filterwarnings("ignore", message="The read_file function is deprecated")
678+
warnings.filterwarnings("ignore", message="The sign_file function is deprecated")
679+
676680
self.data_dir = os.path.join(os.path.dirname(__file__), "fixtures")
677681

678682
# That file has C2PA metadata, so there is something to read

0 commit comments

Comments
 (0)