seqparse 2.0.0rc1__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.
@@ -0,0 +1,335 @@
1
+ Metadata-Version: 2.4
2
+ Name: seqparse
3
+ Version: 2.0.0rc1
4
+ Summary: A nifty way to parse your file sequences.
5
+ Author: Geoff Harvey
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/hoafaloaf/seqparse
8
+ Project-URL: Issues, https://github.com/hoafaloaf/seqparse/issues
9
+ Project-URL: Changelog, https://github.com/hoafaloaf/seqparse/blob/master/CHANGES.md
10
+ Keywords: command-line,file,sequence
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Topic :: Text Processing
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE.txt
25
+ Requires-Dist: humanize
26
+ Provides-Extra: tests
27
+ Requires-Dist: coverage; extra == "tests"
28
+ Requires-Dist: pytest; extra == "tests"
29
+ Dynamic: license-file
30
+
31
+ # seqparse: A nifty way to list your file sequences.
32
+
33
+ [![PyPI version](https://img.shields.io/pypi/v/seqparse)](https://pypi.org/project/seqparse/)
34
+ [![Python versions](https://img.shields.io/pypi/pyversions/seqparse)](https://pypi.org/project/seqparse/)
35
+ [![CI](https://github.com/hoafaloaf/seqparse/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/hoafaloaf/seqparse/actions/workflows/ci.yml)
36
+ [![Coverage](https://img.shields.io/coverallsCoverage/github/hoafaloaf/seqparse?branch=master)](https://coveralls.io/github/hoafaloaf/seqparse?branch=master)
37
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
38
+ [![License](https://img.shields.io/github/license/hoafaloaf/seqparse)](https://github.com/hoafaloaf/seqparse/blob/master/LICENSE.txt)
39
+
40
+ ## Overview
41
+
42
+ The seqparse module may be used to ...
43
+
44
+ - Scan specified paths for file sequences and "singletons,"
45
+ - Construct frame and file sequence from supplied values, and
46
+ - Query disk for overall footprint of tracked files.
47
+
48
+ The module also comes supplied with a simple tool named `seqls` that
49
+ allows the user to scan multiple locations for file sequences and
50
+ singletons from the command line.
51
+
52
+ If you're curious about the **regular expressions** used to determine
53
+ what is and isn't a valid file sequence, take a look at the
54
+ `seqparse.regex` module.
55
+
56
+ ### Requirements
57
+
58
+ - Python 3.11 or later, on Linux, macOS or Windows.
59
+ - [humanize](https://pypi.org/project/humanize/) (installed
60
+ automatically), used by `seqls --long --human-readable`.
61
+
62
+ seqparse is fully type-annotated and ships a `py.typed` marker, so type
63
+ checkers use its hints.
64
+
65
+ Install the current version from GitHub:
66
+
67
+ ```console
68
+ pip install git+https://github.com/hoafaloaf/seqparse
69
+ ```
70
+
71
+ (The release on PyPI, 0.7.3 from 2017, is much older and predates support for
72
+ current Python versions, so a plain `pip install seqparse` is not recommended
73
+ yet.)
74
+
75
+ ### Frame Sequences
76
+
77
+ Frame sequences are broken down into comma-separated chunks of the
78
+ format `first frame`**-**`last frame`**x**`step` where the following
79
+ rules apply:
80
+
81
+ - Frame numbers can be zero-padded,
82
+ - Frame step (increment) is always a positive integer,
83
+ - The number of digits in a frame may exceed the padding of a sequence,
84
+ eg `001,010,100,1000`,
85
+ - Frame chunks with a specified step will **always** consist of three
86
+ or more frames.
87
+
88
+ Examples of proper frame sequences:
89
+
90
+ - Non-padded sequence, frames == **(1, 3, 5, 7)**: `1-7x2`
91
+ - Four-padded sequence, frames == **(1, 3, 5, 7)**: `0001-0007x2`
92
+ - Three-padded sequence, frames == **(11, 13)**: `011,013`
93
+ - Two-padded sequence **(1, 3, 5, 7, 11, 13, 102)**:
94
+ `01-07x2,11,13,102`
95
+
96
+ ### File Sequences
97
+
98
+ Members of a file sequence can be one of two formats:
99
+
100
+ - `base_name`**.**`frame_sequence`**.**`file_extension`
101
+ - `frame_sequence`**.**`file_extension`
102
+
103
+ Examples of valid file sequences:
104
+
105
+ - `my_little_pony.1-7x2.exr`
106
+ - `/maya/is/very/strange/01-07x2,11,13,102.tif`
107
+ - `C:\this\even\works\in\windows\billy.0001-0095.tga`
108
+
109
+ ## seqls
110
+
111
+ `seqls` is the command line interface for the `seqparse` module.
112
+
113
+ ```text
114
+ usage: seqls [-h] [-a] [-H] [-l] [--maxdepth MAX_LEVELS]
115
+ [--mindepth MIN_LEVELS] [-m | --empty] [-S] [--json] [-v]
116
+ [search_path ...]
117
+
118
+ Command line tool for listing file sequences. Upon installation of the package
119
+ this script will be accessible via `seqls` command on the command line of your
120
+ choice.
121
+
122
+ positional arguments:
123
+ search_path Paths that you'd like to search for file sequences.
124
+ Use '-' to read file names (one per line) from
125
+ standard input instead; they are used as written, so
126
+ -a, --maxdepth and --mindepth do not apply to them.
127
+
128
+ options:
129
+ -h, --help show this help message and exit
130
+ -a, --all Do not ignore entries starting with '.'.
131
+ -H, --human-readable with -l/--long, print sizes in human readable format
132
+ (e.g., 1K 234M 2G).
133
+ -l, --long Use a long listing format.
134
+ --maxdepth MAX_LEVELS
135
+ Descend at most MAX_LEVELS (a non-negative integer)
136
+ levels of directories below the starting points; 0
137
+ scans only the starting points themselves.
138
+ --mindepth MIN_LEVELS
139
+ Do not scan at levels less than MIN_LEVELS (a non-
140
+ negative integer); 1 scans every level except the
141
+ starting points.
142
+ -m, --missing Whether to invert output file sequences to only report
143
+ the missing frames.
144
+ --empty Only report the zero-byte frames of each sequence (the
145
+ likely debris of a crashed render), as a frame
146
+ sequence.
147
+ -S, --seqs-only Whether to filter out all non-sequence files.
148
+ --json Print JSON instead of text: sizes (bytes) and
149
+ modification times (epoch seconds) are included with
150
+ -l/--long, and with -m/--missing only sequences that
151
+ have gaps are listed.
152
+ -v, --version Print the version and exit.
153
+ ```
154
+
155
+ Most of the functionality is self-explanatory, but the `-m/--missing`
156
+ option is probably the most useful to users generating large sequences
157
+ of frames on multiple servers.
158
+
159
+ Say you're creating imagery for the latest superhero movie -- and your
160
+ render job crashed some time in the early morning.
161
+
162
+ You're expecting to see something like this ...
163
+
164
+ ```text
165
+ superhero_cape_v0001.0001-1000.exr
166
+ ```
167
+
168
+ ... but not everything rendered.
169
+
170
+ ```console
171
+ $ cd /renders/superhero_cape_v0001
172
+ $ seqls
173
+ superhero_cape_v0001.0001-0500,0600-0800,0990-1000x5.exr
174
+ ```
175
+
176
+ You can easily figure out the missing frames, though, with the
177
+ `--missing` option:
178
+
179
+ ```console
180
+ $ seqls --missing
181
+ superhero_cape_v0001.0501-0599,0801,0991-0994,0996-0999.exr
182
+ ```
183
+
184
+ Crashed renders also tend to leave zero-byte frames behind. `--empty` lists
185
+ just those, in the same notation (`-l` adds their sizes and dates; it can't be
186
+ combined with `-m`):
187
+
188
+ ```console
189
+ $ seqls --empty
190
+ superhero_cape_v0001.0501-0510.exr
191
+ ```
192
+
193
+ ### JSON output
194
+
195
+ For scripts and pipelines, `--json` prints one JSON array instead of text,
196
+ and nothing else (no blank line before it):
197
+
198
+ ```console
199
+ $ seqls --json -l -S
200
+ [
201
+ {
202
+ "type": "sequence",
203
+ "path": "/renders/superhero_cape_v0001",
204
+ "name": "superhero_cape_v0001",
205
+ "ext": "exr",
206
+ "pad": 4,
207
+ "frames": "0001,0002,0004",
208
+ "count": 3,
209
+ "first": 1,
210
+ "last": 4,
211
+ "missing": "0003",
212
+ "empty": "",
213
+ "size": 3000,
214
+ "mtime": 1763798400.0,
215
+ "string": "/renders/superhero_cape_v0001/superhero_cape_v0001.0001,0002,0004.exr"
216
+ }
217
+ ]
218
+ ```
219
+
220
+ Each entry is either a sequence or a singleton file:
221
+
222
+ | Field | Meaning |
223
+ | --- | --- |
224
+ | `type` | `"sequence"` or `"file"` |
225
+ | `path`, `name` | The directory (`null` for a name without one), and the sequence's base name or the file's name |
226
+ | `string` | What the text output prints for the item |
227
+ | `ext`, `pad` | Sequences only: extension and zero-padding |
228
+ | `frames` | Sequences only: the frame sequence, e.g. `"0001-0500,0600-0800"` |
229
+ | `count`, `first`, `last` | Sequences only: number of frames, first and last frame |
230
+ | `missing` | Sequences only: the missing frames in the same notation (`""` if none) |
231
+ | `empty` | Sequences only: the zero-byte frames in the same notation (`""` if none); `null` unless `-l` or `--empty` is given |
232
+ | `size`, `mtime` | Size in bytes and modification time in seconds since the epoch; `null` unless `-l` is given |
233
+
234
+ The other options work as usual (`-S`, `--maxdepth`, ...). With `-m/--missing`,
235
+ only sequences that have gaps are listed, still described by their real
236
+ `frames`, and likewise `--empty` for sequences with zero-byte frames; `-H` has no
237
+ effect.
238
+
239
+ ### Reading names from stdin
240
+
241
+ `seqls -` groups file names read from standard input (one per line) instead
242
+ of scanning disk, so it also works on listings of files that aren't on a local
243
+ disk:
244
+
245
+ ```console
246
+ $ find /renders/superhero_cape_v0001 -name '*.exr' | seqls -
247
+ /renders/superhero_cape_v0001/superhero_cape_v0001.0001-1000.exr
248
+ ```
249
+
250
+ Names are used as written and grouped by directory exactly as spelled
251
+ (`./a/f.1.exr` and `a/f.2.exr` are different directories). `-` can be combined
252
+ with real paths. `-m`, `-S` and `--json` work as usual, with `null` sizes;
253
+ `-a`, `--maxdepth` and `--mindepth` only apply to scanned paths, and `-l` and
254
+ `--empty` need files on disk, so they are rejected together with `-`.
255
+
256
+ ## The module
257
+
258
+ Using the module is fairly simple:
259
+
260
+ 1. Instantiate a parser (`Seqparse` instance).
261
+ 2. Add files to the parser either
262
+ - via the `add_file` method, or
263
+ - by scanning a list of locations on disk via the `scan_path`
264
+ method.
265
+ 3. Create an **iterator** for all file sequences (`FileSequence`
266
+ instances) and singletons (`File` instances).
267
+ 4. ...
268
+ 5. Profit.
269
+
270
+ Example (taken from the `Seqparse` docstring), with the following file
271
+ structure ...
272
+
273
+ ```text
274
+ test_dir/
275
+ TEST_DIR.0001.tif
276
+ TEST_DIR.0002.tif
277
+ TEST_DIR.0003.tif
278
+ TEST_DIR.0004.tif
279
+ TEST_DIR.0010.tif
280
+ SINGLETON.jpg
281
+ ```
282
+
283
+ ```pycon
284
+ >>> from seqparse import seqparse
285
+ >>> parser = seqparse.Seqparse()
286
+ >>> parser.scan_path("test_dir")
287
+ >>> for item in parser.output():
288
+ ... print(str(item))
289
+ ...
290
+ test_dir/TEST_DIR.0001-0004,0010.tif
291
+ test_dir/SINGLETON.jpg
292
+ >>> for item in parser.output(seqs_only=True):
293
+ ... print(str(item))
294
+ ...
295
+ test_dir/TEST_DIR.0001-0004,0010.tif
296
+ >>> for item in parser.output(missing=True):
297
+ ... print(str(item))
298
+ ...
299
+ test_dir/TEST_DIR.0005-0009.tif
300
+ ```
301
+
302
+ ### Useful Classes
303
+
304
+ `FrameSequence` instances are pretty useful on their own.
305
+
306
+ ```pycon
307
+ >>> import seqparse
308
+ >>> seq = seqparse.get_sequence([1, 2, 3, 4, 8], pad=4)
309
+ >>> print(repr(seq))
310
+ FrameSequence(pad=4, frames=set([1, 2, 3, 4, 8]))
311
+ >>> print(seq)
312
+ 0001-0004,0008
313
+ >>> for frame in seq:
314
+ ... print(frame)
315
+ ...
316
+ 0001
317
+ 0002
318
+ 0003
319
+ 0004
320
+ 0008
321
+ >>> for frame in seq.invert():
322
+ ... print(frame)
323
+ ...
324
+ 0005
325
+ 0006
326
+ 0007
327
+ ```
328
+
329
+ As are `FileSequence` instances (which behave similarly; check class
330
+ documentation for details).
331
+
332
+ ## Feedback
333
+
334
+ Lemme know if you have any requests/complaints/suggestions: open an issue at
335
+ <https://github.com/hoafaloaf/seqparse/issues>.
@@ -0,0 +1,15 @@
1
+ seqparse/__init__.py,sha256=u8F-s_zRS98-3NDhRmbfwKa8ZDJzrs3YV3S-3F1Gqww,6115
2
+ seqparse/containers.py,sha256=_tyJbNCPPGqimnczMVd-9fvQTttdQxff6fvY2piLhPE,15463
3
+ seqparse/files.py,sha256=dO69AmwB-FKID1QMZk87KHh74OZar0Abc-KELh7_Ils,4953
4
+ seqparse/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ seqparse/regex.py,sha256=m55qT1hpLAHpQRyjvwFPVbgYtXhHvGHLeyAdILkJYeg,6078
6
+ seqparse/seqparse.py,sha256=y6uEjqueHuFC3E3YYkSaE2omLGhvEICyG-7cEuFHSs0,17630
7
+ seqparse/sequences.py,sha256=0uKAgjmhsI1q2-j42bbLSCyrKBtRlpR9f62x9tMpnc4,43754
8
+ seqparse/cli/__init__.py,sha256=mUDxvN8MWxftIp80siWd3PuNQlfyXJFCdo44lII-GyU,60
9
+ seqparse/cli/seqls.py,sha256=6urMtOcbVesIpCs12WTTScmpfhsPs-_wGXyJFrdRtsc,10657
10
+ seqparse-2.0.0rc1.dist-info/licenses/LICENSE.txt,sha256=-dd9UqMLIqtYYnC8R329ArAvLslabbMHBr6v4ZS5gaU,1074
11
+ seqparse-2.0.0rc1.dist-info/METADATA,sha256=99ukTluCHnzFoNPB4J9178julLu5TWhbAd1SrNbodvM,11506
12
+ seqparse-2.0.0rc1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
13
+ seqparse-2.0.0rc1.dist-info/entry_points.txt,sha256=4WfAMcEuvZCuqIkb3dw89_OPdn73sXrRTSsZJy3Fayc,54
14
+ seqparse-2.0.0rc1.dist-info/top_level.txt,sha256=N5ep0KhAk8u2o8uz4cGbfS_dXOHKgar1LEFT7cpo7Dk,9
15
+ seqparse-2.0.0rc1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ seqls = seqparse.cli.seqls:run_main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-2022 Geoff Harvey
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ seqparse