Return hexdigest of hashvalue for this file.
(self, hashtype="md5", chunksize=524288)
| 616 | error.checked_call(os.remove, self.strpath) |
| 617 | |
| 618 | def computehash(self, hashtype=class="st">"md5", chunksize=524288): |
| 619 | class="st">""class="st">"Return hexdigest of hashvalue for this file."class="st">"" |
| 620 | try: |
| 621 | try: |
| 622 | import hashlib as mod |
| 623 | except ImportError: |
| 624 | if hashtype == class="st">"sha1": |
| 625 | hashtype = class="st">"sha" |
| 626 | mod = __import__(hashtype) |
| 627 | hash = getattr(mod, hashtype)() |
| 628 | except (AttributeError, ImportError): |
| 629 | raise ValueError(fclass="st">"Don&class="cm">#x27;t know how to compute {hashtype!r} hash") |
| 630 | f = self.open(class="st">"rb") |
| 631 | try: |
| 632 | while 1: |
| 633 | buf = f.read(chunksize) |
| 634 | if not buf: |
| 635 | return hash.hexdigest() |
| 636 | hash.update(buf) |
| 637 | finally: |
| 638 | f.close() |
| 639 | |
| 640 | def new(self, **kw): |
| 641 | class="st">"""Create a modified version of this path. |