As PyCrypto and Paramiko are not ported to Python 3 yet, I’ve put together a library providing basic SFTP functionality for the interim. It wraps the ssh executable (not the command-line sftp client) and speaks the wire protocol over the encrypted channel.
The library currently has support for connecting, listing directories, getting files, putting files, removing files, creating directories, and removing directories. There’s also support for sending raw SFTP packets if necessary.
Everything is at a pretty early state and in rough form; there’s little to no error handling at all, and it’s only been tested against the servers I ordinarily have access to (a few fairly recent versions of OpenSSH). Use at your own risk, and patches welcome. Comments on the interface and API too.
It can be downloaded with either git clone https://gytha.org/py3sftp/ or git clone git://gytha.org/py3sftp.
It’s going to be integrated into another project I’m working on (the one that prompted me to write it, oddly enough), but I plan to keep maintaining it separately at least until Paramiko is available, and perhaps beyond since I like piggybacking on the functionality of OpenSSH itself (VisualHostKey is great).
The Damerau-Levenshtein distance between two strings is the number of additions, deletions, substitutions, and transpositions needed to transform one into the other. It’s an extension of the Levenshtein distance, by incorporating transpositions into the set of operations.
I had a need to use it in a program recently, but I couldn’t find any Python implementation around that wasn’t buggy in trivial cases or just extremely inefficient (strictly, you can implement it neatly by recursion, and it’s quite instructive about the algorithm in some ways, but it takes an age to run when you do and you hit the recursion limit in fairly short order). I’ve put one together myself from the algorithmic definition that I’ve tested to work correctly and reasonably efficiently. I’d suggest working in a C module if you need the best possible efficiency. There are some things in difflib you can work around to doing the same thing as well, particularly good if you do want the required sequence of operations too. I’m only doing the numeric side of things here.
The algorithm is inherently O(N*M) in time, and the naïve version is in space as well. This implementation is O(M) in space, as only the last two rows of the matrix need to be kept around. I have implemented it for Python 2.x, but 2to3 makes an accurate translation if you’re using it with Py3K.
The code is available under the MIT licence, in the hope that it will be useful, but without warranty of any kind. I have also included a codesnippet GUID in line with the linked post, as a sort of experiment. Please leave that comment intact if you’re posting a derivative somewhere, and add your own.