Python Card Framework
This is a library designed to allow Python developers to treat the Chat API JSON to be generated for cards and dialogs as objects, each capable of rendering themselves into valid JSON instead of hand-crafting or cut-and-pasting JSON in large blocks.
The exact JSON that is being rendered can be found in the official Google Developer Docs pages here: https://developers.google.com/chat/api/reference/rest/v1/spaces.messages?hl=en
Intention
In order to generate or send messages from a chat application to the user, the messages must be formed of valid JSON objects. In the event that the message is malformed, a simple 'Chat App not responding' message is returned. This leads to the developer having to insert large blocks of JSON in their Python code, much of which is boiler-plate and can easily lead to hard to find cut and paste errors.
As a result this library of objects has been created to alleviate the problem. The developer can now create and manipulate first-class Python objects which know how to correctly render themselves. Thus, instead of inserting this:
return {
"sections": [
{
"widgets": [
{
"decoratedText": {
"topLabel": "Hello, my name is Inigo Montoya",
"text": "You killed my father. Prepare to die.",
"startIcon": {
"knownIcon": "PERSON"
}
}
}
]
}
],
"header": {
"title": "The Princess Bride",
"imageUrl": "https://source.unsplash.com/featured/320x180?nature&sig=8",
"imageType": "CIRCLE"
}
}
... the developer can instead do this (with the appropriate imports, of course):
from card_framework.v2 import Card, CardHeader, Message, Section
from card_framework.v2.widgets import DecoratedText, Icon
text = DecoratedText(top_label='Hello, my name is Inigo Montoya',
text='You killed my father. Prepare to die.',
start_icon=Icon(known_icon=Icon.KnownIcon.PERSON))
widgets = [text]
header = CardHeader(title='The Princess Bride',
image_url='https://source.unsplash.com/featured320x180?nature&sig=8')
card = Card(header=header, sections=[Section(widgets=widgets)])
return Message(cards=[card]).render()
which will return the correct JSON.
Metadata
Release files for python-card-framework 2.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_card_framework-2.4.0.tar.gz | 30.4 kB | Without provenance | Details for python_card_framework-2.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_card_framework-2.4.0-py3-none-any.whl | Python 3 | none | any | Details for python_card_framework-2.4.0-py3-none-any.whl |
Total release size: 100.6 kB
Release files / python_card_framework-2.4.0.tar.gz
| Download URL | python_card_framework-2.4.0.tar.gz |
|---|---|
| Size | 30.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8cd6bb8a7198d825ace4c0327473fd876dd364954184c985719463848f4c09e
|
|
BLAKE2b-256 checksum How to use checksums |
991690364ab2fc054fabc7004cea5e1fea3edd36f3a78a3578bceffd0626cc0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Release files / python_card_framework-2.4.0-py3-none-any.whl
| Download URL | python_card_framework-2.4.0-py3-none-any.whl |
|---|---|
| Size | 70.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d848356814b46cdcfaf65872e9783bafb1ce26197020df2d8ac53612a03d8f6
|
|
BLAKE2b-256 checksum How to use checksums |
cb146b7c79442aff9125bb43a7fccd86d3072986ae34c39145a0a44bd44cc084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Security for python-card-framework 2.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.