Skip to content

Commit b1be1bb

Browse files
committed
Rename the prefix and postfix
"Prefix" can be used to refer to the portion of the file name before the first `.`, which conflicted with our definition of prefix.
1 parent f870c50 commit b1be1bb

13 files changed

Lines changed: 269 additions & 286 deletions

doc/source/decisions/001-path-sequence-format.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ by various VFX software.
2323
- Ranges can start name
2424
- Ranges can be in name
2525
- Ranges can end name
26-
- Prefix required
26+
- Pre-range required
2727
- Notes
2828
* - Blender
2929
- 1
@@ -150,7 +150,7 @@ Blender does not document any use of sequence strings as input.
150150
* - Ranges ends name
151151
- ``file.ext##``
152152
- ``file.ext##.ext``
153-
* - Prefix required
153+
* - Pre-range required
154154
- ``file##.ext``
155155
- ``file##.ext``
156156

doc/source/format.rst

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,30 @@ represents the name of not one file but of all the files in the sequence.
3737
The name has four components:
3838

3939
* The stem
40-
* An optional prefix
40+
* An optional pre-range separator
4141
* The ranges
4242
* The suffixes
4343

4444
.. code-block:: text
4545
4646
/directory/ file . 1001-1010# .tar.gz
47-
┌┴────┼─┼──────────┼───────┴┐
48-
│ ┌┘ └───┐ │ │
49-
│stem│prefix│ranges│suffixes│
50-
├────┴──────┴──────┴────────┤
51-
name │
52-
───────────────────────────┘
47+
┌────┴───┼─┼──────────┼───────┴┐
48+
│ ┌───┘ └───┐ │ │
49+
│stem│pre-range│ranges│suffixes│
50+
├────┴─────────┴──────┴────────┤
51+
name
52+
└──────────────────────────────┘
5353
5454
Supporting multiple ranges in a sequence requires an additional component:
5555
an inter-range separator.
5656

5757
.. code-block:: text
5858
5959
/directory/ file . 1001-1002<UDIM> _ 1001-1010# .tar.gz
60-
────┴────┼─┼───────────────┼─┼──────────┼───────┴┐
61-
│ ┌────┘ │ ┌────┘ └────┐ │ │
62-
│stem│prefix│ range │inter-range│range│suffixes│
63-
└────┴──────┼──────────┴───────────┴─────┼────────┘
60+
┌───────┴────┼─┼───────────────┼─┼──────────┼───────┴┐
61+
│ ┌───────┘ | ┌────┘ └────┐ │ │
62+
│stem│pre-range│ range │inter-range│range│suffixes│
63+
└────┴─────────┼──────────┴───────────┴─────┼────────┘
6464
│ ranges │
6565
└────────────────────────────┘
6666
@@ -70,7 +70,7 @@ an inter-range separator.
7070
Stem
7171
----
7272

73-
The stem is the name of a path sequence, without the prefix, ranges, and suffixes.
73+
The stem is the name of a path sequence, without the pre-range separator, ranges, and suffixes.
7474
A non-empty stem MUST be present in the name of a path sequence.
7575

7676
The stem MUST NOT contain a valid :ref:`range string <spec-simple-range>`,
@@ -83,29 +83,29 @@ For example, in ``file-1.1-5#.tar.gz`` it is unclear whether the stem and range
8383

8484
.. note::
8585

86-
Although this ambiguity is removed when a prefix separator of "``_``" is included,
86+
Although this ambiguity is removed when a pre-range separator of "``_``" is included,
8787
ending the stem with a digit is still forbidden
8888
to prevent complexity in an API that implements this format.
8989
For example, if it were possible to rename a path sequence by
90-
removing or changing the prefix, doing that may not be possible unless
90+
removing or changing the pre-range separator, doing that may not be possible unless
9191
the stem is changed first.
9292

9393

94-
.. _spec-simple-prefix:
94+
.. _spec-simple-prerange:
9595

96-
Prefix
97-
------
96+
Pre-range Separator
97+
-------------------
9898

99-
The prefix is a single character that separates the :ref:`stem <spec-simple-stem>`
99+
The pre-range separator is a single character that separates the :ref:`stem <spec-simple-stem>`
100100
from the :ref:`ranges <spec-simple-range>`.
101101

102-
The name of a path sequence MAY contain a single prefix character.
102+
The name of a path sequence MAY contain a single pre-range separator character.
103103

104-
The prefix character MUST be one of "``.``" or "``_``".
104+
The pre-range separator MUST be one of "``.``" or "``_``".
105105

106106
.. tip::
107107

108-
Including a prefix as "``.``" is RECOMMENDED for best compatibility with VFX software.
108+
Including a pre-range separator as "``.``" is RECOMMENDED for best compatibility with VFX software.
109109

110110
.. code-block:: text
111111
@@ -469,17 +469,17 @@ sequence string being parsed is in the simple format.
469469

470470
In `Simple Path Sequences`_ we saw that in the simple format,
471471
a sequence's name has five components:
472-
the stem, an optional prefix, the ranges, inter-range strings, and the suffixes.
473-
The loose format has an additional component — the OPTIONAL postfix
472+
the stem, an optional pre-range separator, the ranges, inter-range strings, and the suffixes.
473+
The loose format has an additional component — the OPTIONAL post-range separator
474474
to support additional characters after the ranges but before the next component.
475475

476476
.. code-block:: text
477477
478478
/directory/ file . 1001-1002<UDIM> _ 1001-1010# _final .tar.gz
479-
┌────┴────┼─┼───────────────┼─┼──────────┼──────┼───────┴─┐
480-
│ ┌────┘ │ ┌────┘ └────┐ │ └┐ │
481-
│stem│prefix│ range │inter-range│range│postfix│suffixes│
482-
└────┴──────┼──────────┴───────────┴─────┼───────┴────────┘
479+
┌───────┴────┼─┼───────────────┼─┼──────────┼──────┼───────┴────┐
480+
│ ┌───────┘ │ ┌────┘ └────┐ │ └───┐ │
481+
│stem│pre-range│ range │inter-range│range│post-range│suffixes│
482+
└────┴─────────┼──────────┴───────────┴─────┼──────────┴────────┘
483483
│ ranges │
484484
└────────────────────────────┘
485485
@@ -492,10 +492,10 @@ The ranges can be at the start of the name:
492492
.. code-block:: text
493493
494494
/directory/ 1001-1002<UDIM> _ 1001-1010# _ filename .tar.gz
495-
├───────────────┼─┼──────────┼─┼────────┼───────┴──┐
496-
│ ┌────┘ └────┐ │ └─────┐ └─┐ │
497-
│ range │inter-range│range│postfix│stem│suffixes│
498-
├──────────┴───────────┴─────┼───────┴────┴────────┘
495+
├───────────────┼─┼──────────┼─┼────────┼───────┴────
496+
│ ┌────┘ └────┐ │ └───────┐└───┐ │
497+
│ range │inter-range│range│postrange│stem│suffixes│
498+
├──────────┴───────────┴─────┼─────────┴────┴────────┘
499499
│ ranges │
500500
└────────────────────────────┘
501501
@@ -504,10 +504,10 @@ The ranges can be inside the name:
504504
.. code-block:: text
505505
506506
/directory/ file . 1001-1002<UDIM> _ 1001-1010# _final .tar.gz
507-
┌────┴────┼─┼───────────────┼─┼──────────┼──────┼───────┴─┐
508-
│ ┌────┘ │ ┌────┘ └────┐ │ └┐ │
509-
│stem│prefix│ range │inter-range│range│postfix│suffixes│
510-
└────┴──────┼──────────┴───────────┴─────┼───────┴────────┘
507+
┌───────┴────┼─┼───────────────┼─┼──────────┼──────┼───────┴────┐
508+
│ ┌───────┘ │ ┌────┘ └────┐ │ └───┐ │
509+
│stem│pre-range│ range │inter-range│range│post-range│suffixes│
510+
└────┴─────────┼──────────┴───────────┴─────┼──────────┴────────┘
511511
│ ranges │
512512
└────────────────────────────┘
513513
@@ -516,10 +516,10 @@ Finally, the ranges can be at the end of the name:
516516
.. code-block:: text
517517
518518
/directory/ file .tar.gz . 1001-1002<UDIM> _ 1001-1010#
519-
─────┴────┼───────┼─┼───────────────┼─┼──────────┤
520-
│ ┌─────┘ ┌────┘ │ ┌────┘ └────┐ │
521-
│stem│suffixes│prefix│ range │inter-range│range│
522-
└────┴──────────────┼──────────┴───────────┴─────┤
519+
┌────────┴────┼───────┼─┼───────────────┼─┼──────────┤
520+
│ ┌────────┘┌──────┘ │ ┌────┘ └────┐ │
521+
│stem│suffixes │prerange│ range │inter-range│range│
522+
└────┴─────────┴────────┼──────────┴───────────┴─────┤
523523
│ ranges │
524524
└────────────────────────────┘
525525
@@ -528,8 +528,7 @@ Finally, the ranges can be at the end of the name:
528528
Because the stem or suffix are allowed to be empty, the loose format is ambiguous.
529529
For example, ``#.tar.gz`` could be represented as a sequence where
530530
the range starts the string and has a blank stem,
531-
or the range starts the string and has a stem of "tar" and prefix of ".",
532-
or the range is in the string and has a blank stem and prefix.
531+
or the range is in the string and has a blank stem.
533532

534533
Implementations of PathSeq do not need to provide consistent behaviour when
535534
parsing ambiguous loose format strings.
@@ -540,7 +539,8 @@ Finally, the ranges can be at the end of the name:
540539
Stem
541540
----
542541

543-
The stem is the name of a path sequence, without the prefix, ranges, postfix, and suffixes.
542+
The stem is the name of a path sequence, without the pre-range separator, ranges,
543+
post-range separator, and suffixes.
544544
A non-empty stem MAY be present in the name of a path sequence.
545545

546546
The stem MUST NOT contain a valid :ref:`range string <spec-simple-range>`,
@@ -568,18 +568,18 @@ a file in the sequence.
568568
.tar.gz1-5#
569569
570570
571-
.. _spec-loose-prefix:
571+
.. _spec-loose-prerange:
572572

573-
Prefix
574-
------
573+
Pre-range Separator
574+
-------------------
575575

576-
Path sequences where the name starts with a range MUST NOT contain a prefix.
576+
Path sequences where the name starts with a range MUST NOT contain a pre-range separator.
577577
Path sequences where the ranges exist inside or at the end of the name
578-
MAY contain a single prefix character.
578+
MAY contain a pre-range separator.
579579

580-
The prefix separates the ranges from the previous component in the name.
580+
The pre-range separator separates the ranges from the previous component in the name.
581581

582-
The prefix character MUST be one of "``.``" or "``_``".
582+
If a pre-range separator is present, it MUST be one of "``.``" or "``_``".
583583

584584

585585
.. _spec-loose-range:
@@ -613,34 +613,34 @@ but this is NOT RECOMMENDED either because it creates abiguity when parsing
613613
a file in the sequence.
614614

615615

616-
.. _spec-loose-postfix:
616+
.. _spec-loose-postrange:
617617

618-
Postfix
619-
-------
618+
Post-range Separator
619+
--------------------
620620

621-
The postfix string separates the :ref:`ranges <spec-loose-range>`
621+
The post-range separator separates the :ref:`ranges <spec-loose-range>`
622622
from the next component of the sequence's name.
623623

624-
The rules that define what is a valid postfix, depend on the type of path sequence.
624+
The rules that define what is a valid post-range separator, depend on the type of path sequence.
625625

626626
In path sequences where the ranges start the name:
627627

628-
* The sequence MAY contain a postfix.
629-
* If present, the postfix MUST be a "``_``", or it would be part of the stem.
628+
* The sequence MAY contain a post-range separator.
629+
* If present, the post-range separator MUST be a "``_``", or it would be part of the stem.
630630
If it contained a "``.``" then by definition it would be part of the suffixes.
631631

632632
In path sequences where the ranges exist inside of the name:
633633

634-
* The sequence MAY contain a postfix.
635-
* The postfix can be of any length.
636-
* The postfix MUST NOT contain a "``.``", or by definition it would be part of the suffixes.
637-
* The postfix MAY start with digits,
634+
* The sequence MAY contain a post-range separator.
635+
* The post-range separator can be of any length.
636+
* The post-range separator MUST NOT contain a "``.``", or by definition it would be part of the suffixes.
637+
* The post-range separator MAY start with digits,
638638
but this is NOT RECOMMENDED because it makes it difficult to tell
639639
where the range starts and ends from a file path in the sequence.
640640

641641
In path sequences where the name ends with a range:
642642

643-
* A postfix CANNOT be present, otherwise the ranges would exist inside of the name.
643+
* A post-range separator CANNOT be present, otherwise the ranges would exist inside of the name.
644644

645645

646646
.. _spec-loose-suffixes:

doc/source/user/convert.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ So any part of a path sequence can be changed.
4343
>>> class DemoFormatter(Formatter):
4444
... def stem(self, stem):
4545
... return "stem"
46-
... def prefix(self, prefix):
47-
... return "|prefix"
46+
... def pre_range(self, pre_range):
47+
... return "|pre_range"
4848
... def range(self, range_):
4949
... return "|range"
5050
... def inter_range(self, inter_range):
5151
... return "|inter_range"
52-
... def postfix(self, postfix):
53-
... return "|postfix"
52+
... def post_range(self, post_range):
53+
... return "|post_range"
5454
... def suffixes(self, suffixes):
5555
... return "|suffixes"
5656
...
5757
>>> seq = PathSequence("image.1-5#.exr")
5858
>>> DemoFormatter().format(seq.parsed)
59-
'stem|prefix|range|suffixes'
59+
'stem|pre_range|range|suffixes'
6060
6161
The order of the parts in a :ref:`loose <loose-format>` can even be changed
6262
by overriding the :meth:`~pathseq.Formatter.format` or
@@ -70,7 +70,7 @@ a :ref:`simple <simple-format>` might look like this:
7070
... def format(self, seq):
7171
... return (
7272
... self.stem(seq.stem)
73-
... + self.prefix(seq.prefix or ".")
73+
... + self.pre_range(seq.pre_range or ".")
7474
... + self.ranges(seq.ranges)
7575
... + self.suffixes(seq.suffixes)
7676
... )

0 commit comments

Comments
 (0)