Skip to content

Commit 561ac54

Browse files
committed
Comments from Tania
1 parent f346293 commit 561ac54

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

docs/tasks/includes/_python-build.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ Use a `Builder` object to add a manifest to an asset.
55

66
```python
77
try:
8-
# Define a function to sign the claim bytes
9-
# In this case we are using a pre-defined sign_ps256 method, passing in our private cert
10-
# Normally this cert would be kept safe in some other location
8+
# Define a function to sign the claim bytes.
9+
# In this case we are using a pre-defined sign_ps256 method, passing in our private cert.
10+
# Normally this cert would be kept safe in some other location.
1111
def private_sign(data: bytes) -> bytes:
1212
return sign_ps256(data, "tests/fixtures/ps256.pem")
1313

14-
# read our public certs into memory
14+
# Read our public certs into memory.
1515
certs = open(data_dir + "ps256.pub", "rb").read()
1616

17-
# Create a signer from the private signer, certs and a time stamp service url
17+
# Create a signer from the private signer, certs and a time stamp service URL.
1818
signer = create_signer(private_sign, SigningAlg.PS256, certs, "http://timestamp.digicert.com")
1919

2020
# Create a builder add a thumbnail resource and an ingredient file.
2121
builder = Builder(manifest_json)
2222

23-
# Add the resource from a stream
23+
# Add the resource from a stream.
2424
a_thumbnail_jpg_stream = open("tests/fixtures/A_thumbnail.jpg", "rb")
2525
builder.add_resource("image/jpeg", a_thumbnail_jpg_stream)
2626

27-
# Add the resource from a file
27+
# Add the resource from a file.
2828
# The URI provided here, "thumbnail", must match an identifier in the manifest definition.
2929
builder.add_resource_file("thumbnail", "tests/fixtures/A_thumbnail.jpg")
3030

31-
# Define an ingredient, in this case a parent ingredient named A.jpg, with a thumbnail
31+
# Define an ingredient, in this case a parent ingredient named A.jpg, with a thumbnail.
3232
ingredient_json = {
3333
"title": "A.jpg",
3434
"relationship": "parentOf", # "parentOf", "componentOf" or "inputTo"
@@ -38,19 +38,19 @@ try:
3838
}
3939
}
4040

41-
# Add the ingredient from a stream
41+
# Add the ingredient from a stream.
4242
a_jpg_stream = open("tests/fixtures/A.jpg", "rb")
4343
builder.add_ingredient("image/jpeg", a_jpg_stream)
4444

45-
# At this point we could archive or unarchive our Builder to continue later.
46-
# In this example we use a bytearray for the archive stream.
47-
# all ingredients and resources will be saved in the archive
45+
# At this point archive or unarchive Builder to continue later.
46+
# This example uses a bytearray for the archive stream.
47+
# All ingredients and resources are saved in the archive.
4848
archive = io.BytesIO(bytearray())
4949
builder.to_archive(archive)
5050
archive.seek()
5151
builder = builder.from_archive(archive)
5252

53-
# Sign the builder with a stream and output it to a stream
53+
# Sign the builder with a stream and output it to a stream.
5454
# This returns the binary manifest data that could be uploaded to cloud storage.
5555
input_stream = open("tests/fixtures/A.jpg", "rb")
5656
output_stream = open("target/out.jpg", "wb")
@@ -63,8 +63,8 @@ except Exception as err:
6363
FROM SIGNING:
6464

6565
```python
66-
request_data = ... # This is the asset being signed
67-
content_type = ... # MIME type of the asset
66+
request_data = ... # This is the asset being signed.
67+
content_type = ... # MIME type of the asset.
6868

6969
manifest = json.dumps({
7070
"title": "image.jpg",

docs/tasks/includes/_python-get-resources.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ Retrieve binary resources such as thumbnails from the manifest data, use the `re
55

66
_NOTE: Need to add example of using `reader.resource_to_stream()`._
77

8-
```python
8+
```py
99
try:
10-
# Create a reader from a file path
11-
reader = c2pa.Reader.from_file("path/to/media_file.jpg")
10+
# Create a reader from a file path
11+
reader = c2pa.Reader.from_file("path/to/media_file.jpg")
1212

13-
# Get the active manifest.
14-
manifest = reader.get_active_manifest()
15-
if manifest != None:
13+
# Get the active manifest.
14+
manifest = reader.get_active_manifest()
15+
if manifest != None:
1616

17-
# get the uri to the manifest's thumbnail and write it to a file
18-
uri = manifest["thumbnail"]["identifier"]
19-
reader.resource_to_file(uri, "thumbnail_v2.jpg")
17+
# get the uri to the manifest's thumbnail and write it to a file
18+
uri = manifest["thumbnail"]["identifier"]
19+
reader.resource_to_file(uri, "thumbnail_v2.jpg")
2020

2121
except Exception as err:
22-
print(err)
22+
print(err)
2323
```

docs/tasks/includes/_python-read.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
Use the `Reader` object to read manifest data from a file or stream and perform validation on the manifest store. Use the `json()` method to return a JSON manifest report; If there are validation errors, the report includes a `validation_status` field.
2+
Use the `Reader` object to read manifest data from a file or stream and perform validation on the manifest store.
3+
4+
Use the `json()` method to return a JSON manifest report; If there are validation errors, the report includes a `validation_status` field.
35

46
An asset file may contain many manifests in a manifest store. The most recent manifest is identified by the value of the `active_manifest` field in the manifests map.
57

0 commit comments

Comments
 (0)