Skip to main content

Python library to expand and condense integer-sequences using a simple syntax widely used within the VFX-industry for specifying frame-ranges.

Project description

About seqLister

seqLister is a python library for expanding and condensing integer-sequences using a simple syntax widely used within the VFX-industry for specifying frame-ranges.

How to install the seqLister module on your system.

python3 -m pip install seqLister

Syntax for specifying frame ranges

  1. List of individual numbers, e.g.:
    1, 4, 10, 15
  2. Ranges of numbers, e.g.:
    1-4, 10-15, which represents the numbers 1, 2, 3, 4, 10, 11, 12, 13, 14, 15
  3. Ranges of skipped frame numbers, e.g.:
    1-10x2, 20-60x10 which represents the numbers 1, 3, 5, 7, 9, 20, 30, 40, 50, 60
  4. Any combination of the above.

Negative numbers are also allowed, as well as specifying ranges in reverse order.

Libary functions

expandSeq(seqList, nonSeqList=[])

Expands and returns the argument 'seqList' as a list of integers. 'seqList' may be a single string, or a list of integers and/or strings of the following format (with examples):

  • individual frame numbers: seqLister.expandSeq([1, "4", 10, 15]) returns
    [1, 4, 10, 15]
  • sequences of successive frame numbers: seqLister.expandSeq(["1-4", "10-15"]) returns
    [1, 2, 3, 4, 10, 11, 12, 13, 14, 15]
  • sequences of skipped frame numbers: seqLister.expandSeqd(["1-10x2", "20-60x10"]) returns
    [1, 3, 5, 7, 9, 20, 30, 40, 50, 60]
  • reverse sequences work too: seqLister.expandSeq(["5-1"]) returns
    [5, 4, 3, 2, 1]
  • as do negative numbers: seqLister.expandSeq(["-10--3"]) returns
    [-10, -9, -8, -7, -6, -5, -4, -3]

The above formats may be listed in any order, but if a number has been listed once, it will not be listed again.

Eg. seqLister.expandSeq(["0-16x8", "0-16x2"]) returns
[0, 8, 16, 2, 4, 6, 10, 12, 14]

Anything that is not of the above format is ignored for the purposes of building the list of integers and the ignored item is appended to the optional argument "nonSeqList".

The returned list of integers is NOT sorted.

condenseSeq(seqList, pad=1)

Takes a list of numbers and condenses it into the most minimal form using the syntax described in 'expandSeq()' above. Since the returned list is a list of strings, then you can specify the padding of the integers with the optional pad argument.

Examples:

seqLister.condenseSeq([2, 1, 3, 7, 8, 4, 5, 6, 9, 10]) returns
['1-10']

seqLister.condenseSeq([0, 8, 16, 2, 4, 6, 10, 12, 14]) returns
['0-16x2']

condenseSeq tries to keep runs of condensed frame lists as long as possible while also trying to keep random smatterings of frame numbers, simply as numbers and not strange sequences.

Eg. seqLister.condenseSeq(seqLister.expandSeq(["0-100x2", 51])) returns
['0-50x2', '51', '52-100x2']

and seqLister.condenseSeq([1, 5, 13], 2), returns
['01', '05', '13']

Other examples:

seqLister.condenseSeq([1, 1, 1, 3, 3, 5, 5, 5]) returns
['1-5x2']

seqLister.condenseSeq([1, 2, 3, 4, 6, 8, 10]) returns
['1-4', '6-10x2']

seqLister.condenseSeq([1, 2, 3, 4, 6, 8]) returns
['1-4', '6', '8']

condenseSeq(expandSeq(["2-50x2", "3-50x3", "5-50x5", "7-50x7", "11-50x11", "13-50x13", "17-50x17", "19-50x19", "23-50x23"])) returns
['2-28', '30', '32-36', '38-40', '42', '44-46', '48-50']

condenseSeqOnes(seqList, pad=1)

Takes a list of numbers and condenses it into the most minimal form using with the restriction that sequences are compressed to a range (A-B) if and only if the numbers are successive.

Examples:

seqLister.condenseSeqOnes([2, 1, 3, 7, 8, 4, 5, 6, 9, 10]) returns
['1-10']

seqLister.condenseSeqOnes([0, 8, 16, 2, 4, 6, 10, 12, 14]) returns
['0', '2', '4', '6', '8', '10', '12', '14', '16']

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

seqLister-0.0.4.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

seqLister-0.0.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file seqLister-0.0.4.tar.gz.

File metadata

  • Download URL: seqLister-0.0.4.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.8

File hashes

Hashes for seqLister-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f93e643547d32b675a6ef662c7d503fd9352eac1748600bf69337c0192686315
MD5 8c3f3f1e5d944930720b19147a399139
BLAKE2b-256 767d55c960e11401c6123bc962b2bbcba75afe6dbdf6cbb7c032873be8d84699

See more details on using hashes here.

File details

Details for the file seqLister-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: seqLister-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.8

File hashes

Hashes for seqLister-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6ba5f0827c9c86e14a8a123d23571b3896fa974477cb8117716bac43b50e4e43
MD5 4e0911658db4d2747746f2876fbe6eee
BLAKE2b-256 2654628a3b4c703ed55481c11ddf4a43494e58cd77ed29efe2b3f334c4090a26

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