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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: seqLister-1.0.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 564bc69ffa50a4ea8ad5474d8a53e25015ee429720e968997a09f4f6420eaef0
MD5 bae3d14e833c5e99193fd6aefabdb9be
BLAKE2b-256 6e31227a95130e89182bc7b369d19518a2b8272249241b201bbb222d1ded1b9f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seqLister-1.0.0-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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4459aa928e55f4b58c0365bb919e7579458b2df82cf84b15568d54ca70a91d9
MD5 f20e080c1d9ff3a40c80b868e1afb434
BLAKE2b-256 f902694b5a3e7608bf7aa0b000bce4ebb419ada6b9c03f7bfa4b88ca3b5aa1ba

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