Skip to main content

focal

Data Access Objects for local files.

focal re-exports the file-system stores of dol (Files, TextFiles, PickleFiles, ...) and adds multi_extension_wrap, which serializes by file extension.

Examples

The examples below run as doctests (pytest tests/test_readme.py).

a dict-like view of a folder

>>> import os, tempfile
>>> from focal import Files, TextFiles
>>>
>>> rootdir = tempfile.mkdtemp()
>>> store = Files(rootdir)  # keys are relative paths, values are bytes
>>> store['foo'] = b'baz'
>>> 'foo' in store
True
>>> store['foo']
b'baz'
>>> os.listdir(rootdir)  # it is a real file
['foo']
>>> texts = TextFiles(rootdir)  # same folder, values are str
>>> texts['foo']
'baz'
>>> del store['foo']

bytes contents of a file, and key validation

>>> import os, tempfile
>>> from focal import Files
>>>
>>> rootdir = tempfile.mkdtemp()
>>> s = Files(rootdir)
>>> s['hello.txt'] = b'import os'
>>> s['hello.txt'][:6]
b'import'
>>> s['../escape']  # keys outside the root folder are refused
Traceback (most recent call last):
    ...
dol.filesys.KeyValidationError: ...
>>> try:
...     s['no_such_file']
... except KeyError:
...     print("KeyError (not FileNotFoundError) was raised.")
KeyError (not FileNotFoundError) was raised.

serialize by extension

See focal.extension_store.multi_extension_wrap.

Metadata

Release files for focal 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for focal 0.1.15
File Size Uploaded
focal-0.1.15.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for focal 0.1.15
File Interpreter ABI Platform
focal-0.1.15-py3-none-any.whl Python 3 none any Details

Total release size: 44.0 kB

Release files / focal-0.1.15.tar.gz

Download URL focal-0.1.15.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d9e76a4164fece44ba905ac46d35356ae51dd3798bb148d0b8d807a9ae033da0
BLAKE2b-256 checksum
How to use checksums
5c0ab90b1d5f60c424a4b32836f25857f5977a5721cca4095f300f311dd73814
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / focal-0.1.15-py3-none-any.whl

Download URL focal-0.1.15-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4723f7e161b63aadbf897b3d015205354eb881ec19dd334f5141ba92e6ee3bf9
BLAKE2b-256 checksum
How to use checksums
b9c86735cd99a6965c9e1c71de29495b07f9a976f5927f2f89864623e904b86d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.15 This release

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.4

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page