Repository: justinfx/fileseq (language: python)

Issue:
Fails to parse multi-component extensions like ".a.ext"
There is a bug in the regular expression when dealing with multi-component file extension patterns, when one of the components contains only a single characters:

```
file.1.a.ext
```

In this case, the base vs frame vs ext is not captured correctly, leading to breakages in  calls to `findSequenceOnDisk()`


Discussion / hints:
Relates to https://github.com/justinfx/gofileseq/issues/26

Fix patch:
diff --git a/src/fileseq/constants.py b/src/fileseq/constants.py
index 82d68af..e721358 100644
--- a/src/fileseq/constants.py
+++ b/src/fileseq/constants.py
@@ -155,12 +155,12 @@ def __eq__(self, other):
 # Regular expression pattern for matching file names on disk.
 DISK_PATTERN = r"""
     \A
-    ((?:.*[/\\])?)            # dirname
-    (.*?)                     # basename
-    (-?\d+)?                  # frame
-    (                         # ext
-        (?:\.\w*[a-zA-Z]\w)*  #   optional leading alnum ext prefix (.foo.1bar)
-        (?:\.[^.]+)?          #   ext suffix
+    ((?:.*[/\\])?)             # dirname
+    (.*?)                      # basename
+    (-?\d+)?                   # frame
+    (                          # ext
+        (?:\.\w*[a-zA-Z]\w?)*  #   optional leading alnum ext prefix (.foo.1bar)
+        (?:\.[^.]+)?           #   ext suffix
     )
     \Z
     """
@@ -169,12 +169,12 @@ def __eq__(self, other):
 # Regular expression pattern for matching file names on disk allowing subframes.
 DISK_SUB_PATTERN = r"""
     \A
-    ((?:.*[/\\])?)            # dirname
-    (.*?)                     # basename
-    (-?\d+(?:\.\d+)?)?        # frame
-    (                         # ext
-        (?:\.\w*[a-zA-Z]\w)*  #   optional leading alnum ext prefix (.foo.1bar)
-        (?:\.[^.]+)?          #   ext suffix
+    ((?:.*[/\\])?)             # dirname
+    (.*?)                      # basename
+    (-?\d+(?:\.\d+)?)?         # frame
+    (                          # ext
+        (?:\.\w*[a-zA-Z]\w?)*  #   optional leading alnum ext prefix (.foo.1bar)
+        (?:\.[^.]+)?           #   ext suffix
     )
     \Z
     """


Test patch:
diff --git a/test/complex_ext/1.a.jpg b/test/complex_ext/1.a.jpg
new file mode 100644
index 0000000..e69de29
diff --git a/test/complex_ext/2.a.jpg b/test/complex_ext/2.a.jpg
new file mode 100644
index 0000000..e69de29
diff --git a/test/complex_ext/3.a.jpg b/test/complex_ext/3.a.jpg
new file mode 100644
index 0000000..e69de29
diff --git a/test/complex_ext/file.5.a.ext b/test/complex_ext/file.5.a.ext
new file mode 100644
index 0000000..e69de29
diff --git a/test/complex_ext/file.6.a.ext b/test/complex_ext/file.6.a.ext
new file mode 100644
index 0000000..e69de29
diff --git a/test/complex_ext/file.7.a.ext b/test/complex_ext/file.7.a.ext
new file mode 100644
index 0000000..e69de29
diff --git a/test/test_unit.py b/test/test_unit.py
index ba5b996..a010ad7 100755
--- a/test/test_unit.py
+++ b/test/test_unit.py
@@ -1645,6 +1645,8 @@ def testFindSequenceOnDisk(self):
             ("subframe_seq/baz.#.0000.exr", "subframe_seq/baz.1-4#.0000.exr"),
             ("subframe_seq/baz.0001.#.exr", "subframe_seq/baz.0001.0-7500x2500#.exr"),
             ("subframe_seq/baz.0001.0000.exr", "subframe_seq/baz.0001.0-7500x2500#.exr"),
+            ("complex_ext/@.a.jpg", "complex_ext/1-3@.a.jpg"),
+            ("complex_ext/file.@.a.ext", "complex_ext/file.5-7@.a.ext"),
         ]
 
         for pattern, expected in tests:
@@ -1703,6 +1705,8 @@ def testStrictPadding(self):
             ("seq/big.#@.ext", None),
             ("multi_range/file_@@.0001.exr", None),
             ("multi_range/file_#.0001.exr", "multi_range/file_3-5#.0001.exr"),
+            ("complex_ext/#.a.jpg", None),
+            ("complex_ext/@.a.jpg", "complex_ext/1-3@.a.jpg"),
         ]
 
         for pattern, expected in tests: