Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ygbr/mapsnap
Browse files Browse the repository at this point in the history
  • Loading branch information
ygbr committed Sep 8, 2020
2 parents 6fc3351 + 02072f9 commit b7de171
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ Every time you create a new instance of this class, a signed URL is automaticall

##### Default Parameters and Attributes

| Parameter | Type | Description |
| ---------- | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **\_key** | str | The path for the .p8 or .pem file containing your MapKit JS Key downloaded from Apple Developer Portal. **(ex: /opt/myapplekeys/AuthKey_XXXXXXXXXX.p8)** |
| **teamId** | str | Your Apple Developer Team ID (you can view it on https://developer.apple.com after logging in near your company/developer name or by accessing the **Membership** option on the menu) |
| **keyId** | str | This ID is shown to you when you create your key and is generally part of the key file name, for instance if the downloaded key file is AuthKey_XYZ712387.p8 your keyId is XYZ712387. (You can double check it by going to your details on the Apple Developer portal) |
| Parameter | Type | Description |
| ---------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **\_key** | str or bytes | The path for the .p8 or .pem file containing your MapKit JS Key downloaded from Apple Developer Portal. **(ex: /opt/myapplekeys/AuthKey_XXXXXXXXXX.p8)** <br> This can also be a **bytes** object containing the raw contents of the key file. |
| **teamId** | str | Your Apple Developer Team ID (you can view it on https://developer.apple.com after logging in near your company/developer name or by accessing the **Membership** option on the menu) |
| **keyId** | str | This ID is shown to you when you create your key and is generally part of the key file name, for instance if the downloaded key file is AuthKey_XYZ712387.p8 your keyId is XYZ712387. (You can double check it by going to your details on the Apple Developer portal) |

The rest of the parameters are mapped directly from [Apple Maps Web Snapshots](https://developer.apple.com/documentation/snapshots) documentation and can be used as guided there.

Expand Down
10 changes: 5 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ Every time you create a new instance of this class, a signed URL is automaticall

##### Default Parameters and Attributes

| Parameter | Type | Description |
| ---------- | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **\_key** | str | The path for the .p8 or .pem file containing your MapKit JS Key downloaded from Apple Developer Portal. **(ex: /opt/myapplekeys/AuthKey_XXXXXXXXXX.p8)** |
| **teamId** | str | Your Apple Developer Team ID (you can view it on https://developer.apple.com after logging in near your company/developer name or by accessing the **Membership** option on the menu) |
| **keyId** | str | This ID is shown to you when you create your key and is generally part of the key file name, for instance if the downloaded key file is AuthKey_XYZ712387.p8 your keyId is XYZ712387. (You can double check it by going to your details on the Apple Developer portal) |
| Parameter | Type | Description |
| ---------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **\_key** | str or bytes | The path for the .p8 or .pem file containing your MapKit JS Key downloaded from Apple Developer Portal. **(ex: /opt/myapplekeys/AuthKey_XXXXXXXXXX.p8)** <br> This can also be a **bytes** object containing the raw contents of the key file. |
| **teamId** | str | Your Apple Developer Team ID (you can view it on https://developer.apple.com after logging in near your company/developer name or by accessing the **Membership** option on the menu) |
| **keyId** | str | This ID is shown to you when you create your key and is generally part of the key file name, for instance if the downloaded key file is AuthKey_XYZ712387.p8 your keyId is XYZ712387. (You can double check it by going to your details on the Apple Developer portal) |

The rest of the parameters are mapped directly from [Apple Maps Web Snapshots](https://developer.apple.com/documentation/snapshots) documentation and can be used as guided there.

Expand Down
11 changes: 9 additions & 2 deletions mapsnap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,15 @@ def __str__(self):
def __post_init__(self):
"""Initialize, Serialize and Sign"""

with open(self._key, "rb") as fp:
self._sk = SigningKey.from_pem(fp.read())
if isinstance(self._key, bytes):
self._sk = SigningKey.from_pem(self._key)
elif isinstance(self._key, str):
with open(self._key, "rb") as fp:
self._sk = SigningKey.from_pem(fp.read())
else:
raise ValueError(
"_key must be a str with the path or a bytes object with the raw key"
)

self._qs = self.serialize()
self._sig = self.sign()
Expand Down

0 comments on commit b7de171

Please sign in to comment.