This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Generate sequential file names in a thread-safe way.

Usage

If you want to create sequential files to write output to (say from different threads or from consecutive runs of the same program), then you can use this module from within your program or from the command line.

From the commandline

$ seqfile
usage: seqfile [-h] [-m MAX_ATTEMPTS] [-b BASE] prefix [suffix] [folder]
seqfile: error: too few arguments

# Assume files "./a.0.txt" and "./a.3.txt" exist.
$ seqfile a. .txt .
./a.4.txt

# Assume no other files exist.
# This will create files 100 files with names test.*.txt in the current
# folder.
$ seq 100 | xargs -n 1 -P 100 -I{} \
    bash -c "fname=\$(seqfile test. .txt); \
             echo 'Do something awesome with {}' > \$fname"

From your program

# Assume files "./a.0.txt" and "./a.3.txt" exist.
>> import seqfile

# Providing prefix and suffix finds the next file in the sequence
# ignoring any gaps
>> seqfile.findNextFile('.', prefix='a.', suffix='.txt')
'./a.4.txt'

# Providing a file name generator as fnameGen produces the first file
# which it was successful in creating.
>> seqfile.findNextFile('.', fnameGen=lambda x: 'a.' + str(x) + '.txt')
'./a.1.txt'

The returned file will exist, be empty, and can be opened for writing.

Installing

This package is available from PyPi <https://pypi.python.org/pypi/seqfile>.

pip install seqfile

You can install the bleeding edge directly from the source:

pip install git+https://github.com/musically-ut/seqfile.git@master#egg=seqfile

Tests

The tests can be run using nosetests (if all dependencies are installed in the environment) or using python setup.py test.

Caveats

It is best not to provide unicode characters in the prefix, suffix, or folder. Though the support has been tested on all major OSes, it has not been verfied that all OS/filesystem combinations will work.

Also, the O_CREAT | O_EXCEL trick used to create files atomically may not work on old linux kernels while writing to an NFS.

Release History

Release History

0.2.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
seqfile-0.2.0.tar.gz (56.0 kB) Copy SHA256 Checksum SHA256 Source May 8, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting