def extract_hash(hash_fn, hash_type='sha256', file_name=''):
    source_sum = None
    partial_id = False
    name_sought = os.path.basename(file_name)
    log.debug('modules.file.py - extract_hash(): Extracting hash for file '
              'named: {0}'.format(name_sought))
    with salt.utils.fopen(hash_fn, 'r') as hash_fn_fopen:
        for hash_variant in HASHES:
            if hash_type == '' or hash_type == hash_variant[0]:
                log.debug('modules.file.py - extract_hash(): Will use regex to get'
                    ' a purely hexadecimal number of length ({0}), presumably hash'
                    ' type : {1}'.format(hash_variant[1], hash_variant[0]))
                hash_fn_fopen.seek(0)
                for line in hash_fn_fopen.read().splitlines():
                    hash_array = re.findall(r'(?i)(?<![a-z0-9])[a-f0-9]{' + str(hash_variant[1]) + '}(?![a-z0-9])', line)
                    log.debug('modules.file.py - extract_hash(): From "line": {0} '
                              'got : {1}'.format(line, hash_array))
                    if hash_array:
                        if not partial_id:
                            source_sum = {'hsum': hash_array[0], 'hash_type': hash_variant[0]}
                            partial_id = True

                        log.debug('modules.file.py - extract_hash(): Found: {0} '
                                  '-- {1}'.format(source_sum['hash_type'],
                                                  source_sum['hsum']))

                        if re.search(name_sought, line):
                            source_sum = {'hsum': hash_array[0], 'hash_type': hash_variant[0]}
                            log.debug('modules.file.py - extract_hash: For {0} -- '
                                      'returning the {1} hash "{2}".'.format(
                                          name_sought,
                                          source_sum['hash_type'],
                                          source_sum['hsum']))
                            return source_sum

    if partial_id:
        log.debug('modules.file.py - extract_hash: Returning the partially '
                  'identified {0} hash "{1}".'.format(
                       source_sum['hash_type'], source_sum['hsum']))
    else:
        log.debug('modules.file.py - extract_hash: Returning None.')
    return source_sum
Update component cutoff shared var, based on current parameters.
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/extract_hash--crossover with--dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/models/pca.py/_PCABase._update_cutoff