Skip to content

Commit a97a28f

Browse files
committed
fix: Deprecation
1 parent 22860df commit a97a28f

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/c2pa/c2pa.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,15 @@ def read_ingredient_file(
534534
path: Union[str, Path], data_dir: Union[str, Path]) -> str:
535535
"""Read a C2PA ingredient from a file.
536536
537+
.. deprecated:: 0.11.0
538+
This function is deprecated and will be removed in a future version.
539+
Please use the Reader class for reading C2PA metadata instead.
540+
Example:
541+
```python
542+
with Reader(path) as reader:
543+
manifest_json = reader.json()
544+
```
545+
537546
Args:
538547
path: Path to the file to read
539548
data_dir: Directory to write binary resources to
@@ -544,6 +553,12 @@ def read_ingredient_file(
544553
Raises:
545554
C2paError: If there was an error reading the file
546555
"""
556+
warnings.warn(
557+
"The read_ingredient_file function is deprecated and will be removed in a future version."
558+
"Please use Reader(path).json() for reading C2PA metadata instead.",
559+
DeprecationWarning,
560+
stacklevel=2)
561+
547562
container = _StringContainer()
548563

549564
container._path_str = str(path).encode('utf-8')
@@ -1382,7 +1397,7 @@ def wrapped_callback(
13821397
return -1
13831398

13841399
# Copy the signature back to the C buffer (since callback is
1385-
# sued in native code)
1400+
# used in native code)
13861401
actual_len = min(len(signature), signed_len)
13871402
for i in range(actual_len):
13881403
signed_bytes_ptr[i] = signature[i]
@@ -1977,6 +1992,14 @@ def create_signer(
19771992
) -> Signer:
19781993
"""Create a signer from a callback function.
19791994
1995+
.. deprecated:: 0.11.0
1996+
This function is deprecated and will be removed in a future version.
1997+
Please use the Signer class method instead.
1998+
Example:
1999+
```python
2000+
signer = Signer.from_callback(callback, alg, certs, tsa_url)
2001+
```
2002+
19802003
Args:
19812004
callback: Function that signs data and returns the signature
19822005
alg: The signing algorithm to use
@@ -1990,12 +2013,26 @@ def create_signer(
19902013
C2paError: If there was an error creating the signer
19912014
C2paError.Encoding: If the certificate data or TSA URL contains invalid UTF-8 characters
19922015
"""
2016+
warnings.warn(
2017+
"The create_signer function is deprecated and will be removed in a future version."
2018+
"Please use Signer.from_callback() instead.",
2019+
DeprecationWarning,
2020+
stacklevel=2)
2021+
19932022
return Signer.from_callback(callback, alg, certs, tsa_url)
19942023

19952024

19962025
def create_signer_from_info(signer_info: C2paSignerInfo) -> Signer:
19972026
"""Create a signer from signer information.
19982027
2028+
.. deprecated:: 0.11.0
2029+
This function is deprecated and will be removed in a future version.
2030+
Please use the Signer class method instead.
2031+
Example:
2032+
```python
2033+
signer = Signer.from_info(signer_info)
2034+
```
2035+
19992036
Args:
20002037
signer_info: The signer configuration
20012038
@@ -2005,6 +2042,12 @@ def create_signer_from_info(signer_info: C2paSignerInfo) -> Signer:
20052042
Raises:
20062043
C2paError: If there was an error creating the signer
20072044
"""
2045+
warnings.warn(
2046+
"The create_signer_from_info function is deprecated and will be removed in a future version."
2047+
"Please use Signer.from_info() instead.",
2048+
DeprecationWarning,
2049+
stacklevel=2)
2050+
20082051
return Signer.from_info(signer_info)
20092052

20102053

0 commit comments

Comments
 (0)