from codetable import Code, Codes, CodesStorage, msg
codes_storage = CodesStorage()
class UserErrorCodes(Codes):
NAMESPACE: str = "user"
EXPORT_TO: CodesStorage = codes_storage # For example, export status codes to global storage for use in frontend translations.
ALREADY_EXISTS: str
DOES_NOT_EXIST: Code = msg("User does not exist.")
print("# UserErrorCodes.ALREADY_EXISTS\n")
print("code:", UserErrorCodes.ALREADY_EXISTS)
print("\n# UserErrorCodes.DOES_NOT_EXIST\n")
print("obj:", UserErrorCodes.DOES_NOT_EXIST)
print("code:", UserErrorCodes.DOES_NOT_EXIST.code)
print("msg:", UserErrorCodes.DOES_NOT_EXIST.msg)
print("\n# UserErrorCodes.export_codes()\n")
print(UserErrorCodes.export_codes())
class CatCodes(Codes):
NAMESPACE: str = "cat"
EXPORT_TO: CodesStorage = codes_storage # We don't call export_codes here, but it will still be exported due to the presence of EXPORT_TO. export_codes is run automatically when EXPORT_TO is present.
NOT_HUNGRY: Code = msg("Cat is not hungry!")
print("\n# codes_storage\n")
print(codes_storage)
print("\n# codes_storage.to_json()")
print("# !!! You can change ident by passing an argument !!!\n")
print(codes_storage.to_json())
print("\n# codes_storage.to_dict()\n")
print(codes_storage.to_dict())
# # UserErrorCodes.ALREADY_EXISTS
# code: user_already_exists
# # UserErrorCodes.DOES_NOT_EXIST
# obj: Code(code='user_does_not_exist', msg='User does not exist.')
# code: user_does_not_exist
# msg: User does not exist.
# # UserErrorCodes.export_codes()
# {'user_already_exists': None, 'user_does_not_exist': 'User does not exist.'}
# # codes_storage
# CodesStorage(storage={'user_already_exists': None, 'user_does_not_exist': 'User does not exist.', 'cat_not_hungry': 'Cat is not hungry!'})
# # codes_storage.to_json()
# # !!! You can change ident by passing an argument !!!
# {
# "user_already_exists": null,
# "user_does_not_exist": "User does not exist.",
# "cat_not_hungry": "Cat is not hungry!"
# }
# # codes_storage.to_dict()
# {'user_already_exists': None, 'user_does_not_exist': 'User does not exist.', 'cat_not_hungry': 'Cat is not hungry!'}
Metadata
Release files for codetable 1.0.9
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 |
|---|---|---|---|---|
| codetable-1.0.9.tar.gz | 4.6 kB | Without provenance | Details for codetable-1.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| codetable-1.0.9-py3-none-any.whl | Python 3 | none | any | Details for codetable-1.0.9-py3-none-any.whl |
Total release size: 10.6 kB
Release files / codetable-1.0.9.tar.gz
| Download URL | codetable-1.0.9.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7eb8ff3c5ddad085b6938ee1043e9fbcb33c433cc344d7eaa855306b807c9f9f
|
|
BLAKE2b-256 checksum How to use checksums |
364aab914bd23858c2a0a4151c9885b8132d7a287b073037e794056899f905f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.8
|
Release files / codetable-1.0.9-py3-none-any.whl
| Download URL | codetable-1.0.9-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e064551789ee61d8188dfd2a30af24443aae45f79b9102ccde1140a243383e55
|
|
BLAKE2b-256 checksum How to use checksums |
5ffeeda7b22e09d5f0a26c715c03206643772c998db5a51afb229170f18b7066
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.8
|
Security for codetable 1.0.9
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.