pyseq 0.8.2__tar.gz → 0.8.4__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.
- {pyseq-0.8.2 → pyseq-0.8.4}/PKG-INFO +73 -28
- {pyseq-0.8.2 → pyseq-0.8.4}/README.md +72 -27
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq/__init__.py +1 -1
- pyseq-0.8.4/lib/pyseq/config.py +66 -0
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq/seq.py +19 -27
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq.egg-info/PKG-INFO +73 -28
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq.egg-info/SOURCES.txt +1 -1
- {pyseq-0.8.2 → pyseq-0.8.4}/setup.py +0 -1
- pyseq-0.8.2/lib/pyseq.egg-info/requires.txt +0 -1
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq/lss.py +0 -0
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq/util.py +0 -0
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq.egg-info/dependency_links.txt +0 -0
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq.egg-info/entry_points.txt +0 -0
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq.egg-info/not-zip-safe +0 -0
- {pyseq-0.8.2 → pyseq-0.8.4}/lib/pyseq.egg-info/top_level.txt +0 -0
- {pyseq-0.8.2 → pyseq-0.8.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyseq
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.4
|
|
4
4
|
Summary: Compressed File Sequence String Module
|
|
5
5
|
Home-page: http://github.com/rsgalloway/pyseq
|
|
6
6
|
Author: Ryan Galloway
|
|
@@ -24,35 +24,36 @@ Description: PySeq
|
|
|
24
24
|
$ pip install -U pyseq
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
####
|
|
27
|
+
#### Environment
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
PySeq uses [envstack](https://github.com/rsgalloway/envstack) to externalize
|
|
30
|
+
settings and looks for a `pyseq.env` file to source environment variables:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
$
|
|
33
|
+
$ pip install -U envstack
|
|
34
|
+
$ ./pyseq.env -r
|
|
35
|
+
PYSEQ_FRAME_PATTERN=\d+
|
|
36
|
+
PYSEQ_RANGE_SEP=,
|
|
37
|
+
PYSEQ_STRICT_PAD=0
|
|
34
38
|
```
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
root folder defined by `$DEPLOY_ROOT`.
|
|
38
|
-
|
|
39
|
-
#### envstack
|
|
40
|
+
#### Distribution
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
If installing from source you can use [distman](https://github.com/rsgalloway/distman)
|
|
43
|
+
to install PySeq using the provided `dist.json` file:
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
|
-
$
|
|
46
|
-
|
|
47
|
-
PYSEQ_STRICT_PAD=0
|
|
48
|
-
STACK=pyseq
|
|
46
|
+
$ pip install -U distman
|
|
47
|
+
$ distman [-d]
|
|
49
48
|
```
|
|
50
49
|
|
|
50
|
+
Using distman will deploy the targets defined in the `dist.json` file to the
|
|
51
|
+
root folder defined by `${DEPLOY_ROOT}`:
|
|
52
|
+
|
|
51
53
|
## Basic Usage
|
|
52
54
|
|
|
53
55
|
Using the "z1" file sequence example in the "tests" directory, we start by
|
|
54
|
-
listing the directory
|
|
55
|
-
contents using `ls`:
|
|
56
|
+
listing the directory contents using `ls`:
|
|
56
57
|
|
|
57
58
|
```bash
|
|
58
59
|
$ ls tests/files/z1*
|
|
@@ -71,16 +72,7 @@ Description: PySeq
|
|
|
71
72
|
4 z1_002_v2.%d.png [9-12]
|
|
72
73
|
```
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
$ lss tests/files/z1* -f "%h%r%t"
|
|
78
|
-
z1_001_v1.1-4.png
|
|
79
|
-
z1_002_v1.1-4.png
|
|
80
|
-
z1_002_v2.9-12.png
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Recursive:
|
|
75
|
+
Recursivly walk a folder and find all the sequences:
|
|
84
76
|
|
|
85
77
|
```bash
|
|
86
78
|
$ lss -r tests
|
|
@@ -95,7 +87,7 @@ Description: PySeq
|
|
|
95
87
|
├── bnc01_TinkSO_tx_0_ty_1.101-105.tif
|
|
96
88
|
├── bnc01_TinkSO_tx_1_ty_0.101-105.tif
|
|
97
89
|
├── bnc01_TinkSO_tx_1_ty_1.101-105.tif
|
|
98
|
-
├── file.1-
|
|
90
|
+
├── file.1-99.tif
|
|
99
91
|
├── file.info.03.rgb
|
|
100
92
|
├── file01.1-4.j2k
|
|
101
93
|
├── file01_40-43.rgb
|
|
@@ -109,6 +101,30 @@ Description: PySeq
|
|
|
109
101
|
└── z1_002_v2.9-12.png
|
|
110
102
|
```
|
|
111
103
|
|
|
104
|
+
Piping the output of `find` to `lss`, for example finding all the png sequences:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
$ find ./tests/ -name *.png | xargs lss
|
|
108
|
+
10 012_vb_110_v001.%04d.png [1-10]
|
|
109
|
+
10 012_vb_110_v002.%04d.png [1-10]
|
|
110
|
+
3 fileA.%04d.png [1-3]
|
|
111
|
+
4 z1_001_v1.%d.png [1-4]
|
|
112
|
+
4 z1_002_v1.%d.png [1-4]
|
|
113
|
+
4 z1_002_v2.%d.png [9-12]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Use the `--format` option to retain the relative path:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
$ find tests/ -name "*.png" | xargs lss -f "%D%h%r%t"
|
|
120
|
+
tests/files/012_vb_110_v001.1-10.png
|
|
121
|
+
tests/files/012_vb_110_v002.1-10.png
|
|
122
|
+
tests/files/fileA.1-3.png
|
|
123
|
+
tests/files/z1_001_v1.1-4.png
|
|
124
|
+
tests/files/z1_002_v1.1-4.png
|
|
125
|
+
tests/files/z1_002_v2.9-12.png
|
|
126
|
+
```
|
|
127
|
+
|
|
112
128
|
## API Examples
|
|
113
129
|
|
|
114
130
|
Compression, or serialization, of lists of items:
|
|
@@ -132,6 +148,17 @@ Description: PySeq
|
|
|
132
148
|
1001 012_vb_110_v001.%04d.png [1-1001]
|
|
133
149
|
```
|
|
134
150
|
|
|
151
|
+
Walk a directory tree and print disk usage for file sequences:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
>>> for root, dirs, seqs in pyseq.walk(folder):
|
|
155
|
+
... for seq in seqs:
|
|
156
|
+
... print(seq.format("%h%r%t %H"))
|
|
157
|
+
012_vb_110_v001.1000-1321.exr 123.5G
|
|
158
|
+
012_vb_110_v002.1000-1163.exr 40.2G
|
|
159
|
+
012_vb_110_v003.1000-1027.exr 72.2G
|
|
160
|
+
```
|
|
161
|
+
|
|
135
162
|
## Formatting
|
|
136
163
|
|
|
137
164
|
The following directives can be embedded in the format string.
|
|
@@ -178,6 +205,24 @@ Description: PySeq
|
|
|
178
205
|
7 a.1-14.tga [4-9, 11]
|
|
179
206
|
```
|
|
180
207
|
|
|
208
|
+
## Frame Patterns
|
|
209
|
+
|
|
210
|
+
The environment var `${PYSEQ_FRAME_PATTERN}` can be used to define custom regex
|
|
211
|
+
patterns for identifying frame numbers. For example if frames are always preceded
|
|
212
|
+
with an _, you might use:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
$ export PYSEQ_FRAME_PATTERN="_\d+"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Environment vars can be defined anywhere in your environment, or if using
|
|
219
|
+
[envstack](https://github.com/rsgalloway/envstack) add it to the
|
|
220
|
+
`pyseq.env` file and make sure it's found in `${ENVPATH}`:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
$ export ENVPATH=/path/to/env/files
|
|
224
|
+
```
|
|
225
|
+
|
|
181
226
|
## Testing
|
|
182
227
|
|
|
183
228
|
To run the unit tests, simply run `pytest` in a shell:
|
|
@@ -16,35 +16,36 @@ The easiest way to install pyseq:
|
|
|
16
16
|
$ pip install -U pyseq
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
####
|
|
19
|
+
#### Environment
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
PySeq uses [envstack](https://github.com/rsgalloway/envstack) to externalize
|
|
22
|
+
settings and looks for a `pyseq.env` file to source environment variables:
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
$
|
|
25
|
+
$ pip install -U envstack
|
|
26
|
+
$ ./pyseq.env -r
|
|
27
|
+
PYSEQ_FRAME_PATTERN=\d+
|
|
28
|
+
PYSEQ_RANGE_SEP=,
|
|
29
|
+
PYSEQ_STRICT_PAD=0
|
|
26
30
|
```
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
root folder defined by `$DEPLOY_ROOT`.
|
|
30
|
-
|
|
31
|
-
#### envstack
|
|
32
|
+
#### Distribution
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
If installing from source you can use [distman](https://github.com/rsgalloway/distman)
|
|
35
|
+
to install PySeq using the provided `dist.json` file:
|
|
35
36
|
|
|
36
37
|
```bash
|
|
37
|
-
$
|
|
38
|
-
|
|
39
|
-
PYSEQ_STRICT_PAD=0
|
|
40
|
-
STACK=pyseq
|
|
38
|
+
$ pip install -U distman
|
|
39
|
+
$ distman [-d]
|
|
41
40
|
```
|
|
42
41
|
|
|
42
|
+
Using distman will deploy the targets defined in the `dist.json` file to the
|
|
43
|
+
root folder defined by `${DEPLOY_ROOT}`:
|
|
44
|
+
|
|
43
45
|
## Basic Usage
|
|
44
46
|
|
|
45
47
|
Using the "z1" file sequence example in the "tests" directory, we start by
|
|
46
|
-
listing the directory
|
|
47
|
-
contents using `ls`:
|
|
48
|
+
listing the directory contents using `ls`:
|
|
48
49
|
|
|
49
50
|
```bash
|
|
50
51
|
$ ls tests/files/z1*
|
|
@@ -63,16 +64,7 @@ $ lss tests/files/z1*
|
|
|
63
64
|
4 z1_002_v2.%d.png [9-12]
|
|
64
65
|
```
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
$ lss tests/files/z1* -f "%h%r%t"
|
|
70
|
-
z1_001_v1.1-4.png
|
|
71
|
-
z1_002_v1.1-4.png
|
|
72
|
-
z1_002_v2.9-12.png
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Recursive:
|
|
67
|
+
Recursivly walk a folder and find all the sequences:
|
|
76
68
|
|
|
77
69
|
```bash
|
|
78
70
|
$ lss -r tests
|
|
@@ -87,7 +79,7 @@ tests
|
|
|
87
79
|
├── bnc01_TinkSO_tx_0_ty_1.101-105.tif
|
|
88
80
|
├── bnc01_TinkSO_tx_1_ty_0.101-105.tif
|
|
89
81
|
├── bnc01_TinkSO_tx_1_ty_1.101-105.tif
|
|
90
|
-
├── file.1-
|
|
82
|
+
├── file.1-99.tif
|
|
91
83
|
├── file.info.03.rgb
|
|
92
84
|
├── file01.1-4.j2k
|
|
93
85
|
├── file01_40-43.rgb
|
|
@@ -101,6 +93,30 @@ tests
|
|
|
101
93
|
└── z1_002_v2.9-12.png
|
|
102
94
|
```
|
|
103
95
|
|
|
96
|
+
Piping the output of `find` to `lss`, for example finding all the png sequences:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
$ find ./tests/ -name *.png | xargs lss
|
|
100
|
+
10 012_vb_110_v001.%04d.png [1-10]
|
|
101
|
+
10 012_vb_110_v002.%04d.png [1-10]
|
|
102
|
+
3 fileA.%04d.png [1-3]
|
|
103
|
+
4 z1_001_v1.%d.png [1-4]
|
|
104
|
+
4 z1_002_v1.%d.png [1-4]
|
|
105
|
+
4 z1_002_v2.%d.png [9-12]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Use the `--format` option to retain the relative path:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
$ find tests/ -name "*.png" | xargs lss -f "%D%h%r%t"
|
|
112
|
+
tests/files/012_vb_110_v001.1-10.png
|
|
113
|
+
tests/files/012_vb_110_v002.1-10.png
|
|
114
|
+
tests/files/fileA.1-3.png
|
|
115
|
+
tests/files/z1_001_v1.1-4.png
|
|
116
|
+
tests/files/z1_002_v1.1-4.png
|
|
117
|
+
tests/files/z1_002_v2.9-12.png
|
|
118
|
+
```
|
|
119
|
+
|
|
104
120
|
## API Examples
|
|
105
121
|
|
|
106
122
|
Compression, or serialization, of lists of items:
|
|
@@ -124,6 +140,17 @@ Uncompression, or deserialization, of compressed sequences strings:
|
|
|
124
140
|
1001 012_vb_110_v001.%04d.png [1-1001]
|
|
125
141
|
```
|
|
126
142
|
|
|
143
|
+
Walk a directory tree and print disk usage for file sequences:
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
>>> for root, dirs, seqs in pyseq.walk(folder):
|
|
147
|
+
... for seq in seqs:
|
|
148
|
+
... print(seq.format("%h%r%t %H"))
|
|
149
|
+
012_vb_110_v001.1000-1321.exr 123.5G
|
|
150
|
+
012_vb_110_v002.1000-1163.exr 40.2G
|
|
151
|
+
012_vb_110_v003.1000-1027.exr 72.2G
|
|
152
|
+
```
|
|
153
|
+
|
|
127
154
|
## Formatting
|
|
128
155
|
|
|
129
156
|
The following directives can be embedded in the format string.
|
|
@@ -170,6 +197,24 @@ a.1-14.tga
|
|
|
170
197
|
7 a.1-14.tga [4-9, 11]
|
|
171
198
|
```
|
|
172
199
|
|
|
200
|
+
## Frame Patterns
|
|
201
|
+
|
|
202
|
+
The environment var `${PYSEQ_FRAME_PATTERN}` can be used to define custom regex
|
|
203
|
+
patterns for identifying frame numbers. For example if frames are always preceded
|
|
204
|
+
with an _, you might use:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
$ export PYSEQ_FRAME_PATTERN="_\d+"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Environment vars can be defined anywhere in your environment, or if using
|
|
211
|
+
[envstack](https://github.com/rsgalloway/envstack) add it to the
|
|
212
|
+
`pyseq.env` file and make sure it's found in `${ENVPATH}`:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
$ export ENVPATH=/path/to/env/files
|
|
216
|
+
```
|
|
217
|
+
|
|
173
218
|
## Testing
|
|
174
219
|
|
|
175
220
|
To run the unit tests, simply run `pytest` in a shell:
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2011-2025, Ryan Galloway (ryan@rsgalloway.com)
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
#
|
|
8
|
+
# - Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
# this list of conditions and the following disclaimer.
|
|
10
|
+
#
|
|
11
|
+
# - Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
#
|
|
15
|
+
# - Neither the name of the software nor the names of its contributors
|
|
16
|
+
# may be used to endorse or promote products derived from this software
|
|
17
|
+
# without specific prior written permission.
|
|
18
|
+
#
|
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
# -----------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
__doc__ = """
|
|
33
|
+
Contains pyseq configs and default settings.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
import os
|
|
37
|
+
import re
|
|
38
|
+
|
|
39
|
+
# default serialization format string
|
|
40
|
+
DEFAULT_FORMAT = "%h%r%t"
|
|
41
|
+
default_format = os.getenv("PYSEQ_DEFAULT_FORMAT", DEFAULT_FORMAT)
|
|
42
|
+
|
|
43
|
+
# default serialization format string for global sequences
|
|
44
|
+
DEFAULT_GLOBAL_FORMAT = "%4l %h%p%t %R"
|
|
45
|
+
global_format = os.getenv("PYSEQ_GLOBAL_FORMAT", DEFAULT_GLOBAL_FORMAT)
|
|
46
|
+
|
|
47
|
+
# use strict padding on sequences (pad length must match)
|
|
48
|
+
PYSEQ_STRICT_PAD = os.getenv("PYSEQ_STRICT_PAD", 0)
|
|
49
|
+
PYSEQ_NOT_STRICT = os.getenv("PYSEQ_NOT_STRICT", 1)
|
|
50
|
+
strict_pad = int(PYSEQ_STRICT_PAD) == 1 or int(PYSEQ_NOT_STRICT) == 0
|
|
51
|
+
|
|
52
|
+
# regex pattern for matching all numbers in a filename
|
|
53
|
+
digits_re = re.compile(r"\d+")
|
|
54
|
+
|
|
55
|
+
# regex pattern for matching frame numbers only
|
|
56
|
+
# the default is \d+ for maximum compatibility
|
|
57
|
+
DEFAULT_FRAME_PATTERN = r"\d+"
|
|
58
|
+
PYSEQ_FRAME_PATTERN = os.getenv("PYSEQ_FRAME_PATTERN", DEFAULT_FRAME_PATTERN)
|
|
59
|
+
frames_re = re.compile(PYSEQ_FRAME_PATTERN)
|
|
60
|
+
|
|
61
|
+
# regex for matching format directives
|
|
62
|
+
format_re = re.compile(r"%(?P<pad>\d+)?(?P<var>\w+)")
|
|
63
|
+
|
|
64
|
+
# character to join explicit frame ranges on
|
|
65
|
+
DEFAULT_RANGE_SEP = ", "
|
|
66
|
+
range_join = os.getenv("PYSEQ_RANGE_SEP", DEFAULT_RANGE_SEP)
|
|
@@ -41,30 +41,16 @@ import warnings
|
|
|
41
41
|
from collections import deque
|
|
42
42
|
from glob import glob, iglob
|
|
43
43
|
|
|
44
|
+
from pyseq import config
|
|
44
45
|
from pyseq.util import _ext_key
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# $ export PYSEQ_STRICT_PAD=1 or
|
|
52
|
-
# $ export PYSEQ_NOT_STRICT=1
|
|
53
|
-
# to enable/disable. disabled by default.
|
|
54
|
-
strict_pad = (
|
|
55
|
-
int(os.getenv("PYSEQ_STRICT_PAD", 0)) == 1
|
|
56
|
-
or int(os.getenv("PYSEQ_NOT_STRICT", 1)) == 0
|
|
46
|
+
from pyseq.config import (
|
|
47
|
+
default_format,
|
|
48
|
+
format_re,
|
|
49
|
+
global_format,
|
|
50
|
+
range_join,
|
|
51
|
+
strict_pad,
|
|
57
52
|
)
|
|
58
53
|
|
|
59
|
-
# regex for matching numerical characters
|
|
60
|
-
digits_re = re.compile(r"\d+")
|
|
61
|
-
|
|
62
|
-
# regex for matching format directives
|
|
63
|
-
format_re = re.compile(r"%(?P<pad>\d+)?(?P<var>\w+)")
|
|
64
|
-
|
|
65
|
-
# character to join explicit frame ranges on
|
|
66
|
-
range_join = os.getenv("PYSEQ_RANGE_SEP", ", ")
|
|
67
|
-
|
|
68
54
|
|
|
69
55
|
class SequenceError(Exception):
|
|
70
56
|
"""Special exception for Sequence errors."""
|
|
@@ -120,7 +106,7 @@ class Item(str):
|
|
|
120
106
|
self.__path = str(item)
|
|
121
107
|
self.__filename = os.path.basename(self.__path)
|
|
122
108
|
self.__number_matches = []
|
|
123
|
-
self.__parts =
|
|
109
|
+
self.__parts = config.frames_re.split(self.name)
|
|
124
110
|
self.__stat = None
|
|
125
111
|
|
|
126
112
|
# modified by self.is_sibling()
|
|
@@ -250,7 +236,7 @@ class Item(str):
|
|
|
250
236
|
|
|
251
237
|
:return: The numerical components.
|
|
252
238
|
"""
|
|
253
|
-
return
|
|
239
|
+
return config.frames_re.findall(self.__filename)
|
|
254
240
|
|
|
255
241
|
@property
|
|
256
242
|
def number_matches(self):
|
|
@@ -260,7 +246,7 @@ class Item(str):
|
|
|
260
246
|
:return: The numerical components.
|
|
261
247
|
"""
|
|
262
248
|
if not self.__number_matches:
|
|
263
|
-
self.__number_matches = list(digits_re.finditer(self.__filename))
|
|
249
|
+
self.__number_matches = list(config.digits_re.finditer(self.__filename))
|
|
264
250
|
return self.__number_matches
|
|
265
251
|
|
|
266
252
|
@property
|
|
@@ -330,7 +316,7 @@ class Item(str):
|
|
|
330
316
|
if is_sibling:
|
|
331
317
|
frame = d[0]["frames"][0]
|
|
332
318
|
self.frame = int(frame)
|
|
333
|
-
self.pad = padsize(item, frame)
|
|
319
|
+
self.pad = padsize(item, frame) if self.pad is None else self.pad
|
|
334
320
|
self.head = self.name[: d[0]["start"]]
|
|
335
321
|
self.tail = self.name[d[0]["end"] :] # noqa
|
|
336
322
|
frame = d[0]["frames"][1]
|
|
@@ -1055,7 +1041,7 @@ def uncompress(seq_string, fmt=global_format):
|
|
|
1055
1041
|
return seqs
|
|
1056
1042
|
|
|
1057
1043
|
|
|
1058
|
-
def get_sequences(source):
|
|
1044
|
+
def get_sequences(source, frame_pattern=config.PYSEQ_FRAME_PATTERN):
|
|
1059
1045
|
"""Returns a list of Sequence objects given a directory or list that contain
|
|
1060
1046
|
sequential members.
|
|
1061
1047
|
|
|
@@ -1091,11 +1077,14 @@ def get_sequences(source):
|
|
|
1091
1077
|
fileB.1.rgb
|
|
1092
1078
|
|
|
1093
1079
|
:param source: Can be directory path, list of strings, or sortable list of objects.
|
|
1080
|
+
:param frame_pattern: Regular expression pattern for frame matching.
|
|
1094
1081
|
:return: List of pyseq.Sequence class objects.
|
|
1095
1082
|
"""
|
|
1096
1083
|
|
|
1097
1084
|
seqs = []
|
|
1098
1085
|
|
|
1086
|
+
config.frames_re = re.compile(frame_pattern)
|
|
1087
|
+
|
|
1099
1088
|
if isinstance(source, list):
|
|
1100
1089
|
items = sorted(source, key=lambda x: str(x))
|
|
1101
1090
|
|
|
@@ -1126,7 +1115,7 @@ def get_sequences(source):
|
|
|
1126
1115
|
return seqs
|
|
1127
1116
|
|
|
1128
1117
|
|
|
1129
|
-
def iget_sequences(source):
|
|
1118
|
+
def iget_sequences(source, frame_pattern=config.PYSEQ_FRAME_PATTERN):
|
|
1130
1119
|
"""Generator version of get_sequences. Creates Sequences from a various
|
|
1131
1120
|
source files. A notable difference is the sort order of iget_sequences
|
|
1132
1121
|
versus get_sequences. iget_sequences uses an adaption of natural sorting
|
|
@@ -1170,9 +1159,12 @@ def iget_sequences(source):
|
|
|
1170
1159
|
fileB.1.rgb
|
|
1171
1160
|
|
|
1172
1161
|
:param source: Can be directory path, list of strings, or sortable list of objects.
|
|
1162
|
+
:param frame_pattern: Regular expression pattern for frame matching.
|
|
1173
1163
|
:return: List of pyseq.Sequence class objects.
|
|
1174
1164
|
"""
|
|
1175
1165
|
|
|
1166
|
+
config.frames_re = re.compile(frame_pattern)
|
|
1167
|
+
|
|
1176
1168
|
if isinstance(source, list):
|
|
1177
1169
|
items = source
|
|
1178
1170
|
elif isinstance(source, str):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyseq
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.4
|
|
4
4
|
Summary: Compressed File Sequence String Module
|
|
5
5
|
Home-page: http://github.com/rsgalloway/pyseq
|
|
6
6
|
Author: Ryan Galloway
|
|
@@ -24,35 +24,36 @@ Description: PySeq
|
|
|
24
24
|
$ pip install -U pyseq
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
####
|
|
27
|
+
#### Environment
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
PySeq uses [envstack](https://github.com/rsgalloway/envstack) to externalize
|
|
30
|
+
settings and looks for a `pyseq.env` file to source environment variables:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
$
|
|
33
|
+
$ pip install -U envstack
|
|
34
|
+
$ ./pyseq.env -r
|
|
35
|
+
PYSEQ_FRAME_PATTERN=\d+
|
|
36
|
+
PYSEQ_RANGE_SEP=,
|
|
37
|
+
PYSEQ_STRICT_PAD=0
|
|
34
38
|
```
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
root folder defined by `$DEPLOY_ROOT`.
|
|
38
|
-
|
|
39
|
-
#### envstack
|
|
40
|
+
#### Distribution
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
If installing from source you can use [distman](https://github.com/rsgalloway/distman)
|
|
43
|
+
to install PySeq using the provided `dist.json` file:
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
|
-
$
|
|
46
|
-
|
|
47
|
-
PYSEQ_STRICT_PAD=0
|
|
48
|
-
STACK=pyseq
|
|
46
|
+
$ pip install -U distman
|
|
47
|
+
$ distman [-d]
|
|
49
48
|
```
|
|
50
49
|
|
|
50
|
+
Using distman will deploy the targets defined in the `dist.json` file to the
|
|
51
|
+
root folder defined by `${DEPLOY_ROOT}`:
|
|
52
|
+
|
|
51
53
|
## Basic Usage
|
|
52
54
|
|
|
53
55
|
Using the "z1" file sequence example in the "tests" directory, we start by
|
|
54
|
-
listing the directory
|
|
55
|
-
contents using `ls`:
|
|
56
|
+
listing the directory contents using `ls`:
|
|
56
57
|
|
|
57
58
|
```bash
|
|
58
59
|
$ ls tests/files/z1*
|
|
@@ -71,16 +72,7 @@ Description: PySeq
|
|
|
71
72
|
4 z1_002_v2.%d.png [9-12]
|
|
72
73
|
```
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
$ lss tests/files/z1* -f "%h%r%t"
|
|
78
|
-
z1_001_v1.1-4.png
|
|
79
|
-
z1_002_v1.1-4.png
|
|
80
|
-
z1_002_v2.9-12.png
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Recursive:
|
|
75
|
+
Recursivly walk a folder and find all the sequences:
|
|
84
76
|
|
|
85
77
|
```bash
|
|
86
78
|
$ lss -r tests
|
|
@@ -95,7 +87,7 @@ Description: PySeq
|
|
|
95
87
|
├── bnc01_TinkSO_tx_0_ty_1.101-105.tif
|
|
96
88
|
├── bnc01_TinkSO_tx_1_ty_0.101-105.tif
|
|
97
89
|
├── bnc01_TinkSO_tx_1_ty_1.101-105.tif
|
|
98
|
-
├── file.1-
|
|
90
|
+
├── file.1-99.tif
|
|
99
91
|
├── file.info.03.rgb
|
|
100
92
|
├── file01.1-4.j2k
|
|
101
93
|
├── file01_40-43.rgb
|
|
@@ -109,6 +101,30 @@ Description: PySeq
|
|
|
109
101
|
└── z1_002_v2.9-12.png
|
|
110
102
|
```
|
|
111
103
|
|
|
104
|
+
Piping the output of `find` to `lss`, for example finding all the png sequences:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
$ find ./tests/ -name *.png | xargs lss
|
|
108
|
+
10 012_vb_110_v001.%04d.png [1-10]
|
|
109
|
+
10 012_vb_110_v002.%04d.png [1-10]
|
|
110
|
+
3 fileA.%04d.png [1-3]
|
|
111
|
+
4 z1_001_v1.%d.png [1-4]
|
|
112
|
+
4 z1_002_v1.%d.png [1-4]
|
|
113
|
+
4 z1_002_v2.%d.png [9-12]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Use the `--format` option to retain the relative path:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
$ find tests/ -name "*.png" | xargs lss -f "%D%h%r%t"
|
|
120
|
+
tests/files/012_vb_110_v001.1-10.png
|
|
121
|
+
tests/files/012_vb_110_v002.1-10.png
|
|
122
|
+
tests/files/fileA.1-3.png
|
|
123
|
+
tests/files/z1_001_v1.1-4.png
|
|
124
|
+
tests/files/z1_002_v1.1-4.png
|
|
125
|
+
tests/files/z1_002_v2.9-12.png
|
|
126
|
+
```
|
|
127
|
+
|
|
112
128
|
## API Examples
|
|
113
129
|
|
|
114
130
|
Compression, or serialization, of lists of items:
|
|
@@ -132,6 +148,17 @@ Description: PySeq
|
|
|
132
148
|
1001 012_vb_110_v001.%04d.png [1-1001]
|
|
133
149
|
```
|
|
134
150
|
|
|
151
|
+
Walk a directory tree and print disk usage for file sequences:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
>>> for root, dirs, seqs in pyseq.walk(folder):
|
|
155
|
+
... for seq in seqs:
|
|
156
|
+
... print(seq.format("%h%r%t %H"))
|
|
157
|
+
012_vb_110_v001.1000-1321.exr 123.5G
|
|
158
|
+
012_vb_110_v002.1000-1163.exr 40.2G
|
|
159
|
+
012_vb_110_v003.1000-1027.exr 72.2G
|
|
160
|
+
```
|
|
161
|
+
|
|
135
162
|
## Formatting
|
|
136
163
|
|
|
137
164
|
The following directives can be embedded in the format string.
|
|
@@ -178,6 +205,24 @@ Description: PySeq
|
|
|
178
205
|
7 a.1-14.tga [4-9, 11]
|
|
179
206
|
```
|
|
180
207
|
|
|
208
|
+
## Frame Patterns
|
|
209
|
+
|
|
210
|
+
The environment var `${PYSEQ_FRAME_PATTERN}` can be used to define custom regex
|
|
211
|
+
patterns for identifying frame numbers. For example if frames are always preceded
|
|
212
|
+
with an _, you might use:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
$ export PYSEQ_FRAME_PATTERN="_\d+"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Environment vars can be defined anywhere in your environment, or if using
|
|
219
|
+
[envstack](https://github.com/rsgalloway/envstack) add it to the
|
|
220
|
+
`pyseq.env` file and make sure it's found in `${ENVPATH}`:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
$ export ENVPATH=/path/to/env/files
|
|
224
|
+
```
|
|
225
|
+
|
|
181
226
|
## Testing
|
|
182
227
|
|
|
183
228
|
To run the unit tests, simply run `pytest` in a shell:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
README.md
|
|
2
2
|
setup.py
|
|
3
3
|
lib/pyseq/__init__.py
|
|
4
|
+
lib/pyseq/config.py
|
|
4
5
|
lib/pyseq/lss.py
|
|
5
6
|
lib/pyseq/seq.py
|
|
6
7
|
lib/pyseq/util.py
|
|
@@ -9,5 +10,4 @@ lib/pyseq.egg-info/SOURCES.txt
|
|
|
9
10
|
lib/pyseq.egg-info/dependency_links.txt
|
|
10
11
|
lib/pyseq.egg-info/entry_points.txt
|
|
11
12
|
lib/pyseq.egg-info/not-zip-safe
|
|
12
|
-
lib/pyseq.egg-info/requires.txt
|
|
13
13
|
lib/pyseq.egg-info/top_level.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
envstack>=0.8.3
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|