expandSeq 2.3.0__py3-none-any.whl → 4.0.0__py3-none-any.whl
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.
- condenseseq/__init__.py +0 -0
- condenseseq/__main__.py +240 -0
- {expandSeq-2.3.0.dist-info → expandSeq-4.0.0.dist-info}/LICENSE +1 -1
- expandSeq-4.0.0.dist-info/METADATA +153 -0
- expandSeq-4.0.0.dist-info/RECORD +10 -0
- {expandSeq-2.3.0.dist-info → expandSeq-4.0.0.dist-info}/WHEEL +1 -1
- {expandSeq-2.3.0.dist-info → expandSeq-4.0.0.dist-info}/entry_points.txt +1 -2
- expandSeq-4.0.0.dist-info/top_level.txt +2 -0
- expandseq/__main__.py +120 -104
- expandSeq-2.3.0.dist-info/METADATA +0 -27
- expandSeq-2.3.0.dist-info/RECORD +0 -8
- expandSeq-2.3.0.dist-info/top_level.txt +0 -1
condenseseq/__init__.py
ADDED
|
File without changes
|
condenseseq/__main__.py
ADDED
|
@@ -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,10 @@
|
|
|
1
|
+
condenseseq/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
condenseseq/__main__.py,sha256=Snb1xISSczj-XYE6A-Q3H3JHx4MNYKdzyfTEOWzrY-E,9105
|
|
3
|
+
expandseq/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
expandseq/__main__.py,sha256=jw3uv_YkvitmJAugURJfeEtGQ8_BlHZG0cU9Qa8xrlQ,8650
|
|
5
|
+
expandSeq-4.0.0.dist-info/LICENSE,sha256=7ssn-dBSkdFTvXKCXb6weBMit69-58B_3P7GA5VBvms,1620
|
|
6
|
+
expandSeq-4.0.0.dist-info/METADATA,sha256=6RGwytKGjjOd6pcHm99vJ90xuMPDtV3h4QzneUbPT_4,4974
|
|
7
|
+
expandSeq-4.0.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
8
|
+
expandSeq-4.0.0.dist-info/entry_points.txt,sha256=jPMAMCyVL3KeArm7ZsjKIxP_DoJF-k47q9nOSTJ2I78,94
|
|
9
|
+
expandSeq-4.0.0.dist-info/top_level.txt,sha256=RdXBSEQ2TUgy7KyzH1P0KkXp9U4gfjdr7ikaCt9TNNQ,22
|
|
10
|
+
expandSeq-4.0.0.dist-info/RECORD,,
|
expandseq/__main__.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
1
3
|
# 3-Clause BSD License
|
|
2
4
|
#
|
|
3
|
-
# Copyright (c) 2008-
|
|
5
|
+
# Copyright (c) 2008-2025, James Philip Rowell,
|
|
4
6
|
# Alpha Eleven Incorporated
|
|
5
7
|
# www.alpha-eleven.com
|
|
6
8
|
# All rights reserved.
|
|
@@ -34,21 +36,9 @@
|
|
|
34
36
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
35
37
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
36
38
|
|
|
37
|
-
# expandseq/condenseseq - two command line utilities that expose
|
|
38
|
-
# functionality of the python-module "seqLister
|
|
39
|
-
# and "condenseSeq()".
|
|
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.
|
|
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()".
|
|
52
42
|
|
|
53
43
|
import argparse
|
|
54
44
|
import os
|
|
@@ -58,18 +48,13 @@ import textwrap
|
|
|
58
48
|
from operator import itemgetter
|
|
59
49
|
import seqLister
|
|
60
50
|
|
|
61
|
-
|
|
62
|
-
|
|
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"
|
|
63
56
|
|
|
64
|
-
|
|
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
|
|
57
|
+
PROG_NAME = "expandseq"
|
|
73
58
|
|
|
74
59
|
def main():
|
|
75
60
|
|
|
@@ -85,115 +70,146 @@ def main():
|
|
|
85
70
|
pass
|
|
86
71
|
sys.excepthook = new_hook
|
|
87
72
|
|
|
88
|
-
|
|
89
|
-
|
|
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(
|
|
73
|
+
p = argparse.ArgumentParser(
|
|
74
|
+
prog=PROG_NAME,
|
|
99
75
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
100
76
|
description=textwrap.dedent('''\
|
|
101
|
-
Expands a list of
|
|
102
|
-
|
|
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.
|
|
103
80
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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:
|
|
107
84
|
|
|
108
|
-
|
|
109
|
-
with quotes but include a leading space.
|
|
110
|
-
For example:
|
|
85
|
+
'A' the integer A.
|
|
111
86
|
|
|
112
|
-
|
|
87
|
+
'A-B' all the integers from A to B inclusive.
|
|
113
88
|
|
|
114
|
-
|
|
115
|
-
|
|
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.
|
|
116
92
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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.
|
|
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
|
|
127
99
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
For example:
|
|
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.
|
|
131
102
|
|
|
132
|
-
|
|
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
|
|
133
110
|
|
|
134
|
-
|
|
135
|
-
|
|
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.
|
|
136
115
|
|
|
137
|
-
(Also see
|
|
116
|
+
(Also see condenseseq).
|
|
138
117
|
'''),
|
|
139
|
-
|
|
118
|
+
usage="%(prog)s [OPTION]... [FRAME-RANGE]...")
|
|
140
119
|
|
|
141
120
|
p.add_argument("--version", action="version", version=VERSION)
|
|
142
121
|
p.add_argument("--delimiter", "-d", action="store", type=str,
|
|
143
122
|
choices=("comma", "space", "newline"),
|
|
144
123
|
dest="seqDelimiter",
|
|
145
124
|
metavar="DELIMITER",
|
|
146
|
-
default="
|
|
147
|
-
help="List successive numbers delimited by a 'comma'
|
|
148
|
-
|
|
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")
|
|
125
|
+
default="space",
|
|
126
|
+
help="List successive numbers delimited by a 'comma',\
|
|
127
|
+
'space' (default) or a 'newline'.")
|
|
152
128
|
p.add_argument("--pad", action="store", type=int,
|
|
153
|
-
dest="pad", default=1,
|
|
154
|
-
metavar="PAD",
|
|
129
|
+
dest="pad", default=1, metavar="PAD",
|
|
155
130
|
help="set the padding of the frame numbers to be <PAD> digits. [default: 1]")
|
|
156
131
|
p.add_argument("--reverse", "-r", action="store_true",
|
|
157
132
|
dest="reverseList", default=False,
|
|
158
133
|
help="reverse the order of the list")
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
p.add_argument("
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
+
|
|
172
152
|
args = p.parse_args()
|
|
173
153
|
|
|
154
|
+
# Copy the command line args converting commas into spaces and then
|
|
155
|
+
# splitting along ALL whitespace possibly generating more args.
|
|
156
|
+
#
|
|
174
157
|
separateArgs = []
|
|
175
158
|
for a in args.numSequences :
|
|
176
159
|
for b in a.split(',') :
|
|
177
|
-
|
|
160
|
+
for c in b.split() :
|
|
161
|
+
separateArgs.append(c)
|
|
178
162
|
remainingArgs = []
|
|
179
163
|
result = seqLister.expandSeq(separateArgs, remainingArgs)
|
|
180
164
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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)
|
|
195
197
|
else :
|
|
196
|
-
|
|
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
|
|
197
213
|
|
|
198
214
|
if args.reverseList :
|
|
199
215
|
result.reverse()
|
|
@@ -1,27 +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
|
-
Requires-Dist: seqLister
|
|
20
|
-
|
|
21
|
-
# About expandseq and consdenseseq
|
|
22
|
-
|
|
23
|
-
`expandseq` and `condenseseq`are two unix/linux command-line utilitiies that
|
|
24
|
-
expose the functionality of the python library package `seqLister` to shell users.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
expandSeq-2.3.0.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
expandseq/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
expandseq/__main__.py,sha256=4tfBuIMAI4ZjuFwK1JuTwv0C32GLTrxTwYXWzx8ih-s,8741
|
|
3
|
-
expandSeq-2.3.0.dist-info/LICENSE,sha256=uJumFikn_4U3QE8iJV02efpAIb29chJkDyP1usjd6MA,1620
|
|
4
|
-
expandSeq-2.3.0.dist-info/METADATA,sha256=ceEIJESqaZ1SdCiIhAekubOJF7BLJth3999BcRMNO7M,866
|
|
5
|
-
expandSeq-2.3.0.dist-info/WHEEL,sha256=OqRkF0eY5GHssMorFjlbTIq072vpHpF60fIQA6lS9xA,92
|
|
6
|
-
expandSeq-2.3.0.dist-info/entry_points.txt,sha256=iZkuadyNEBIPHOylIyWHeRuS4SSBLUFJgHwNqxN2XtU,93
|
|
7
|
-
expandSeq-2.3.0.dist-info/top_level.txt,sha256=K9B5Uev376UPiMcSB33sel_pLvLU0of7QdieACDDKAo,10
|
|
8
|
-
expandSeq-2.3.0.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
expandseq
|