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 items are appended to the optional argument "nonSeqList".

The returned list of integers is NOT sorted.

condenseSeq(seqList, pad=1, nonSeqList=[])

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']

Anything in seqList that is not an integer is ignored for the purposes of condensing the list of integers and the ignored items are appended to the optional argument "nonSeqList".

condenseSeqOnes(seqList, pad=1)

Takes a list of numbers and condenses it into the most minimal form 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']

As with condenseSeq, anything in seqList that is not an integer is ignored for the purposes of condensing the list of integers and the ignored items are appended to the optional argument "nonSeqList".

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-1.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

seqLister-1.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: seqLister-1.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for seqLister-1.1.0.tar.gz
Algorithm Hash digest
SHA256 59d754360c7a7dd224a5a9ec9fc713c55e8819d917320353d7942f81a9da6f9c
MD5 db7e35d102bdcabd69fd76dda40fee76
BLAKE2b-256 c2eec8f5a7d6a409b1f3135678057474d1ea754fcfa04fc27e384b53e578d6c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seqLister-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for seqLister-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e338acf73d51dc05b4f5ace2dadec25ee78a6461bc14b1385965740d17bf67cd
MD5 cd78d96ed709f82cc032fb28fdb383e8
BLAKE2b-256 aa088564ac08afed1090f90b955514e5343d5de0a3ee8093ca10fc407560debb

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