Skip to main content

Easily pack and unpack metadata in a filename.

Project description

keyname

https://img.shields.io/pypi/v/keyname.svg https://img.shields.io/travis/mmore500/keyname.svg Documentation Status

Easily pack and unpack metadata in a filename.

Usage

Keyname is built around the following file name convention:

  • key/value pairs are constructed with = between the key and value
  • key/value pairs are joined by +
  • key/value pairs are ordered alphanumerically by key
    • keys beginning with _ are ordered after keys not beginning with _
    • the ext (extension) key is always placed last
    • the key _ is reserved for the original filename

For example, key1=val1+key2=val2+_key3=val3+ext=.txt.

from keyname import keyname as kn

# returns 'key1=val1+key2=val2+_key3=val3+ext=.txt'
kn.pack({
  'key2' : 'val2',
  'ext' : '.txt',
  'key1' : 'val1',
  '_key3' : 'val3',
})

# returns {'key' : 'val', 'ext' : '.txt', '_' : 'path/to/key=val+ext=.txt'}
kf.unpack('path/to/key=val+ext=.txt')

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.0.0 (2019-03-16)

  • First release on PyPI.

Project details


Download files

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

Files for keyname, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size keyname-0.1.0-py2.py3-none-any.whl (4.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size keyname-0.1.0.tar.gz (9.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page