Ticket #11: createrepo-hashlib.patch

File createrepo-hashlib.patch, 1.4 kB (added by awillis, 8 years ago)

Patch to quiet deprecation warnings

  • dumpMetadata.py

    old new  
    2121import os 
    2222import rpm 
    2323import exceptions 
    24 import md5 
    25 import sha 
     24import hashlib 
    2625import types 
    2726import struct 
    2827import re 
     
    4443    def _write_gzip_header(self): 
    4544        self.fileobj.write('\037\213')             # magic header 
    4645        self.fileobj.write('\010')                 # compression method 
    47         fname = self.filename[:-3] 
     46        fname = self.name[:-3] 
    4847        flags = 0 
    4948        if fname: 
    5049            flags = FNAME 
     
    122121            opened_here = 1 
    123122            fo = open(file, 'rb', CHUNK) 
    124123             
    125         if sumtype == 'md5': 
    126             sum = md5.new() 
    127         elif sumtype == 'sha': 
    128             sum = sha.new() 
    129         else: 
    130             raise MDError, 'Error Checksumming file, wrong checksum type %s' % sumtype 
     124        sum = hashlib.new(sumtype) 
    131125        chunk = fo.read 
    132126        while chunk:  
    133127            chunk = fo.read(CHUNK) 
     
    600594        if type(self.hdr[rpm.RPMTAG_HDRID]) is not types.NoneType: 
    601595            t.append("".join(self.hdr[rpm.RPMTAG_HDRID])) 
    602596 
    603         key = md5.new("".join(t)).hexdigest() 
     597        key = hashlib.new('md5', ''.join(t)).hexdigest() 
    604598                                         
    605599        csumtag = '%s-%s-%s-%s' % (os.path.basename(self.relativepath),  
    606600                                   self.hdr[rpm.RPMTAG_SHA1HEADER],