New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

pafex

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Malware was recently detected in this package.

Affected versions:

2.3

pafex

Minimal checksummed binary configuration handling.

pipPyPI
Version
2.3
Weekly downloads
105
Maintainers
1
Weekly downloads
 
Created

Minimal checksummed binary configuration handling for Python. Config layers user settings over DEFAULT_CONFIG; load_config/save_config persist to a strict binary format with optional gzip/xz/zlib compression. Standard library only.

Install

pip install pafex

Usage

from pafex import Config, load_config, save_config

cfg = Config({'strict_mode': True, 'allowed_tags': {'p', 'a'}})
cfg.get('strict_mode')                    # True
cfg.get('strip_whitespace')               # default from DEFAULT_CONFIG
cfg.update({'max_depth': 3})              # new Config, original untouched

save_config(cfg, 'default.config', compression='gzip')
loaded = load_config('default.config')
loaded == cfg                             # True

Config file layout:

raw:   [8-byte MD5 checksum][4-byte size][config]
gzip:  [8-byte MD5 checksum][4-byte size][gzip.compress(config)]
xz:    [8-byte MD5 checksum][4-byte size][lzma.compress(config)]
zlib:  [8-byte MD5 checksum][4-byte size][zlib.compress(config)]

Writes are atomic (temp file + os.replace). With no explicit path, load_config/save_config locate the caller's default.config (caller's module directory first, then the package directory).

Errors raise PafexError subclasses: ConfigLoadError (read/parse failures), ConfigChecksumError (integrity mismatch) and ConfigDecompressError (corrupt compressed payload).

FAQs

Related posts