many changes: formats, modes, dtype, sf_open_fd(), ...#31
Conversation
|
(I'll put these comments in the pull request and not in the commit, so as to avoid losing them when the PR changes) I have a few comments:
Only the last two points are immediately actionable. The rest of the PR looks great! If you get this ready today, I'll start writing tests tomorrow. During all this refactoring action, a test suite is becoming more and more valuable. |
This commit holds several changes which were discussed in #22 (which was itself based on #18). Change handling of file formats: File formats are handled as three simple strings: format, subtype and endian. Add "which" argument to seek(). This is needed because the combination with logical or (e.g. SEEK_SET | READ) isn't possible with string formats. Update frames counter on write(). Hide all non-API names in module namespace (by prefixing _). This is relevant for tools that do introspection, e.g. for auto-completion in IDEs. Support sf_open_fd(), remove obsolete argument virtual_io The first constructor argument can now be: - a string (path to a file) - an int (a file descriptor) - a file-like object The argument virtual_io is not needed, because this can be detected automatically. Closes #19 Get file extension from 'name' attribute of a file-like object. Change public attributes of SoundFile class to properties. Add 'name' property. Add properties 'format_info' and 'subtype_info'. Proper handling of dtype's in read() and write(). Add function default_subtype().
I don't want to put newlines into the error string, a multi-line string would do that. But if I use the string literal directly as argument (without defining a variable), I can at least get rid of the line continuations. Is that better?
I don't have a strong opinion about that, I just used what was used in the rest of the code. I want to point out, however, that the automatic numbering of format arguments is not supported in Python 2.6 (e.g. Anyway, I have a few more commits in the pipeline, I would prefer if we change that at a later time.
Sure, why not.
Yeah, I don't think that's a real problem. And defining the functions with
Nice catch.
Good question, the reason is in one of my next commits.
Probably.
Can If yes I'm wondering why we're not using them with the file formats and the other stuff as well. Anyway, it would be nice if we could change that at a later time after my next few commits. |
|
Alright, let's postpone everything save the ffi typo. None of this is critical in any way. On 20. April 2014 20:38:40 MESZ, Matthias Geier notifications@github.com wrote:
Diese Nachricht wurde von meinem Mobiltelefon mit Kaiten Mail gesendet. |
Anyway, I see that the ffi-bug is fixed, so just merge when you are ready! |
I personally don't need 2.6 compatibility (I don't even need 2.7). But I think if CFFI supports it (which it does) and if it's not too much additional work for us, we should keep it anyway. I didn't try PySoundFile on Python 2.6 because I had some problems with setuptools, so I don't even know if there's something else that breaks compatibility. Did you try it?
Is it really formally deprecated? I agree that the new |
|
I'll implement a test suite later today. Then, we'll have a better idea about what works and what doesn't. As for string formatting, you are correct. It is not deprecated. However, the docs claim that percent-formatting is error-prone:
Also, a useful discussion on SO: http://stackoverflow.com/questions/5082452/python-string-formatting-vs-format |
Great, I'm looking forward to that! About "some text %s some text" % repr(some_variable)I think this very specific usage is perfectly safe and not error-prone. The only still unsafe spot is in Again, I do think |
This adds single quotes to strings and it avoids an error with string formatting if "name" happens to be a tuple. See also #31.
This adds single quotes to strings and it avoids an error with string formatting if "name" happens to be a tuple. See also #31.
__repr__ now returns a nice description of the SoundFile closes #76
This adds single quotes to strings and it avoids an error with string formatting if "name" happens to be a tuple. See also #31.
This commit holds several changes which were discussed in #22 (which was
itself based on #18).
Change handling of file formats:
File formats are handled as three simple strings: format, subtype and endian.
Add "which" argument to seek().
This is needed because the combination with logical or (e.g. SEEK_SET | READ)
isn't possible with string formats.
Update frames counter on write().
Hide all non-API names in module namespace (by prefixing _).
This is relevant for tools that do introspection, e.g. for
auto-completion in IDEs.
Support sf_open_fd(), remove obsolete argument virtual_io
The first constructor argument can now be:
The argument virtual_io is not needed, because this can be detected
automatically.
Closes Implement sf_open_fd? #19
Get file extension from 'name' attribute of a file-like object.
Change public attributes of SoundFile class to properties.
Add 'name' property.
Add properties 'format_info' and 'subtype_info'.
Proper handling of dtype's in read() and write().
Add function default_subtype().