expandSeq 2.3.0__tar.gz → 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {expandSeq-2.3.0 → expandseq-4.0.0}/LICENSE +1 -1
- expandseq-4.0.0/PKG-INFO +153 -0
- expandseq-4.0.0/README.md +126 -0
- expandseq-4.0.0/condenseseq/__main__.py +240 -0
- expandseq-4.0.0/expandSeq.egg-info/PKG-INFO +153 -0
- {expandSeq-2.3.0 → expandseq-4.0.0}/expandSeq.egg-info/SOURCES.txt +2 -0
- {expandSeq-2.3.0 → expandseq-4.0.0}/expandSeq.egg-info/entry_points.txt +1 -2
- expandseq-4.0.0/expandSeq.egg-info/requires.txt +1 -0
- expandseq-4.0.0/expandSeq.egg-info/top_level.txt +2 -0
- expandseq-4.0.0/expandseq/__init__.py +0 -0
- expandseq-4.0.0/expandseq/__main__.py +235 -0
- {expandSeq-2.3.0 → expandseq-4.0.0}/setup.py +4 -4
- expandSeq-2.3.0/PKG-INFO +0 -26
- expandSeq-2.3.0/README.md +0 -5
- expandSeq-2.3.0/expandSeq.egg-info/PKG-INFO +0 -26
- expandSeq-2.3.0/expandSeq.egg-info/requires.txt +0 -1
- expandSeq-2.3.0/expandSeq.egg-info/top_level.txt +0 -1
- expandSeq-2.3.0/expandseq/__main__.py +0 -219
- {expandSeq-2.3.0/expandseq → expandseq-4.0.0/condenseseq}/__init__.py +0 -0
- {expandSeq-2.3.0 → expandseq-4.0.0}/expandSeq.egg-info/dependency_links.txt +0 -0
- {expandSeq-2.3.0 → expandseq-4.0.0}/setup.cfg +0 -0
expandseq-4.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: expandSeq
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: Command line utils to expose functionality of seqLister python library.
|
|
5
|
+
Home-page: https://github.com/jrowellfx/expandSeq
|
|
6
|
+
Author: James Philip Rowell
|
|
7
|
+
Author-email: james@alpha-eleven.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
10
|
+
Classifier: Operating System :: POSIX
|
|
11
|
+
Classifier: Operating System :: Unix
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Requires-Python: >=3.6, <4
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: seqLister>=1.1.0
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
# About expandseq and consdenseseq
|
|
29
|
+
|
|
30
|
+
`expandseq` and `condenseseq` are two unix/linux command-line utilitiies
|
|
31
|
+
for expanding and condensing
|
|
32
|
+
integer-sequences using a simple syntax widely used within
|
|
33
|
+
the VFX-industry for specifying frame-ranges.
|
|
34
|
+
|
|
35
|
+
## Definition: 'Frame-Range'.
|
|
36
|
+
|
|
37
|
+
Given that 'A', 'B' and 'N' are integers, the syntax
|
|
38
|
+
for specifying an integer sequence used to describe
|
|
39
|
+
frame-ranges is one of the following three cases:
|
|
40
|
+
|
|
41
|
+
1. 'A' : just the integer A.
|
|
42
|
+
|
|
43
|
+
2. 'A-B' : all the integers from A to B inclusive.
|
|
44
|
+
|
|
45
|
+
3. 'A-BxN' : every Nth integer starting at A and increasing
|
|
46
|
+
to be no larger than B when A < B, or descending
|
|
47
|
+
to be no less than B when A > B.
|
|
48
|
+
|
|
49
|
+
The above three cases may be combined to describe
|
|
50
|
+
less regular lists of Frame-Ranges by concatenating one
|
|
51
|
+
Frame-Range after another separated by spaces or commas.
|
|
52
|
+
|
|
53
|
+
## Installing the commands
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
python3 -m pip install expandSeq --upgrade
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Testing the installation
|
|
60
|
+
|
|
61
|
+
You should be able to run the following commands and get this output.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
1$ expandseq 1-10
|
|
65
|
+
1 2 3 4 5 6 7 8 9 10
|
|
66
|
+
2$ condenseseq 1 2 3 4 5 7 9 11 13 15
|
|
67
|
+
1-4 5-15x2
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## expandseq
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
expandseq [OPTION]... [FRAME-RANGE]...
|
|
74
|
+
|
|
75
|
+
Expands a list of FRAME-RANGEs into a list of integers.
|
|
76
|
+
|
|
77
|
+
Example:
|
|
78
|
+
$ expandseq 2-4 1-6 10
|
|
79
|
+
2 3 4 1 5 6 10
|
|
80
|
+
|
|
81
|
+
Note in the above example that numbers are only listed once each.
|
|
82
|
+
That is, once '2-4' is listed, then '1-6' only need list 1, 5 and 6.
|
|
83
|
+
|
|
84
|
+
More examples:
|
|
85
|
+
$ expandseq 1-10x2, 20-60x10
|
|
86
|
+
1 3 5 7 9 20 30 40 50 60
|
|
87
|
+
$ expandseq --pad 3 109-91x4
|
|
88
|
+
109 105 101 097 093
|
|
89
|
+
$ expandseq --pad 4 -- -99-86x23
|
|
90
|
+
-099 -076 -053 -030 -007 0016 0039 0062 0085
|
|
91
|
+
|
|
92
|
+
Protip: To pass a negative-number to expandseq WITHOUT it being intepreted
|
|
93
|
+
as a command-line OPTION insert a double-minus ('--') before the
|
|
94
|
+
negative-number, which is a standard technique to deliniate the end
|
|
95
|
+
of command-line options.
|
|
96
|
+
|
|
97
|
+
positional arguments:
|
|
98
|
+
FRAME-RANGE See the definition of 'FRAME-RANGE' above.
|
|
99
|
+
|
|
100
|
+
optional arguments:
|
|
101
|
+
-h, --help show this help message and exit
|
|
102
|
+
--version show program's version number and exit
|
|
103
|
+
--delimiter DELIMITER, -d DELIMITER
|
|
104
|
+
List successive numbers delimited by a 'comma',
|
|
105
|
+
'space' (default) or a 'newline'.
|
|
106
|
+
--pad PAD set the padding of the frame numbers to be <PAD>
|
|
107
|
+
digits. [default: 1]
|
|
108
|
+
--reverse, -r reverse the order of the list
|
|
109
|
+
--sort, -s sort the resulting list
|
|
110
|
+
--error exit with error if FRAME-RANGE is invalid. (default)
|
|
111
|
+
--no-error skip invalid FRAME-RANGEs, but print warning
|
|
112
|
+
--silent, --quiet suppress all errors and warnings
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## condenseseq
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
condenseseq [OPTION]... [FRAME-RANGE]...
|
|
119
|
+
|
|
120
|
+
Given a list of FRAME-RANGEs condense the fully expanded list into
|
|
121
|
+
the most succinct list of FRAME-RANGEs possible.
|
|
122
|
+
|
|
123
|
+
Examples:
|
|
124
|
+
$ condenseseq 1-100x2 2-100x2
|
|
125
|
+
1-100
|
|
126
|
+
$ condenseseq 0-100x2 51
|
|
127
|
+
0-50x2 51 52-100x2
|
|
128
|
+
$ condenseseq --pad 3 49 0-100x2 51 53
|
|
129
|
+
000-048x2 049-053 054-100x2
|
|
130
|
+
|
|
131
|
+
Protip: To pass a negative-number to expandseq WITHOUT it being intepreted
|
|
132
|
+
as a command-line OPTION insert a double-minus ('--') before the
|
|
133
|
+
negative-number, which is a standard technique to deliniate the end
|
|
134
|
+
of command-line options.
|
|
135
|
+
|
|
136
|
+
positional arguments:
|
|
137
|
+
FRAME-RANGE See the definition of 'FRAME-RANGE' above.
|
|
138
|
+
|
|
139
|
+
optional arguments:
|
|
140
|
+
-h, --help show this help message and exit
|
|
141
|
+
--version show program's version number and exit
|
|
142
|
+
--delimiter DELIMITER, -d DELIMITER
|
|
143
|
+
List successive numbers delimited by a 'comma',
|
|
144
|
+
'space' (default) or a 'newline'.
|
|
145
|
+
--only-ones only condense sucessive frames, that is, do not list
|
|
146
|
+
sequences on 2's, 3's, ... N's
|
|
147
|
+
--pad PAD set the padding of the frame numbers to be <PAD>
|
|
148
|
+
digits. [default: 1]
|
|
149
|
+
--error exit with error if FRAME-RANGE is invalid. (default)
|
|
150
|
+
--no-error skip invalid FRAME-RANGEs, but print warning
|
|
151
|
+
--silent, --quiet suppress all errors and warnings
|
|
152
|
+
|
|
153
|
+
```
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# About expandseq and consdenseseq
|
|
2
|
+
|
|
3
|
+
`expandseq` and `condenseseq` are two unix/linux command-line utilitiies
|
|
4
|
+
for expanding and condensing
|
|
5
|
+
integer-sequences using a simple syntax widely used within
|
|
6
|
+
the VFX-industry for specifying frame-ranges.
|
|
7
|
+
|
|
8
|
+
## Definition: 'Frame-Range'.
|
|
9
|
+
|
|
10
|
+
Given that 'A', 'B' and 'N' are integers, the syntax
|
|
11
|
+
for specifying an integer sequence used to describe
|
|
12
|
+
frame-ranges is one of the following three cases:
|
|
13
|
+
|
|
14
|
+
1. 'A' : just the integer A.
|
|
15
|
+
|
|
16
|
+
2. 'A-B' : all the integers from A to B inclusive.
|
|
17
|
+
|
|
18
|
+
3. 'A-BxN' : every Nth integer starting at A and increasing
|
|
19
|
+
to be no larger than B when A < B, or descending
|
|
20
|
+
to be no less than B when A > B.
|
|
21
|
+
|
|
22
|
+
The above three cases may be combined to describe
|
|
23
|
+
less regular lists of Frame-Ranges by concatenating one
|
|
24
|
+
Frame-Range after another separated by spaces or commas.
|
|
25
|
+
|
|
26
|
+
## Installing the commands
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
python3 -m pip install expandSeq --upgrade
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Testing the installation
|
|
33
|
+
|
|
34
|
+
You should be able to run the following commands and get this output.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
1$ expandseq 1-10
|
|
38
|
+
1 2 3 4 5 6 7 8 9 10
|
|
39
|
+
2$ condenseseq 1 2 3 4 5 7 9 11 13 15
|
|
40
|
+
1-4 5-15x2
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## expandseq
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
expandseq [OPTION]... [FRAME-RANGE]...
|
|
47
|
+
|
|
48
|
+
Expands a list of FRAME-RANGEs into a list of integers.
|
|
49
|
+
|
|
50
|
+
Example:
|
|
51
|
+
$ expandseq 2-4 1-6 10
|
|
52
|
+
2 3 4 1 5 6 10
|
|
53
|
+
|
|
54
|
+
Note in the above example that numbers are only listed once each.
|
|
55
|
+
That is, once '2-4' is listed, then '1-6' only need list 1, 5 and 6.
|
|
56
|
+
|
|
57
|
+
More examples:
|
|
58
|
+
$ expandseq 1-10x2, 20-60x10
|
|
59
|
+
1 3 5 7 9 20 30 40 50 60
|
|
60
|
+
$ expandseq --pad 3 109-91x4
|
|
61
|
+
109 105 101 097 093
|
|
62
|
+
$ expandseq --pad 4 -- -99-86x23
|
|
63
|
+
-099 -076 -053 -030 -007 0016 0039 0062 0085
|
|
64
|
+
|
|
65
|
+
Protip: To pass a negative-number to expandseq WITHOUT it being intepreted
|
|
66
|
+
as a command-line OPTION insert a double-minus ('--') before the
|
|
67
|
+
negative-number, which is a standard technique to deliniate the end
|
|
68
|
+
of command-line options.
|
|
69
|
+
|
|
70
|
+
positional arguments:
|
|
71
|
+
FRAME-RANGE See the definition of 'FRAME-RANGE' above.
|
|
72
|
+
|
|
73
|
+
optional arguments:
|
|
74
|
+
-h, --help show this help message and exit
|
|
75
|
+
--version show program's version number and exit
|
|
76
|
+
--delimiter DELIMITER, -d DELIMITER
|
|
77
|
+
List successive numbers delimited by a 'comma',
|
|
78
|
+
'space' (default) or a 'newline'.
|
|
79
|
+
--pad PAD set the padding of the frame numbers to be <PAD>
|
|
80
|
+
digits. [default: 1]
|
|
81
|
+
--reverse, -r reverse the order of the list
|
|
82
|
+
--sort, -s sort the resulting list
|
|
83
|
+
--error exit with error if FRAME-RANGE is invalid. (default)
|
|
84
|
+
--no-error skip invalid FRAME-RANGEs, but print warning
|
|
85
|
+
--silent, --quiet suppress all errors and warnings
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## condenseseq
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
condenseseq [OPTION]... [FRAME-RANGE]...
|
|
92
|
+
|
|
93
|
+
Given a list of FRAME-RANGEs condense the fully expanded list into
|
|
94
|
+
the most succinct list of FRAME-RANGEs possible.
|
|
95
|
+
|
|
96
|
+
Examples:
|
|
97
|
+
$ condenseseq 1-100x2 2-100x2
|
|
98
|
+
1-100
|
|
99
|
+
$ condenseseq 0-100x2 51
|
|
100
|
+
0-50x2 51 52-100x2
|
|
101
|
+
$ condenseseq --pad 3 49 0-100x2 51 53
|
|
102
|
+
000-048x2 049-053 054-100x2
|
|
103
|
+
|
|
104
|
+
Protip: To pass a negative-number to expandseq WITHOUT it being intepreted
|
|
105
|
+
as a command-line OPTION insert a double-minus ('--') before the
|
|
106
|
+
negative-number, which is a standard technique to deliniate the end
|
|
107
|
+
of command-line options.
|
|
108
|
+
|
|
109
|
+
positional arguments:
|
|
110
|
+
FRAME-RANGE See the definition of 'FRAME-RANGE' above.
|
|
111
|
+
|
|
112
|
+
optional arguments:
|
|
113
|
+
-h, --help show this help message and exit
|
|
114
|
+
--version show program's version number and exit
|
|
115
|
+
--delimiter DELIMITER, -d DELIMITER
|
|
116
|
+
List successive numbers delimited by a 'comma',
|
|
117
|
+
'space' (default) or a 'newline'.
|
|
118
|
+
--only-ones only condense sucessive frames, that is, do not list
|
|
119
|
+
sequences on 2's, 3's, ... N's
|
|
120
|
+
--pad PAD set the padding of the frame numbers to be <PAD>
|
|
121
|
+
digits. [default: 1]
|
|
122
|
+
--error exit with error if FRAME-RANGE is invalid. (default)
|
|
123
|
+
--no-error skip invalid FRAME-RANGEs, but print warning
|
|
124
|
+
--silent, --quiet suppress all errors and warnings
|
|
125
|
+
|
|
126
|
+
```
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# 3-Clause BSD License
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2008-2025, James Philip Rowell,
|
|
6
|
+
# Alpha Eleven Incorporated
|
|
7
|
+
# www.alpha-eleven.com
|
|
8
|
+
# All rights reserved.
|
|
9
|
+
#
|
|
10
|
+
# Redistribution and use in source and binary forms, with or without
|
|
11
|
+
# modification, are permitted provided that the following conditions are
|
|
12
|
+
# met:
|
|
13
|
+
#
|
|
14
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
15
|
+
# notice, this list of conditions and the following disclaimer.
|
|
16
|
+
#
|
|
17
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
18
|
+
# notice, this list of conditions and the following disclaimer in
|
|
19
|
+
# the documentation and/or other materials provided with the
|
|
20
|
+
# distribution.
|
|
21
|
+
#
|
|
22
|
+
# 3. Neither the name of the copyright holder, "Alpha Eleven, Inc.",
|
|
23
|
+
# nor the names of its contributors may be used to endorse or
|
|
24
|
+
# promote products derived from this software without specific prior
|
|
25
|
+
# written permission.
|
|
26
|
+
#
|
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
28
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
29
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
30
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
31
|
+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
32
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
33
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
34
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
35
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
36
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
37
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
38
|
+
|
|
39
|
+
# expandseq/condenseseq - two command line utilities that expose and
|
|
40
|
+
# expand upon the basic functionality of the python-module "seqLister"
|
|
41
|
+
# functions "expandSeq()" and "condenseSeq()".
|
|
42
|
+
|
|
43
|
+
import argparse
|
|
44
|
+
import os
|
|
45
|
+
import sys
|
|
46
|
+
import subprocess
|
|
47
|
+
import textwrap
|
|
48
|
+
from operator import itemgetter
|
|
49
|
+
import seqLister
|
|
50
|
+
|
|
51
|
+
# MAJOR version for incompatible API changes
|
|
52
|
+
# MINOR version for added functionality in a backwards compatible manner
|
|
53
|
+
# PATCH version for backwards compatible bug fixes
|
|
54
|
+
#
|
|
55
|
+
VERSION = "4.0.0"
|
|
56
|
+
|
|
57
|
+
PROG_NAME = "condenseseq"
|
|
58
|
+
|
|
59
|
+
def main():
|
|
60
|
+
|
|
61
|
+
# Redefine the exception handling routine so that it does NOT
|
|
62
|
+
# do a trace dump if the user types ^C while expandseq or
|
|
63
|
+
# condenseseq are running.
|
|
64
|
+
#
|
|
65
|
+
old_excepthook = sys.excepthook
|
|
66
|
+
def new_hook(exceptionType, value, traceback):
|
|
67
|
+
if exceptionType != KeyboardInterrupt and exceptionType != IOError:
|
|
68
|
+
old_excepthook(exceptionType, value, traceback)
|
|
69
|
+
else:
|
|
70
|
+
pass
|
|
71
|
+
sys.excepthook = new_hook
|
|
72
|
+
|
|
73
|
+
p = argparse.ArgumentParser(
|
|
74
|
+
|
|
75
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
76
|
+
prog=PROG_NAME,
|
|
77
|
+
description=textwrap.dedent('''\
|
|
78
|
+
Given a list of FRAME-RANGEs condense the fully expanded list into
|
|
79
|
+
the most succinct list of FRAME-RANGEs possible.
|
|
80
|
+
|
|
81
|
+
Definition: FRAME-RANGE
|
|
82
|
+
Given that 'A', 'B' and 'N' are integers, then a FRAME-RANGE is one,
|
|
83
|
+
or any combination, of the following:
|
|
84
|
+
|
|
85
|
+
'A' the integer A.
|
|
86
|
+
|
|
87
|
+
'A-B' all the integers from A to B inclusive.
|
|
88
|
+
|
|
89
|
+
'A-BxN' every Nth integer starting at A and increasing to be no
|
|
90
|
+
larger than B when A < B, or decreasing to be no less
|
|
91
|
+
than B when A > B.
|
|
92
|
+
|
|
93
|
+
FRAME-RANGEs may be combined to describe less regular sequences by
|
|
94
|
+
concatenating one after another separated by spaces or commas.
|
|
95
|
+
|
|
96
|
+
Examples:
|
|
97
|
+
$ condenseseq 1-100x2 2-100x2
|
|
98
|
+
1-100
|
|
99
|
+
$ condenseseq 0-100x2 51
|
|
100
|
+
0-50x2 51 52-100x2
|
|
101
|
+
$ condenseseq --pad 3 49 0-100x2 51 53
|
|
102
|
+
000-048x2 049-053 054-100x2
|
|
103
|
+
|
|
104
|
+
Protip: To pass a negative-number to expandseq WITHOUT it being intepreted
|
|
105
|
+
as a command-line OPTION insert a double-minus ('--') before the
|
|
106
|
+
negative-number, which is a standard technique to deliniate the end
|
|
107
|
+
of command-line options.
|
|
108
|
+
|
|
109
|
+
(Also see expandseq).
|
|
110
|
+
'''),
|
|
111
|
+
usage="%(prog)s [OPTION]... [FRAME-RANGE]...")
|
|
112
|
+
|
|
113
|
+
p.add_argument("--version", action="version", version=VERSION)
|
|
114
|
+
p.add_argument("--delimiter", "-d", action="store", type=str,
|
|
115
|
+
choices=("comma", "space", "newline"),
|
|
116
|
+
dest="seqDelimiter",
|
|
117
|
+
metavar="DELIMITER",
|
|
118
|
+
default="space",
|
|
119
|
+
help="List successive numbers delimited by a 'comma', 'space' (default) or a 'newline'.")
|
|
120
|
+
p.add_argument("--only-ones", action="store_true",
|
|
121
|
+
dest="onlyOnes", default=False,
|
|
122
|
+
help="only condense sucessive frames, that is, do not list sequences on 2's, 3's, ... N's")
|
|
123
|
+
p.add_argument("--pad", action="store", type=int,
|
|
124
|
+
dest="pad", default=1,
|
|
125
|
+
metavar="PAD",
|
|
126
|
+
help="set the padding of the frame numbers to be <PAD> digits. [default: 1]")
|
|
127
|
+
|
|
128
|
+
p.add_argument("--error", action="store_true",
|
|
129
|
+
dest="exitOnError", default=True,
|
|
130
|
+
help="exit with error if FRAME-RANGE is invalid. (default)" )
|
|
131
|
+
p.add_argument("--no-error", action="store_false",
|
|
132
|
+
dest="exitOnError",
|
|
133
|
+
help="skip invalid FRAME-RANGEs, but print warning" )
|
|
134
|
+
|
|
135
|
+
p.add_argument("--silent", "--quiet", action="store_true",
|
|
136
|
+
dest="silent", default=False,
|
|
137
|
+
help="suppress all errors and warnings")
|
|
138
|
+
|
|
139
|
+
p.add_argument("numSequences", metavar="FRAME-RANGE", nargs="*",
|
|
140
|
+
help="See the definition of 'FRAME-RANGE' above.")
|
|
141
|
+
|
|
142
|
+
args = p.parse_args()
|
|
143
|
+
|
|
144
|
+
# Copy the command line args converting commas into spaces and then
|
|
145
|
+
# splitting along ALL whitespace possibly generating more args.
|
|
146
|
+
#
|
|
147
|
+
separateArgs = []
|
|
148
|
+
for a in args.numSequences :
|
|
149
|
+
for b in a.split(',') :
|
|
150
|
+
for c in b.split() :
|
|
151
|
+
separateArgs.append(c)
|
|
152
|
+
remainingArgs = []
|
|
153
|
+
|
|
154
|
+
# Now fully expand all the FRAME-RANGES supplied to get a FULL set of frame
|
|
155
|
+
# numbers before condensing the full list.
|
|
156
|
+
#
|
|
157
|
+
expandedArgs = seqLister.expandSeq(separateArgs, remainingArgs)
|
|
158
|
+
|
|
159
|
+
# Any non-FRAME-RANGES, should have been caught at this point, so we can
|
|
160
|
+
# process the possible errors and warnings now. Same code as expandSeq command.
|
|
161
|
+
#
|
|
162
|
+
# Check for any invalid FRAME-RANGEs, and respond according to
|
|
163
|
+
# flags set with OPTIONS. Only show up to 3 bad FRAME-RANGES,
|
|
164
|
+
# chop any after that and append an 'etc.' note to the warning
|
|
165
|
+
# or error message.
|
|
166
|
+
#
|
|
167
|
+
badArgsLength = len(remainingArgs)
|
|
168
|
+
if badArgsLength > 0 :
|
|
169
|
+
|
|
170
|
+
badArgsEtcLength = badArgsLength
|
|
171
|
+
if badArgsLength > 3 :
|
|
172
|
+
badArgsEtcLength = 3
|
|
173
|
+
|
|
174
|
+
plural = ''
|
|
175
|
+
count = ''
|
|
176
|
+
if badArgsLength > 1 :
|
|
177
|
+
plural = 's'
|
|
178
|
+
count = str(badArgsLength) + ' '
|
|
179
|
+
|
|
180
|
+
badFramesMessage = count \
|
|
181
|
+
+ 'invalid FRAME-RANGE' \
|
|
182
|
+
+ plural + ': ' \
|
|
183
|
+
+ ', '.join(remainingArgs[:badArgsEtcLength])
|
|
184
|
+
|
|
185
|
+
if badArgsLength > 3 :
|
|
186
|
+
badFramesMessage += ', ... etc.'
|
|
187
|
+
|
|
188
|
+
if args.exitOnError :
|
|
189
|
+
if not args.silent :
|
|
190
|
+
print(PROG_NAME,
|
|
191
|
+
": error: ", badFramesMessage,
|
|
192
|
+
file=sys.stderr, sep='')
|
|
193
|
+
sys.exit(1)
|
|
194
|
+
else :
|
|
195
|
+
if not args.silent :
|
|
196
|
+
print(PROG_NAME,
|
|
197
|
+
": warning: ", badFramesMessage,
|
|
198
|
+
file=sys.stderr, sep='')
|
|
199
|
+
|
|
200
|
+
tmpList = []
|
|
201
|
+
if args.onlyOnes :
|
|
202
|
+
result = seqLister.condenseSeqOnes(expandedArgs, args.pad, tmpList)
|
|
203
|
+
|
|
204
|
+
# tmpList should be zero length since expandSeq() call above should
|
|
205
|
+
# have caught all the issues with badly formed FRAME-RANGEs.
|
|
206
|
+
#
|
|
207
|
+
if len(tmpList) > 0 and not args.silent :
|
|
208
|
+
print(PROG_NAME,
|
|
209
|
+
": ASSERT FAILURE: call to seqLister.condenseSeqOnes() returned non-zero length nonSeqList.",
|
|
210
|
+
file=sys.stderr, sep='')
|
|
211
|
+
else :
|
|
212
|
+
result = seqLister.condenseSeq(expandedArgs, args.pad, tmpList)
|
|
213
|
+
|
|
214
|
+
# tmpList should be zero length since expandSeq() call above should
|
|
215
|
+
# have caught all the issues with badly formed FRAME-RANGEs.
|
|
216
|
+
#
|
|
217
|
+
if len(tmpList) > 0 and not args.silent :
|
|
218
|
+
print(PROG_NAME,
|
|
219
|
+
": ASSERT FAILURE: call to seqLister.condenseSeq() returned non-zero length nonSeqList.",
|
|
220
|
+
file=sys.stderr, sep='')
|
|
221
|
+
|
|
222
|
+
isFirst = True
|
|
223
|
+
for s in result :
|
|
224
|
+
if args.seqDelimiter == 'space' :
|
|
225
|
+
if not isFirst :
|
|
226
|
+
sys.stdout.write(' ')
|
|
227
|
+
sys.stdout.write(str(s))
|
|
228
|
+
isFirst = False
|
|
229
|
+
elif args.seqDelimiter == 'comma' :
|
|
230
|
+
if not isFirst :
|
|
231
|
+
sys.stdout.write(',')
|
|
232
|
+
sys.stdout.write(str(s))
|
|
233
|
+
isFirst = False
|
|
234
|
+
else : # newline
|
|
235
|
+
print(s)
|
|
236
|
+
if (args.seqDelimiter == 'comma' or args.seqDelimiter == 'space') and not isFirst :
|
|
237
|
+
print()
|
|
238
|
+
|
|
239
|
+
if __name__ == '__main__':
|
|
240
|
+
main()
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: expandSeq
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: Command line utils to expose functionality of seqLister python library.
|
|
5
|
+
Home-page: https://github.com/jrowellfx/expandSeq
|
|
6
|
+
Author: James Philip Rowell
|
|
7
|
+
Author-email: james@alpha-eleven.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
10
|
+
Classifier: Operating System :: POSIX
|
|
11
|
+
Classifier: Operating System :: Unix
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Requires-Python: >=3.6, <4
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: seqLister>=1.1.0
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
# About expandseq and consdenseseq
|
|
29
|
+
|
|
30
|
+
`expandseq` and `condenseseq` are two unix/linux command-line utilitiies
|
|
31
|
+
for expanding and condensing
|
|
32
|
+
integer-sequences using a simple syntax widely used within
|
|
33
|
+
the VFX-industry for specifying frame-ranges.
|
|
34
|
+
|
|
35
|
+
## Definition: 'Frame-Range'.
|
|
36
|
+
|
|
37
|
+
Given that 'A', 'B' and 'N' are integers, the syntax
|
|
38
|
+
for specifying an integer sequence used to describe
|
|
39
|
+
frame-ranges is one of the following three cases:
|
|
40
|
+
|
|
41
|
+
1. 'A' : just the integer A.
|
|
42
|
+
|
|
43
|
+
2. 'A-B' : all the integers from A to B inclusive.
|
|
44
|
+
|
|
45
|
+
3. 'A-BxN' : every Nth integer starting at A and increasing
|
|
46
|
+
to be no larger than B when A < B, or descending
|
|
47
|
+
to be no less than B when A > B.
|
|
48
|
+
|
|
49
|
+
The above three cases may be combined to describe
|
|
50
|
+
less regular lists of Frame-Ranges by concatenating one
|
|
51
|
+
Frame-Range after another separated by spaces or commas.
|
|
52
|
+
|
|
53
|
+
## Installing the commands
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
python3 -m pip install expandSeq --upgrade
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Testing the installation
|
|
60
|
+
|
|
61
|
+
You should be able to run the following commands and get this output.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
1$ expandseq 1-10
|
|
65
|
+
1 2 3 4 5 6 7 8 9 10
|
|
66
|
+
2$ condenseseq 1 2 3 4 5 7 9 11 13 15
|
|
67
|
+
1-4 5-15x2
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## expandseq
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
expandseq [OPTION]... [FRAME-RANGE]...
|
|
74
|
+
|
|
75
|
+
Expands a list of FRAME-RANGEs into a list of integers.
|
|
76
|
+
|
|
77
|
+
Example:
|
|
78
|
+
$ expandseq 2-4 1-6 10
|
|
79
|
+
2 3 4 1 5 6 10
|
|
80
|
+
|
|
81
|
+
Note in the above example that numbers are only listed once each.
|
|
82
|
+
That is, once '2-4' is listed, then '1-6' only need list 1, 5 and 6.
|
|
83
|
+
|
|
84
|
+
More examples:
|
|
85
|
+
$ expandseq 1-10x2, 20-60x10
|
|
86
|
+
1 3 5 7 9 20 30 40 50 60
|
|
87
|
+
$ expandseq --pad 3 109-91x4
|
|
88
|
+
109 105 101 097 093
|
|
89
|
+
$ expandseq --pad 4 -- -99-86x23
|
|
90
|
+
-099 -076 -053 -030 -007 0016 0039 0062 0085
|
|
91
|
+
|
|
92
|
+
Protip: To pass a negative-number to expandseq WITHOUT it being intepreted
|
|
93
|
+
as a command-line OPTION insert a double-minus ('--') before the
|
|
94
|
+
negative-number, which is a standard technique to deliniate the end
|
|
95
|
+
of command-line options.
|
|
96
|
+
|
|
97
|
+
positional arguments:
|
|
98
|
+
FRAME-RANGE See the definition of 'FRAME-RANGE' above.
|
|
99
|
+
|
|
100
|
+
optional arguments:
|
|
101
|
+
-h, --help show this help message and exit
|
|
102
|
+
--version show program's version number and exit
|
|
103
|
+
--delimiter DELIMITER, -d DELIMITER
|
|
104
|
+
List successive numbers delimited by a 'comma',
|
|
105
|
+
'space' (default) or a 'newline'.
|
|
106
|
+
--pad PAD set the padding of the frame numbers to be <PAD>
|
|
107
|
+
digits. [default: 1]
|
|
108
|
+
--reverse, -r reverse the order of the list
|
|
109
|
+
--sort, -s sort the resulting list
|
|
110
|
+
--error exit with error if FRAME-RANGE is invalid. (default)
|
|
111
|
+
--no-error skip invalid FRAME-RANGEs, but print warning
|
|
112
|
+
--silent, --quiet suppress all errors and warnings
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## condenseseq
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
condenseseq [OPTION]... [FRAME-RANGE]...
|
|
119
|
+
|
|
120
|
+
Given a list of FRAME-RANGEs condense the fully expanded list into
|
|
121
|
+
the most succinct list of FRAME-RANGEs possible.
|
|
122
|
+
|
|
123
|
+
Examples:
|
|
124
|
+
$ condenseseq 1-100x2 2-100x2
|
|
125
|
+
1-100
|
|
126
|
+
$ condenseseq 0-100x2 51
|
|
127
|
+
0-50x2 51 52-100x2
|
|
128
|
+
$ condenseseq --pad 3 49 0-100x2 51 53
|
|
129
|
+
000-048x2 049-053 054-100x2
|
|
130
|
+
|
|
131
|
+
Protip: To pass a negative-number to expandseq WITHOUT it being intepreted
|
|
132
|
+
as a command-line OPTION insert a double-minus ('--') before the
|
|
133
|
+
negative-number, which is a standard technique to deliniate the end
|
|
134
|
+
of command-line options.
|
|
135
|
+
|
|
136
|
+
positional arguments:
|
|
137
|
+
FRAME-RANGE See the definition of 'FRAME-RANGE' above.
|
|
138
|
+
|
|
139
|
+
optional arguments:
|
|
140
|
+
-h, --help show this help message and exit
|
|
141
|
+
--version show program's version number and exit
|
|
142
|
+
--delimiter DELIMITER, -d DELIMITER
|
|
143
|
+
List successive numbers delimited by a 'comma',
|
|
144
|
+
'space' (default) or a 'newline'.
|
|
145
|
+
--only-ones only condense sucessive frames, that is, do not list
|
|
146
|
+
sequences on 2's, 3's, ... N's
|
|
147
|
+
--pad PAD set the padding of the frame numbers to be <PAD>
|
|
148
|
+
digits. [default: 1]
|
|
149
|
+
--error exit with error if FRAME-RANGE is invalid. (default)
|
|
150
|
+
--no-error skip invalid FRAME-RANGEs, but print warning
|
|
151
|
+
--silent, --quiet suppress all errors and warnings
|
|
152
|
+
|
|
153
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
seqLister>=1.1.0
|
|
File without changes
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# 3-Clause BSD License
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2008-2025, James Philip Rowell,
|
|
6
|
+
# Alpha Eleven Incorporated
|
|
7
|
+
# www.alpha-eleven.com
|
|
8
|
+
# All rights reserved.
|
|
9
|
+
#
|
|
10
|
+
# Redistribution and use in source and binary forms, with or without
|
|
11
|
+
# modification, are permitted provided that the following conditions are
|
|
12
|
+
# met:
|
|
13
|
+
#
|
|
14
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
15
|
+
# notice, this list of conditions and the following disclaimer.
|
|
16
|
+
#
|
|
17
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
18
|
+
# notice, this list of conditions and the following disclaimer in
|
|
19
|
+
# the documentation and/or other materials provided with the
|
|
20
|
+
# distribution.
|
|
21
|
+
#
|
|
22
|
+
# 3. Neither the name of the copyright holder, "Alpha Eleven, Inc.",
|
|
23
|
+
# nor the names of its contributors may be used to endorse or
|
|
24
|
+
# promote products derived from this software without specific prior
|
|
25
|
+
# written permission.
|
|
26
|
+
#
|
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
28
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
29
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
30
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
31
|
+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
32
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
33
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
34
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
35
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
36
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
37
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
38
|
+
|
|
39
|
+
# expandseq/condenseseq - two command line utilities that expose and
|
|
40
|
+
# expand upon the basic functionality of the python-module "seqLister"
|
|
41
|
+
# functions "expandSeq()" and "condenseSeq()".
|
|
42
|
+
|
|
43
|
+
import argparse
|
|
44
|
+
import os
|
|
45
|
+
import sys
|
|
46
|
+
import subprocess
|
|
47
|
+
import textwrap
|
|
48
|
+
from operator import itemgetter
|
|
49
|
+
import seqLister
|
|
50
|
+
|
|
51
|
+
# MAJOR version for incompatible API changes
|
|
52
|
+
# MINOR version for added functionality in a backwards compatible manner
|
|
53
|
+
# PATCH version for backwards compatible bug fixes
|
|
54
|
+
#
|
|
55
|
+
VERSION = "4.0.0"
|
|
56
|
+
|
|
57
|
+
PROG_NAME = "expandseq"
|
|
58
|
+
|
|
59
|
+
def main():
|
|
60
|
+
|
|
61
|
+
# Redefine the exception handling routine so that it does NOT
|
|
62
|
+
# do a trace dump if the user types ^C while expandseq or
|
|
63
|
+
# condenseseq are running.
|
|
64
|
+
#
|
|
65
|
+
old_excepthook = sys.excepthook
|
|
66
|
+
def new_hook(exceptionType, value, traceback):
|
|
67
|
+
if exceptionType != KeyboardInterrupt and exceptionType != IOError:
|
|
68
|
+
old_excepthook(exceptionType, value, traceback)
|
|
69
|
+
else:
|
|
70
|
+
pass
|
|
71
|
+
sys.excepthook = new_hook
|
|
72
|
+
|
|
73
|
+
p = argparse.ArgumentParser(
|
|
74
|
+
prog=PROG_NAME,
|
|
75
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
76
|
+
description=textwrap.dedent('''\
|
|
77
|
+
Expands a list of FRAME-RANGEs into a list of integers. A FRAME-RANGE
|
|
78
|
+
is a simple syntax widely used within the VFX-industry for specifying a
|
|
79
|
+
list of frame-numbers for image-sequences.
|
|
80
|
+
|
|
81
|
+
Definition: FRAME-RANGE
|
|
82
|
+
Given that 'A', 'B' and 'N' are integers, then a FRAME-RANGE is one,
|
|
83
|
+
or any combination, of the following:
|
|
84
|
+
|
|
85
|
+
'A' the integer A.
|
|
86
|
+
|
|
87
|
+
'A-B' all the integers from A to B inclusive.
|
|
88
|
+
|
|
89
|
+
'A-BxN' every Nth integer starting at A and increasing to be no
|
|
90
|
+
larger than B when A < B, or decreasing to be no less
|
|
91
|
+
than B when A > B.
|
|
92
|
+
|
|
93
|
+
FRAME-RANGEs may be combined to describe less regular sequences by
|
|
94
|
+
concatenating one after another separated by spaces or commas.
|
|
95
|
+
|
|
96
|
+
Example:
|
|
97
|
+
$ expandseq 2-4 1-6 10
|
|
98
|
+
2 3 4 1 5 6 10
|
|
99
|
+
|
|
100
|
+
Note in the above example that numbers are only listed once each.
|
|
101
|
+
That is, once '2-4' is listed, then '1-6' only need list 1, 5 and 6.
|
|
102
|
+
|
|
103
|
+
More examples:
|
|
104
|
+
$ expandseq 1-10x2, 20-60x10
|
|
105
|
+
1 3 5 7 9 20 30 40 50 60
|
|
106
|
+
$ expandseq --pad 3 109-91x4
|
|
107
|
+
109 105 101 097 093
|
|
108
|
+
$ expandseq --pad 4 -- -99-86x23
|
|
109
|
+
-099 -076 -053 -030 -007 0016 0039 0062 0085
|
|
110
|
+
|
|
111
|
+
Protip: To pass a negative-number to expandseq WITHOUT it being intepreted
|
|
112
|
+
as a command-line OPTION insert a double-minus ('--') before the
|
|
113
|
+
negative-number, which is a standard technique to deliniate the end
|
|
114
|
+
of command-line options.
|
|
115
|
+
|
|
116
|
+
(Also see condenseseq).
|
|
117
|
+
'''),
|
|
118
|
+
usage="%(prog)s [OPTION]... [FRAME-RANGE]...")
|
|
119
|
+
|
|
120
|
+
p.add_argument("--version", action="version", version=VERSION)
|
|
121
|
+
p.add_argument("--delimiter", "-d", action="store", type=str,
|
|
122
|
+
choices=("comma", "space", "newline"),
|
|
123
|
+
dest="seqDelimiter",
|
|
124
|
+
metavar="DELIMITER",
|
|
125
|
+
default="space",
|
|
126
|
+
help="List successive numbers delimited by a 'comma',\
|
|
127
|
+
'space' (default) or a 'newline'.")
|
|
128
|
+
p.add_argument("--pad", action="store", type=int,
|
|
129
|
+
dest="pad", default=1, metavar="PAD",
|
|
130
|
+
help="set the padding of the frame numbers to be <PAD> digits. [default: 1]")
|
|
131
|
+
p.add_argument("--reverse", "-r", action="store_true",
|
|
132
|
+
dest="reverseList", default=False,
|
|
133
|
+
help="reverse the order of the list")
|
|
134
|
+
p.add_argument("--sort", "-s", action="store_true",
|
|
135
|
+
dest="sortList", default=False,
|
|
136
|
+
help="sort the resulting list")
|
|
137
|
+
|
|
138
|
+
p.add_argument("--error", action="store_true",
|
|
139
|
+
dest="exitOnError", default=True,
|
|
140
|
+
help="exit with error if FRAME-RANGE is invalid. (default)" )
|
|
141
|
+
p.add_argument("--no-error", action="store_false",
|
|
142
|
+
dest="exitOnError",
|
|
143
|
+
help="skip invalid FRAME-RANGEs, but print warning" )
|
|
144
|
+
|
|
145
|
+
p.add_argument("--silent", "--quiet", action="store_true",
|
|
146
|
+
dest="silent", default=False,
|
|
147
|
+
help="suppress all errors and warnings")
|
|
148
|
+
|
|
149
|
+
p.add_argument("numSequences", metavar="FRAME-RANGE", nargs="*",
|
|
150
|
+
help="See the definition of 'FRAME-RANGE' above.")
|
|
151
|
+
|
|
152
|
+
args = p.parse_args()
|
|
153
|
+
|
|
154
|
+
# Copy the command line args converting commas into spaces and then
|
|
155
|
+
# splitting along ALL whitespace possibly generating more args.
|
|
156
|
+
#
|
|
157
|
+
separateArgs = []
|
|
158
|
+
for a in args.numSequences :
|
|
159
|
+
for b in a.split(',') :
|
|
160
|
+
for c in b.split() :
|
|
161
|
+
separateArgs.append(c)
|
|
162
|
+
remainingArgs = []
|
|
163
|
+
result = seqLister.expandSeq(separateArgs, remainingArgs)
|
|
164
|
+
|
|
165
|
+
# Check for any invalid FRAME-RANGEs, and respond according to
|
|
166
|
+
# flags set with OPTIONS. Only show up to 3 bad FRAME-RANGES,
|
|
167
|
+
# chop any after that and append an 'etc.' note to the warning
|
|
168
|
+
# or error message.
|
|
169
|
+
#
|
|
170
|
+
badArgsLength = len(remainingArgs)
|
|
171
|
+
if badArgsLength > 0 :
|
|
172
|
+
|
|
173
|
+
badArgsEtcLength = badArgsLength
|
|
174
|
+
if badArgsLength > 3 :
|
|
175
|
+
badArgsEtcLength = 3
|
|
176
|
+
|
|
177
|
+
plural = ''
|
|
178
|
+
count = ''
|
|
179
|
+
if badArgsLength > 1 :
|
|
180
|
+
plural = 's'
|
|
181
|
+
count = str(badArgsLength) + ' '
|
|
182
|
+
|
|
183
|
+
badFramesMessage = count \
|
|
184
|
+
+ 'invalid FRAME-RANGE' \
|
|
185
|
+
+ plural + ': ' \
|
|
186
|
+
+ ', '.join(remainingArgs[:badArgsEtcLength])
|
|
187
|
+
|
|
188
|
+
if badArgsLength > 3 :
|
|
189
|
+
badFramesMessage += ', ... etc.'
|
|
190
|
+
|
|
191
|
+
if args.exitOnError :
|
|
192
|
+
if not args.silent :
|
|
193
|
+
print(PROG_NAME,
|
|
194
|
+
": error: ", badFramesMessage,
|
|
195
|
+
file=sys.stderr, sep='')
|
|
196
|
+
sys.exit(1)
|
|
197
|
+
else :
|
|
198
|
+
if not args.silent :
|
|
199
|
+
print(PROG_NAME,
|
|
200
|
+
": warning: ", badFramesMessage,
|
|
201
|
+
file=sys.stderr, sep='')
|
|
202
|
+
|
|
203
|
+
if args.sortList :
|
|
204
|
+
result.sort()
|
|
205
|
+
|
|
206
|
+
# Pad list of integers and turn them into strings before printing.
|
|
207
|
+
#
|
|
208
|
+
formatStr = "{0:0=-" + str(args.pad) + "d}"
|
|
209
|
+
paddedFrames = []
|
|
210
|
+
for frame in result:
|
|
211
|
+
paddedFrames.append(formatStr.format(frame))
|
|
212
|
+
result = paddedFrames
|
|
213
|
+
|
|
214
|
+
if args.reverseList :
|
|
215
|
+
result.reverse()
|
|
216
|
+
|
|
217
|
+
isFirst = True
|
|
218
|
+
for s in result :
|
|
219
|
+
if args.seqDelimiter == 'space' :
|
|
220
|
+
if not isFirst :
|
|
221
|
+
sys.stdout.write(' ')
|
|
222
|
+
sys.stdout.write(str(s))
|
|
223
|
+
isFirst = False
|
|
224
|
+
elif args.seqDelimiter == 'comma' :
|
|
225
|
+
if not isFirst :
|
|
226
|
+
sys.stdout.write(',')
|
|
227
|
+
sys.stdout.write(str(s))
|
|
228
|
+
isFirst = False
|
|
229
|
+
else : # newline
|
|
230
|
+
print(s)
|
|
231
|
+
if (args.seqDelimiter == 'comma' or args.seqDelimiter == 'space') and not isFirst :
|
|
232
|
+
print()
|
|
233
|
+
|
|
234
|
+
if __name__ == '__main__':
|
|
235
|
+
main()
|
|
@@ -8,7 +8,7 @@ long_description = (here / 'README.md').read_text(encoding='utf-8')
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name = 'expandSeq',
|
|
11
|
-
version = '
|
|
11
|
+
version = '4.0.0',
|
|
12
12
|
description='Command line utils to expose functionality of seqLister python library.',
|
|
13
13
|
long_description=long_description,
|
|
14
14
|
long_description_content_type='text/markdown',
|
|
@@ -25,14 +25,14 @@ setup(
|
|
|
25
25
|
'Development Status :: 5 - Production/Stable',
|
|
26
26
|
],
|
|
27
27
|
|
|
28
|
-
packages = ['expandseq'],
|
|
28
|
+
packages = ['expandseq', 'condenseseq'],
|
|
29
29
|
python_requires = '>=3.6, <4',
|
|
30
|
-
install_requires=['seqLister'],
|
|
30
|
+
install_requires=['seqLister>=1.1.0'],
|
|
31
31
|
|
|
32
32
|
entry_points = {
|
|
33
33
|
'console_scripts': [
|
|
34
34
|
'expandseq = expandseq.__main__:main',
|
|
35
|
-
'condenseseq =
|
|
35
|
+
'condenseseq = condenseseq.__main__:main'
|
|
36
36
|
]
|
|
37
37
|
}
|
|
38
38
|
)
|
expandSeq-2.3.0/PKG-INFO
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: expandSeq
|
|
3
|
-
Version: 2.3.0
|
|
4
|
-
Summary: Command line utils to expose functionality of seqLister python library.
|
|
5
|
-
Home-page: https://github.com/jrowellfx/expandSeq
|
|
6
|
-
Author: James Philip Rowell
|
|
7
|
-
Author-email: james@alpha-eleven.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Platform: UNKNOWN
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
12
|
-
Classifier: Operating System :: POSIX
|
|
13
|
-
Classifier: Operating System :: Unix
|
|
14
|
-
Classifier: Operating System :: MacOS
|
|
15
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
-
Requires-Python: >=3.6, <4
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
License-File: LICENSE
|
|
19
|
-
|
|
20
|
-
# About expandseq and consdenseseq
|
|
21
|
-
|
|
22
|
-
`expandseq` and `condenseseq`are two unix/linux command-line utilitiies that
|
|
23
|
-
expose the functionality of the python library package `seqLister` to shell users.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
expandSeq-2.3.0/README.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: expandSeq
|
|
3
|
-
Version: 2.3.0
|
|
4
|
-
Summary: Command line utils to expose functionality of seqLister python library.
|
|
5
|
-
Home-page: https://github.com/jrowellfx/expandSeq
|
|
6
|
-
Author: James Philip Rowell
|
|
7
|
-
Author-email: james@alpha-eleven.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Platform: UNKNOWN
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
12
|
-
Classifier: Operating System :: POSIX
|
|
13
|
-
Classifier: Operating System :: Unix
|
|
14
|
-
Classifier: Operating System :: MacOS
|
|
15
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
-
Requires-Python: >=3.6, <4
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
License-File: LICENSE
|
|
19
|
-
|
|
20
|
-
# About expandseq and consdenseseq
|
|
21
|
-
|
|
22
|
-
`expandseq` and `condenseseq`are two unix/linux command-line utilitiies that
|
|
23
|
-
expose the functionality of the python library package `seqLister` to shell users.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
seqLister
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
expandseq
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
# 3-Clause BSD License
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2008-2021, James Philip Rowell,
|
|
4
|
-
# Alpha Eleven Incorporated
|
|
5
|
-
# www.alpha-eleven.com
|
|
6
|
-
# All rights reserved.
|
|
7
|
-
#
|
|
8
|
-
# Redistribution and use in source and binary forms, with or without
|
|
9
|
-
# modification, are permitted provided that the following conditions are
|
|
10
|
-
# met:
|
|
11
|
-
#
|
|
12
|
-
# 1. Redistributions of source code must retain the above copyright
|
|
13
|
-
# notice, this list of conditions and the following disclaimer.
|
|
14
|
-
#
|
|
15
|
-
# 2. Redistributions in binary form must reproduce the above copyright
|
|
16
|
-
# notice, this list of conditions and the following disclaimer in
|
|
17
|
-
# the documentation and/or other materials provided with the
|
|
18
|
-
# distribution.
|
|
19
|
-
#
|
|
20
|
-
# 3. Neither the name of the copyright holder, "Alpha Eleven, Inc.",
|
|
21
|
-
# nor the names of its contributors may be used to endorse or
|
|
22
|
-
# promote products derived from this software without specific prior
|
|
23
|
-
# written permission.
|
|
24
|
-
#
|
|
25
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
26
|
-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
27
|
-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
28
|
-
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
29
|
-
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
30
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
31
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
32
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
33
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
34
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
35
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
36
|
-
|
|
37
|
-
# expandseq/condenseseq - two command line utilities that expose the basic
|
|
38
|
-
# functionality of the python-module "seqLister.py" functions "expandSeq()"
|
|
39
|
-
# and "condenseSeq()". These functions translate back and forth between a
|
|
40
|
-
# condensed form for listing sequences of integers and plain lists of integers.
|
|
41
|
-
# Lists of integers in this condensed format are commonly used by various
|
|
42
|
-
# computer programs dealing with sequences of images such as render farm
|
|
43
|
-
# management tools (like smedge), image sequence viewers (like rv) or "ls"
|
|
44
|
-
# commands (like lsseq) to list frames from CG-animation or video footage
|
|
45
|
-
# which has been saved as a sequence of individually numbered frames.
|
|
46
|
-
#
|
|
47
|
-
# The "expandseq" and "condenseseq" commands enhance the simple behavior of
|
|
48
|
-
# the "expandSeq()" and "condenseSeq()" python functions by adding the ability
|
|
49
|
-
# to print out the lists in various forms. eg.; comma, space or newline
|
|
50
|
-
# separators as well as sorting the lists, reversing order, and mixing and
|
|
51
|
-
# matching expanded and condensed formats as arguments on the command line.
|
|
52
|
-
|
|
53
|
-
import argparse
|
|
54
|
-
import os
|
|
55
|
-
import sys
|
|
56
|
-
import subprocess
|
|
57
|
-
import textwrap
|
|
58
|
-
from operator import itemgetter
|
|
59
|
-
import seqLister
|
|
60
|
-
|
|
61
|
-
EXPAND_MODE = True
|
|
62
|
-
VERSION = "2.3.0"
|
|
63
|
-
|
|
64
|
-
def indexNegNumber(argList) :
|
|
65
|
-
i = 0
|
|
66
|
-
argLen = len(argList)
|
|
67
|
-
while i < argLen :
|
|
68
|
-
if len(argList[i]) >= 2 :
|
|
69
|
-
if argList[i][0] == '-' and argList[i][1].isdigit() :
|
|
70
|
-
return i
|
|
71
|
-
i += 1
|
|
72
|
-
return -1
|
|
73
|
-
|
|
74
|
-
def main():
|
|
75
|
-
|
|
76
|
-
# Redefine the exception handling routine so that it does NOT
|
|
77
|
-
# do a trace dump if the user types ^C while expandseq or
|
|
78
|
-
# condenseseq are running.
|
|
79
|
-
#
|
|
80
|
-
old_excepthook = sys.excepthook
|
|
81
|
-
def new_hook(exceptionType, value, traceback):
|
|
82
|
-
if exceptionType != KeyboardInterrupt and exceptionType != IOError:
|
|
83
|
-
old_excepthook(exceptionType, value, traceback)
|
|
84
|
-
else:
|
|
85
|
-
pass
|
|
86
|
-
sys.excepthook = new_hook
|
|
87
|
-
|
|
88
|
-
global EXPAND_MODE
|
|
89
|
-
if os.path.basename(sys.argv[0]) == "expandseq" :
|
|
90
|
-
EXPAND_MODE = True
|
|
91
|
-
elif os.path.basename(sys.argv[0]) == "condenseseq" :
|
|
92
|
-
EXPAND_MODE = False
|
|
93
|
-
else :
|
|
94
|
-
print(os.path.basename(sys.argv[0]), ": must be named either expandseq or condenseseq", sep='', file=sys.stderr)
|
|
95
|
-
sys.exit(1)
|
|
96
|
-
|
|
97
|
-
if EXPAND_MODE :
|
|
98
|
-
p = argparse.ArgumentParser(
|
|
99
|
-
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
100
|
-
description=textwrap.dedent('''\
|
|
101
|
-
Expands a list of integers and integer sequences of the form 'A-B' or
|
|
102
|
-
'A-BxN' into a list of integers.
|
|
103
|
-
|
|
104
|
-
A-BxN means list every Nth integer starting at A ending at the highest
|
|
105
|
-
integer less than or equal to B. Numbers will only be listed once
|
|
106
|
-
each. That is; '2-4 1-6' yeilds the list '2 3 4 1 5 6'.
|
|
107
|
-
|
|
108
|
-
Helpful hint: To pass negative numbers as an argument enclose them
|
|
109
|
-
with quotes but include a leading space.
|
|
110
|
-
For example:
|
|
111
|
-
|
|
112
|
-
" -12" or " -99-86"
|
|
113
|
-
|
|
114
|
-
Allows you to pass a minus-twelve, or minus-ninety-nine through
|
|
115
|
-
eighty-six.
|
|
116
|
-
|
|
117
|
-
(Also see condenseseq).
|
|
118
|
-
'''),
|
|
119
|
-
usage="%(prog)s [OPTION]... [INTEGER SEQUENCE]...")
|
|
120
|
-
else :
|
|
121
|
-
p = argparse.ArgumentParser(
|
|
122
|
-
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
123
|
-
description=textwrap.dedent('''\
|
|
124
|
-
Condenses a list of integers and/or integer sequences of the form
|
|
125
|
-
'A-B' or 'A-BxN' into the most minimal sequence format possible to
|
|
126
|
-
represent the full list of numbers.
|
|
127
|
-
|
|
128
|
-
Helpful hint: To pass negative numbers as an argument enclose them
|
|
129
|
-
with quotes but include a leading space.
|
|
130
|
-
For example:
|
|
131
|
-
|
|
132
|
-
" -12" or " -99-86"
|
|
133
|
-
|
|
134
|
-
Allows you to pass a minus-twelve, or minus-ninety-nine through
|
|
135
|
-
eighty-six.
|
|
136
|
-
|
|
137
|
-
(Also see expandseq).
|
|
138
|
-
'''),
|
|
139
|
-
usage="%(prog)s [OPTION]... [INTEGER SEQUENCE]...")
|
|
140
|
-
|
|
141
|
-
p.add_argument("--version", action="version", version=VERSION)
|
|
142
|
-
p.add_argument("--delimiter", "-d", action="store", type=str,
|
|
143
|
-
choices=("comma", "space", "newline"),
|
|
144
|
-
dest="seqDelimiter",
|
|
145
|
-
metavar="DELIMITER",
|
|
146
|
-
default="comma",
|
|
147
|
-
help="List successive numbers delimited by a 'comma' (default) or a 'space' or a 'newline'.")
|
|
148
|
-
if not EXPAND_MODE : # i.e.; condense
|
|
149
|
-
p.add_argument("--onlyOnes", action="store_true",
|
|
150
|
-
dest="onlyOnes", default=False,
|
|
151
|
-
help="only condense sucessive frames, that is, do not list sequences on 2's, 3's, ... N's")
|
|
152
|
-
p.add_argument("--pad", action="store", type=int,
|
|
153
|
-
dest="pad", default=1,
|
|
154
|
-
metavar="PAD",
|
|
155
|
-
help="set the padding of the frame numbers to be <PAD> digits. [default: 1]")
|
|
156
|
-
p.add_argument("--reverse", "-r", action="store_true",
|
|
157
|
-
dest="reverseList", default=False,
|
|
158
|
-
help="reverse the order of the list")
|
|
159
|
-
if EXPAND_MODE :
|
|
160
|
-
p.add_argument("--sort", "-s", action="store_true",
|
|
161
|
-
dest="sortList", default=False,
|
|
162
|
-
help="sort the resulting list")
|
|
163
|
-
p.add_argument("numSequences", metavar="INTEGER SEQUENCE", nargs="*",
|
|
164
|
-
help="is a single integer such as 'A', or a range \
|
|
165
|
-
of integers such as 'A-B' (A or B can be negative,\
|
|
166
|
-
and A may be greater than B to count backwards), or \
|
|
167
|
-
a range on N's such as 'A-BxN' where N is a positive integer.")
|
|
168
|
-
|
|
169
|
-
# Copy the command line args (except prog name) and convert
|
|
170
|
-
# commas into spaces thus making more args.
|
|
171
|
-
#
|
|
172
|
-
args = p.parse_args()
|
|
173
|
-
|
|
174
|
-
separateArgs = []
|
|
175
|
-
for a in args.numSequences :
|
|
176
|
-
for b in a.split(',') :
|
|
177
|
-
separateArgs.append(b)
|
|
178
|
-
remainingArgs = []
|
|
179
|
-
result = seqLister.expandSeq(separateArgs, remainingArgs)
|
|
180
|
-
|
|
181
|
-
if EXPAND_MODE :
|
|
182
|
-
if args.sortList :
|
|
183
|
-
result.sort()
|
|
184
|
-
# Pad list of integers and turn them into strings before printing.
|
|
185
|
-
#
|
|
186
|
-
### jpr debug ### formatStr = "{0:0=-" + str(4) + "d}"
|
|
187
|
-
formatStr = "{0:0=-" + str(args.pad) + "d}"
|
|
188
|
-
paddedFrames = []
|
|
189
|
-
for frame in result:
|
|
190
|
-
paddedFrames.append(formatStr.format(frame))
|
|
191
|
-
result = paddedFrames
|
|
192
|
-
else :
|
|
193
|
-
if args.onlyOnes :
|
|
194
|
-
result = seqLister.condenseSeqOnes(result, args.pad)
|
|
195
|
-
else :
|
|
196
|
-
result = seqLister.condenseSeq(result, args.pad)
|
|
197
|
-
|
|
198
|
-
if args.reverseList :
|
|
199
|
-
result.reverse()
|
|
200
|
-
|
|
201
|
-
isFirst = True
|
|
202
|
-
for s in result :
|
|
203
|
-
if args.seqDelimiter == 'space' :
|
|
204
|
-
if not isFirst :
|
|
205
|
-
sys.stdout.write(' ')
|
|
206
|
-
sys.stdout.write(str(s))
|
|
207
|
-
isFirst = False
|
|
208
|
-
elif args.seqDelimiter == 'comma' :
|
|
209
|
-
if not isFirst :
|
|
210
|
-
sys.stdout.write(',')
|
|
211
|
-
sys.stdout.write(str(s))
|
|
212
|
-
isFirst = False
|
|
213
|
-
else : # newline
|
|
214
|
-
print(s)
|
|
215
|
-
if (args.seqDelimiter == 'comma' or args.seqDelimiter == 'space') and not isFirst :
|
|
216
|
-
print()
|
|
217
|
-
|
|
218
|
-
if __name__ == '__main__':
|
|
219
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|