Easy file metadata.
Store metadata in a special YAML configuration header for text files, or a sidecar “shadow” configuration file for binary files.
Caput: n. Latin for “head” or “top”. Root of many English words, such as “captain”, “capital”, and “decapitate”.
Install
Caput is available from PyPI:
pip install caput
Usage
Say that you’re building a static site generator. You can add a metadata header to any textfile. The first three bytes must be ---\n. In index.md:
--- title: My Site author: Me featured_image: /images/my-header.jpg --- # Welcome to my site!
Read the metadata header:
>>> import caput
>>> caput.read_config('./index.md', defaults={'markup': 'markdown'})
{'markup': 'markdown',
'title': 'My Site',
'author': 'Me',
'featured_image': '/images/my-header.jpg'}
Read the file contents:
>>> caput.read_contents('./index.md')
'# Welcome to my site!\n'
Write metadata headers to files:
>>> metadata = {
... 'title': 'My New Post',
... 'author': 'Me',
... 'date': '2024-01-15'
... }
>>> content = '# This is my new post\n\nLorem ipsum...'
>>> caput.write_config('./new-post.md', metadata, content)
>>> # Verify the file was written correctly
>>> caput.read_config('./new-post.md')
{'title': 'My New Post', 'author': 'Me', 'date': '2024-01-15'}
>>> caput.read_contents('./new-post.md')
'# This is my new post\n\nLorem ipsum...'
Update existing metadata:
>>> # Read existing metadata
>>> config = caput.read_config('./index.md')
>>> config['updated'] = '2024-01-15'
>>> config['tags'] = ['blog', 'personal']
>>> # Write back with updated metadata
>>> caput.write_config('./index.md', config)
Read & write contents:
>>> content = caput.read_contents('./index.md')
>>> config = caput.read_config('./index.md')
>>> config['updated'] = '2025-09-09'
>>> content += '\n\nUpdated on 2025-09-09'
>>> caput.write_contents('./index.md', content, config)
Shadow Files for Binary Content
You can add metadata to binary files with a “shadow” header. For your featured image, add a .yml file with the same base name, e.g. for ./images/my-header.jpg you would add ./images/my-header.yml:
title: My Site Header credit: Me
Read the metadata header:
>>> caput.read_config('./images/my-header.jpg')
{'title': 'My Site Header', 'credit': 'Me')
Read the file contents:
>>> caput.read_contents('./images/my-header.jpg', encoding=None)
b'...binary data...'
Write metadata for binary files:
>>> # Create metadata for a binary file using a shadow YAML file
>>> binary_metadata = {
... 'title': 'Site Logo',
... 'credit': 'Design Team',
... 'license': 'CC BY 4.0'
... }
>>> caput.write_shadow_config('./images/logo.png', binary_metadata)
>>> # This creates ./images/logo.yml with the metadata
>>> caput.read_config('./images/logo.png')
{'title': 'Site Logo', 'credit': 'Design Team', 'license': 'CC BY 4.0'}
Metadata
Release files for caput 1.1
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 | |
|---|---|---|---|---|
| caput-1.1.tar.gz | 69.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| caput-1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 78.6 kB
Release files / caput-1.1.tar.gz
| Download URL | caput-1.1.tar.gz |
|---|---|
| Size | 69.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4481ad1ee754ead7b9b423e7423b353e1962dbda8a026b644bb1259ec9bc21f4
|
|
BLAKE2b-256 checksum How to use checksums |
13fbea55a4399ecda7114c1ef44c3a449c17ae0532dca9a5da05695b579fcd1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.19
|
Release files / caput-1.1-py3-none-any.whl
| Download URL | caput-1.1-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a951b25b4c0a5860db92e3fe6eeb5183f779fa976c4f15533feceeb8834158e3
|
|
BLAKE2b-256 checksum How to use checksums |
c188ce3e9137530ba08afce4107b4a2a9ca7d2503b873365c8d85fd1acaead77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.19
|
Security for caput 1.1
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.