Miserlou / omnihash

Hash files, strings, input streams and network resources in various common algorithms simultaneously
https://github.com/Miserlou/omnihash
MIT License
252 stars 23 forks source link

REVAMP core to FIX #20 reuse of instanciated plugin digesters #21

Open ankostis opened 7 years ago

ankostis commented 7 years ago

HASHING REVAMP

Had to revamp to solve the bug in #20 about reusing instanciated plugin-digesters.

In the previous version, each "digester" was a "convoluted' 2-tuple (digester-instance, final-hash-func). To solve the reuse bug without refactoring it would require to re-initialize the plugins for each input.

In this PR registered digesters are actually factory_functions(fsize: int) that will create a digester class with just 2 methods:

NOTE: the factory-function takes fsize as its argument, - this is useful for git-digesters, to avoid always slurping files with known size; that is also handy for for URL-resources; but as bargain, all other digesters must use a "special" factory just to ignore the fsize arg.

MODULES REVAMP

As explained in #20, enabling plugins in Travis across PY-versions revealed structural module issues. In general it is easier if module-names do not shadow their package-name, and using relative imports is helpfull. So I had to move:

Other changes

(most changes are in commit e15bef5552, impossible to separate, sorry)

TODO:

ankostis commented 7 years ago

After shattered, this utility might become a bit popular.

Would you check this PR?