rsgalloway / pyseq

Compressed sequence string module for Python
https://pyseq.rsgalloway.com/
Other
123 stars 36 forks source link

format error when %s (start) in fmt string #57

Closed herronelou closed 5 years ago

herronelou commented 5 years ago

We ran into an error this morning when trying to format a sequence '%h%s%t' (basically return the first frame of the sequence).

In the formatting, when it does the _old to _new replace, the fmt string gets edited as: %(h)s%s%t then: %(h)(s)%(s)i%t At which point it breaks because the s added in the first replace gets replaced by (s).

I got a fix but got to make unit tests then I'll make a Pull request

rsgalloway commented 5 years ago

Thanks for the report. For the record, is this the traceback you're seeing?

>>> print s.format('%h%s%t')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyseq.py", line 514, in format
    return fmt % atts
ValueError: unsupported format character '(' (0x28) at index 4

And when using %s alone, I'm getting the following,

>>> print s.format('%s')
1

so you'd expect something like this, is that right?

>>> print s.format('%h%s%t')
file.1.jpg
herronelou commented 5 years ago

That is the error I was getting yes

The format with no padding is what I needed yes, thought the final use case is a bit different.

(I had the nuke string with # padding, and needed to double check multiple sequences against that string. Converted it into a regex and compared). Could have gone many other ways, but exposed the bug.

On Wed, Jan 2, 2019, 6:01 PM Ryan Galloway <notifications@github.com wrote:

Thanks for the report. For the record, is this the traceback you're seeing?

print s.format('%h%s%t') Traceback (most recent call last): File "", line 1, in File "pyseq.py", line 514, in format return fmt % atts ValueError: unsupported format character '(' (0x28) at index 4

And when using %s alone, I'm getting the following,

print s.format('%s') 1

so you'd expect something like this, is that right?

print s.format('%h%s%t') file.1.jpg

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rsgalloway/pyseq/issues/57#issuecomment-451012284, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIK9DlC8hMq7EoZtnW7pfCOUWx12A5Fks5u_TpigaJpZM4ZkC-k .

rsgalloway commented 5 years ago

merged into 1.0.0 branch