pysequitur 0.1.2__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.
- pysequitur/__init__.py +31 -0
- pysequitur/examples/examples.py +66 -0
- pysequitur/examples/files/plate.01001.dpx +0 -0
- pysequitur/examples/files/plate.01002.dpx +0 -0
- pysequitur/examples/files/plate.01003.dpx +0 -0
- pysequitur/examples/files/plate.01004.dpx +0 -0
- pysequitur/examples/files/plate.01005.dpx +0 -0
- pysequitur/examples/files/plate.01006.dpx +0 -0
- pysequitur/examples/files/plate.01007.dpx +0 -0
- pysequitur/examples/files/plate.01008.dpx +0 -0
- pysequitur/examples/files/plate.01009.dpx +0 -0
- pysequitur/examples/files/plate.01010.dpx +0 -0
- pysequitur/examples/files/render_001_final.exr +0 -0
- pysequitur/examples/files/render_002_final.exr +0 -0
- pysequitur/examples/files/render_003_final.exr +0 -0
- pysequitur/examples/files/render_004_final.exr +0 -0
- pysequitur/examples/files/render_005_final.exr +0 -0
- pysequitur/examples/files/render_006_final.exr +0 -0
- pysequitur/examples/files/render_007_final.exr +0 -0
- pysequitur/examples/files/render_008_final.exr +0 -0
- pysequitur/examples/files/render_009_final.exr +0 -0
- pysequitur/examples/files/render_010_final.exr +0 -0
- pysequitur/examples/files/shot-0100.exr +0 -0
- pysequitur/examples/files/shot-0101.exr +0 -0
- pysequitur/examples/files/shot-0102.exr +0 -0
- pysequitur/examples/files/shot-0103.exr +0 -0
- pysequitur/examples/files/shot-0104.exr +0 -0
- pysequitur/examples/files/shot-0105.exr +0 -0
- pysequitur/examples/files/shot-0106.exr +0 -0
- pysequitur/examples/files/shot-0107.exr +0 -0
- pysequitur/examples/files/shot-0108.exr +0 -0
- pysequitur/examples/files/shot-0109.exr +0 -0
- pysequitur/examples/files/shot-0110.exr +0 -0
- pysequitur/examples/utils.py +62 -0
- pysequitur/file_sequence.py +1889 -0
- pysequitur/file_sequence_bak.py +1735 -0
- pysequitur/file_sequence_bak_bak.py +1717 -0
- pysequitur/main.py +17 -0
- pysequitur-0.1.2.dist-info/METADATA +136 -0
- pysequitur-0.1.2.dist-info/RECORD +43 -0
- pysequitur-0.1.2.dist-info/WHEEL +4 -0
- pysequitur-0.1.2.dist-info/entry_points.txt +8 -0
- pysequitur-0.1.2.dist-info/licenses/LICENCE +7 -0
pysequitur/__init__.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Copyright (c) 2024 Alex Harding (alexharding.ooo)
|
|
2
|
+
# This file is part of PySequitur which is released under MIT license.
|
|
3
|
+
# See file LICENSE for full license details.
|
|
4
|
+
"""
|
|
5
|
+
PySequitur - A tool for parsing and manipulating file sequences.
|
|
6
|
+
|
|
7
|
+
This package provides tools for working with frame-based file sequences,
|
|
8
|
+
commonly used in VFX and animation pipelines.
|
|
9
|
+
|
|
10
|
+
Classes:
|
|
11
|
+
Item: Represents a single item in a file sequence
|
|
12
|
+
FileSequence: Manages collections of related files as a sequence
|
|
13
|
+
Components: Configuration class for specifying filename components
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from typing import List, Type
|
|
17
|
+
|
|
18
|
+
__version__ = "0.1.0"
|
|
19
|
+
|
|
20
|
+
from .file_sequence import Item, FileSequence, Components # type: ignore
|
|
21
|
+
|
|
22
|
+
# Type definitions for better IDE support
|
|
23
|
+
ItemType = Type[Item]
|
|
24
|
+
FileSequenceType = Type[FileSequence]
|
|
25
|
+
ComponentsType = Type[Components]
|
|
26
|
+
|
|
27
|
+
__all__: List[str] = [
|
|
28
|
+
"Item",
|
|
29
|
+
"FileSequence",
|
|
30
|
+
"Components",
|
|
31
|
+
]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from pysequitur import Components, FileSequence
|
|
2
|
+
from pysequitur.examples.utils import create_some_sequences
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def run_examples():
|
|
7
|
+
|
|
8
|
+
# generate some empty files
|
|
9
|
+
temp_files_directory = create_some_sequences()
|
|
10
|
+
|
|
11
|
+
print("\n\nGenerated these files:\n")
|
|
12
|
+
|
|
13
|
+
for file in sorted(os.listdir(temp_files_directory)):
|
|
14
|
+
print(file)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Parse a directory of files
|
|
18
|
+
|
|
19
|
+
parsed_sequences = FileSequence.from_directory(temp_files_directory)
|
|
20
|
+
|
|
21
|
+
print("\n\nFound sequences:\n")
|
|
22
|
+
for seq in parsed_sequences:
|
|
23
|
+
print(seq)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Parse by components:
|
|
27
|
+
|
|
28
|
+
sequences = FileSequence.from_components_in_directory(Components(prefix="render"), temp_files_directory)
|
|
29
|
+
|
|
30
|
+
print("\n\nParser found one sequence with prefix 'render':\n")
|
|
31
|
+
for seq in sequences:
|
|
32
|
+
print(seq)
|
|
33
|
+
|
|
34
|
+
sequences = FileSequence.from_components_in_directory(Components(extension="exr"), temp_files_directory)
|
|
35
|
+
|
|
36
|
+
print("\n\nParser found two sequence with extension 'exr':\n")
|
|
37
|
+
for seq in sequences:
|
|
38
|
+
print(seq)
|
|
39
|
+
|
|
40
|
+
sequences = FileSequence.from_components_in_directory(Components(prefix="render", extension="exr"), temp_files_directory)
|
|
41
|
+
|
|
42
|
+
print("\n\nParser found one sequence with prefix 'render' and extension 'exr':\n")
|
|
43
|
+
for seq in sequences:
|
|
44
|
+
print(seq)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Parse by filename
|
|
48
|
+
|
|
49
|
+
seq = FileSequence.from_sequence_string_in_directory("render_###_final.exr", temp_files_directory)
|
|
50
|
+
|
|
51
|
+
print("\n\nParsed a single sequence:\n")
|
|
52
|
+
print(seq)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Operations:
|
|
57
|
+
|
|
58
|
+
seq = FileSequence.from_sequence_string_in_directory("render_###_final.exr", temp_files_directory)
|
|
59
|
+
|
|
60
|
+
seq.move_to("/new/directory")
|
|
61
|
+
seq.rename_to("new_name")
|
|
62
|
+
seq.offset_frames(100) # Shift all frame numbers by 100
|
|
63
|
+
new_sequence = seq.copy_to("/new/directory")
|
|
64
|
+
|
|
65
|
+
print("\n\nRenamed sequence:\n")
|
|
66
|
+
print(new_sequence)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from pysequitur import Components, FileSequence
|
|
2
|
+
import os
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
seq1 = Components(
|
|
6
|
+
prefix="render",
|
|
7
|
+
delimiter=".",
|
|
8
|
+
padding=4,
|
|
9
|
+
suffix="exr",
|
|
10
|
+
extension="exr",
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def create_some_sequences():
|
|
15
|
+
|
|
16
|
+
components_1 = Components(
|
|
17
|
+
prefix="render",
|
|
18
|
+
delimiter="_",
|
|
19
|
+
padding=3,
|
|
20
|
+
suffix="_final",
|
|
21
|
+
extension="exr",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
components_2 = Components(
|
|
25
|
+
prefix="plate",
|
|
26
|
+
delimiter=".",
|
|
27
|
+
padding=5,
|
|
28
|
+
extension="dpx",
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
components_3 = Components(
|
|
32
|
+
prefix="shot",
|
|
33
|
+
delimiter="-",
|
|
34
|
+
padding=4,
|
|
35
|
+
extension="exr",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
directory = os.path.dirname(os.path.abspath(__file__)) + "/files"
|
|
39
|
+
|
|
40
|
+
generate_file_sequence(components_1, 1, 10,directory )
|
|
41
|
+
generate_file_sequence(components_2, 1001, 1010, directory)
|
|
42
|
+
generate_file_sequence(components_3, 100, 110, directory)
|
|
43
|
+
|
|
44
|
+
return directory
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def generate_file_sequence(
|
|
48
|
+
components: Components, first_frame: int, last_frame: int, directory
|
|
49
|
+
) -> None:
|
|
50
|
+
|
|
51
|
+
padding = max(len(str(last_frame)), components.padding)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if components.suffix == None:
|
|
56
|
+
components.suffix = ""
|
|
57
|
+
|
|
58
|
+
for frame_number in range(first_frame, last_frame + 1):
|
|
59
|
+
this_frame = f"{components.prefix}{components.delimiter}{str(frame_number).zfill(padding)}{components.suffix}.{components.extension}"
|
|
60
|
+
p = Path(Path(directory) / this_frame)
|
|
61
|
+
p.touch()
|
|
62
|
+
|