[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][ftp-team/dak][deploy] 3 commits: dep11-basic-validate.py: use `with` statement to manage file



Title: GitLab

Ansgar pushed to branch deploy at Debian FTP Team / dak

Commits:

2 changed files:

Changes:

  • scripts/debian/dep11-basic-validate.py
    ... ... @@ -161,16 +161,15 @@ def validate_data(data):
    161 161
     
    
    162 162
     
    
    163 163
     def validate_file(fname):
    
    164
    -    f = None
    
    165 164
         if fname.endswith('.gz'):
    
    166
    -        f = gzip.open(fname, 'r')
    
    165
    +        opener = gzip.open
    
    167 166
         elif fname.endswith('.xz'):
    
    168
    -        f = lzma.open(fname, 'r')
    
    167
    +        opener = lzma.open
    
    169 168
         else:
    
    170
    -        f = open(fname, 'r')
    
    169
    +        opener = open
    
    171 170
     
    
    172
    -    data = str(f.read(), 'utf-8')
    
    173
    -    f.close()
    
    171
    +    with opener(fname, 'rt', encoding='utf-8') as fh:
    
    172
    +        data = fh.read()
    
    174 173
     
    
    175 174
         return validate_data(data)
    
    176 175
     
    

  • scripts/debian/link_morgue.sh
    ... ... @@ -101,10 +101,8 @@ out=$(ssh ${DBHOST} preparehashes)
    101 101
     # And now we get us the file here, so we can easily lookup hashes.
    
    102 102
     # (the rsync uses the same ssh key and runs into the forced command.
    
    103 103
     # That just knows to send the file for rsync instead of preparing it.)
    
    104
    -if [[ ${out} == UPDATED ]]; then
    
    105
    -    cd "${dbdir}"
    
    106
    -    rsync ${DBHOST}:/srv/ftp-master.debian.org/home/hashes.gz ${HASHFILE}.gz
    
    107
    -fi
    
    104
    +cd "${dbdir}"
    
    105
    +rsync ${DBHOST}:/srv/ftp-master.debian.org/home/hashes.gz ${HASHFILE}.gz
    
    108 106
     
    
    109 107
     cd "${PROCESSDIR}"
    
    110 108
     log "Processing ${PROCESSDIR}"
    


  • Reply to: