Skip to main content

AFS - Agnostic File Storage

Goals and motivations

The purpose of this module is to offer an agnostic, easy-to-use module for different file systems (At present time, just local and SMB/CIFS). The initial use of this module was provide an easy path to translate local file systems operations to a network samba server.

Example of use

So, you can translate code like this:

if os.path.isdir('/tmp/token.txt'):
    if not os.path.isdir('/tmp/results'):
        os.mkdir('/tmp/results')
    with open('/tmp/results/data.txt', 'wb') as f:
        f.write('This is an example\n')

To something like this (which must work identical):

with afs.connect('temp') as fs:
    if not fs.isdir('results'):
        fs.mkdir('results')
    fs.cd('results')
    fs.save('data.txt', 'This is an example\n')

Usually you need to iterate a list of directories checking for the existence of the dir, create if needed, and then changing to the dir, for every directory::

dirs = ['media', 'public', '2016', 'sep', '14']
with afs.connect('static') as fs:
    for dir in dirs:
        if not fs.is_dir(dir):
            fs.mkdir(dir)
        fs.cd(dir)
    # You can save the file now

Using the set_path method make all this steps with one single call::

with afs.connect('static') as fs:
    fs.set_path('media', 'public', '2016', 'sep', '14')
    # You can save the file now

The entry temp is defined in a configuration file, using a format similar to windows .INI files, like this:

[temp]
kind: local
base: /tmp

We can now switch to another directory by just replacing the temp base entry to the desired base path, for example. More interesting, you can change to a network SMB Server, modifying the configuration file to:

[temp]
kind: smb
username: samba_user
password: samba_password
host: nas
domain: mycompany.com
service: test$

Things to do

  • Add more storage file systems: NFS, Amazon S3, SFTP

  • Improve security, nobody likes password stored as plain text in configuration files.

  • More tests

Metadata

Release files for agnostic-file-store 0.5.4

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

Source distribution (sdist)

Source distribution for agnostic-file-store 0.5.4
File Size Uploaded Provenance Actions
agnostic-file-store-0.5.4.tar.gz 10.6 kB Without provenance Details for agnostic-file-store-0.5.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agnostic-file-store 0.5.4
File Interpreter ABI Platform Actions
agnostic_file_store-0.5.4-py3-none-any.whl Python 3 none any Details for agnostic_file_store-0.5.4-py3-none-any.whl

Total release size: 22.6 kB

Release files / agnostic-file-store-0.5.4.tar.gz

Download URL agnostic-file-store-0.5.4.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8a12d41442e087d18b11b371b3ed62a179ef8bfa9b51f86f57a1e182a000e89b
BLAKE2b-256 checksum
How to use checksums
65d0eeaaf633155fe60c84d2f2140499692ce8d696e51fe4fa6ada6ab3f9ee00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

Release files / agnostic_file_store-0.5.4-py3-none-any.whl

Download URL agnostic_file_store-0.5.4-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9dccf3ff8959c143cb813e99f224cd566cccd7a4907c9d44a00af370764dc424
BLAKE2b-256 checksum
How to use checksums
815e4eddc315284d4b2ddf1d7b2306b3d0468a7a15f2305a5ec641b61d800b8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

Security for agnostic-file-store 0.5.4

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.

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