Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for negative frame ranges #25

Open
BigRoy opened this issue Jul 22, 2016 · 2 comments
Open

Add support for negative frame ranges #25

BigRoy opened this issue Jul 22, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@BigRoy
Copy link

BigRoy commented Jul 22, 2016

Problem

When pyseq encounters a frame range that is negative it doesn't parse it correctly.

For example I have an application that saves out to the following format:

file.-002.jpg
file.-001.jpg
file.0000.jpg
file.0001.jpg
file.0003.jpg

Testing that it parses:

data = ["file.-002.jpg", "file.-001.jpg", "file.0000.jpg", "file.0001.jpg", "file.0003.jpg"]
print pyseq.get_sequences(data)
# [<pyseq.Sequence "file.-1-2.jpg">, <pyseq.Sequence "file.0-3.jpg">]

Solution

Parse digits including the - (minus) sign to ensure it is parsed as it should.
I quickly tested to change:

digits_re = re.compile(r'\d+')

To:

digits_re = re.compile(r'-?\d+')

And it parsed the above file sequence correctly as a single sequence. YAY! (Dirty fix?)

Though to have this as a fully reliable implementation I'm imagining some changes need to be made to uncompress and alike to be perfect. Similarly tests should be implemented to also ensure the functionality remains reliable over time.

@rsgalloway rsgalloway added the bug label Jul 28, 2016
@rsgalloway rsgalloway self-assigned this Jul 28, 2016
@rsgalloway
Copy link
Owner

Hi Roy, thanks for using pyseq and for reporting this issue.

I'll need to do a bit more testing and write some new unit tests, but I tried your solution and I think it should be fine. There are unit tests in test/test_pyseq.py, and they all pass with this change, including uncompress.

BigRoy added a commit to BigRoy/pyseq that referenced this issue Aug 28, 2016
@rsgalloway rsgalloway added this to the 0.5.1 milestone Nov 16, 2017
@rsgalloway
Copy link
Owner

Looks like a little more work will be required here,

>>> s = pyseq.get_sequences(data)[0]
>>> s
<pyseq.Sequence "file.-2-3.jpg">
>>> for i in s: print i
... 
file.-001.jpg
file.-002.jpg
file.0000.jpg
file.0001.jpg
file.0003.jpg

The issue seems to be the sort here, so a fancier sorting function will be required:

https://github.com/rsgalloway/pyseq/blob/master/pyseq.py#L1045

>>> s = pyseq.Sequence(data)
>>> s[0]
<pyseq.Item "file.-002.jpg">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants