Skip to main content

Easy file metadata.

Project description

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'

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...'

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caput-1.0.tar.gz (24.0 kB view details)

Uploaded Source

File details

Details for the file caput-1.0.tar.gz.

File metadata

  • Download URL: caput-1.0.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for caput-1.0.tar.gz
Algorithm Hash digest
SHA256 31bb2c95f665be9db43245e8c1b424500066d2932ad499e983ec2bf61628ffa2
MD5 4e84178c0b0c8ad1861ce3f0b5d5382d
BLAKE2b-256 86e4cb58acc8306296d8f478eba51d7e7fbc751d229fd9e9b632dfb4d9d8b96b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page