Skip to main content

Filelister is a Python package that makes working with filelists (yes, lists of files) easy.

Project description

Filelister

Filelister is a Python package that makes working with filelists (yes, lists of files) easy.

import filelister as fs

Contents

Basic Usage

Types of Filelists

Filelister supports three formats of filelists: Absolute, Relative, and "na"

Absolute

abs refers to an absolute filelist

['path/to/file_01.txt', 'path/to/file_02.txt', 'path/to/file_03.txt']

Relative

rel refers to a relative filelists

['../file_01.txt', '../file_02.txt', '../file_03.txt']

na

na refers to a filelist that is stored with no context, where filepaths are ignored and only filenames are stored

['file_01.txt', 'file_02.txt', 'file_03.txt']

Creating a Filelist

From Data

You can create a Filelist object from a list, set, tuple, Filelist object, or path to directory.

my_filelist = fs.Filelist(['../file_01.jpg', '../file_02.jpg'])

my_other_filelist = fs.Filelist('path/to/directory')

From System Files

You can also create a Filelist object by reading from a filelist saved on your system.

my_filelist = fs.read_filelist('path/to/filelist.txt')

Saving a Filelist

Arguments

outfile: specify a path to the location in which to write the filelist.
output_type: specify the type of filelist to write. Options include 'abs', 'rel', and 'na'.
compressed: accepts a boolean. Pass compressed=True to write a compressed filelist.

Usage

my_filelist.save('filelists/my_filelist.txt', output_type='abs', compressed=True)

Note that when saving a relative filelist, the filepaths are converted to be relative to the location of the filelist.

Compression

A filelist can be stored using custom zlib compression by using

my_filelist.save(outfile='compressed_filelist.zz', compressed=True)

This filelist can then be read using

fs.read_filelist('compressed_filelist.zz', compressed=True)

Due to the nature of the compression, a compressed filelist should only be read by filelister.

Working with Filelists

Manipulating a Filelist

Filelists support a number of conversions, including conversions to a native python list, to a relative filelist, and to an absolute filelist.

my_filelist.to_list()

my_filelist.to_abs()

my_filelist.to_rel()

These commands can also be chained:

my_filelist.to_abs().to_list()

Filelists support a cointains method, as well as the python in operator.

my_filelist.contains('path/to/file')

'path/to/file' in my_filelist

A filelist can also be indexed and sliced like a normal python list. This will always return a native python list.

my_filelist[1] == 'path/to/file.txt'

my_filelist[:3] == ['path/to/file01.txt', 'path/to/file02.txt', 'path/to/file03.txt']

The Vision

This tool was created to make sharing and handling filelists simple and easy for everyone.

Runtime/Storage efficiency info here?

  • O(1) get/lookup
  • O(n) instantiaton
  • Efficient data storage`

Installation

pip (local)

You can install this package locally via Github and pip.

git clone https://github.com/burkecp/filelister.git
cd filelister
pip install -e .

pip (PyPi)

Coming soon

Anaconda

Coming soon

Contributors

Authors

Simon Burke Christian Burke Refik Anadol Studio

Spec

Use Cases

  1. Simple read and write
  2. Ability to check if a filelist contains a path
  3. Ability to create batches from a filelist (TODO)
  4. Ability to resolve correct output paths for a relative filelist
  5. Ability to verify contents of a filelist (TODO)
  6. Convert relative/absolute filelists
  7. Ability to compare filelists (TODO)
  8. Ability to perform list + set methods on a filelist (TODO)

Runtimes

  1. O(n) read and O(n) write
  2. O(1) contains
  3. O(n) iteration

API

In Progress

Arithmetic Operations

Set Operations

Project details


Download files

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

Source Distribution

filelister-0.0.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

filelister-0.0.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file filelister-0.0.0.tar.gz.

File metadata

  • Download URL: filelister-0.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0b3 CPython/3.8.13 Linux/5.4.0-124-generic

File hashes

Hashes for filelister-0.0.0.tar.gz
Algorithm Hash digest
SHA256 7d54e80bf3099a534fee5e6cb720026e8bceea49decb6940286e34ef511cf9e5
MD5 eca7b3a337092bede647da92f585aafc
BLAKE2b-256 3a1e22c0560b35b6beb7994964d86d4a38b23b9aa2d08fe4b5b5aa5625107dfc

See more details on using hashes here.

File details

Details for the file filelister-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: filelister-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0b3 CPython/3.8.13 Linux/5.4.0-124-generic

File hashes

Hashes for filelister-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 875db3ed190860631dda4d2818d84d51475fc14cfa677b504a18e976fc8e5ec0
MD5 f28c03dcdea48262be44b2dd0ccc9022
BLAKE2b-256 e4aefc5eb68960a2ac8dc493cf3be51e90ce615859a1a4da88ae169c861e8a95

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