Looks up hashes in nsrlsvr.

    Args:
      hashes (list[str]): hash values to look up.

    Returns:
      list[HashAnalysis]: analysis results, or an empty list on error.
506421
def Analyze(self, hashes):
    
    logger.debug(
        'Opening connection to {0:s}:{1:d}'.format(self._host, self._port))

    nsrl_socket = self._GetSocket()
    if not nsrl_socket:
      self.SignalAbort()
      return []

    hash_analyses = []
    for digest in hashes:
      response = self._QueryHash(nsrl_socket, digest)
      if response is None:
        continue

      hash_analysis = interface.HashAnalysis(digest, response)
      hash_analyses.append(hash_analysis)

    nsrl_socket.close()

    logger.debug(
        'Closed connection to {0:s}:{1:d}'.format(self._host, self._port))

    return hash_analyses
671919
def results(analyser)
      r = analyser.results
      [0, nil].map do |val|
        r.select { |node, runs| runs == val }
         .keys
         .map(&:source)
      end
    end
702934
def hashes_above(path, line_number):
    
    def hash_lists(path):
        """Yield lists of hashes appearing between non-comment lines.

        The lists will be in order of appearance and, for each non-empty
        list, their place in the results will coincide with that of the
        line number of the corresponding result from `parse_requirements`
        (which changed in pip 7.0 to not count comments).

        """
        hashes = []
        with open(path) as file:
            for lineno, line in enumerate(file, 1):
                match = HASH_COMMENT_RE.match(line)
                if match:  # Accumulate this hash.
                    hashes.append(match.groupdict()['hash'])
                if not IGNORED_LINE_RE.match(line):
                    yield hashes  # Report hashes seen so far.
                    hashes = []
                elif PIP_COUNTS_COMMENTS:
                    # Comment: count as normal req but have no hashes.
                    yield []

    return next(islice(hash_lists(path), line_number - 1, None))
273493
def get_available_hashes():
    
    if sys.version_info >= (3,2):
        return hashlib.algorithms_available
    elif sys.version_info >= (2,7) and sys.version_info < (3,0):
        return hashlib.algorithms
    else:
        return 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'
847304
def sample(self, hashes):
        
        api_name = 'opendns-sample'
        fmt_url_path = u'sample/{0}'
        return self._multi_get(api_name, fmt_url_path, hashes)
712307
def system_find_analyses(input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/system/findAnalyses', input_params, always_retry=always_retry, **kwargs)
833007
def hash_key_path(hash, *path)
      result = nil

      path.each do |key|
        return nil unless hash.respond_to? :"[]"
        result = hash = hash[key]
      end

      return result
    end
1790
def _my_hash(arg_list):
    # type: (List[Any]) -> int
    """"""
    res = 0
    for arg in arg_list:
        res = res * 31 + hash(arg)
    return res
1046607
def parse_hashes(self):
        # type: () -> None
        

        line, hashes = self.split_hashes(self.line)
        self.hashes = hashes
        self.line = line
34228
def get_nodes_by_hashes(self, node_hashes: List[str]) -> List[Node]:
        """"""
        return self.session.query(Node).filter(Node.sha512.in_(node_hashes)).all()
1351497
def prune_hashes(self, hashes, list_type):
        """"""
        discarded = []
        for hash in hashes:
            if (hash in self.hashes):
                self.hashes.discard(hash)
                discarded.append(hash)
        self.logger.info("Not calculating %s hash(es) on destination as not present "
                         "in source %s list" % (', '.join(sorted(discarded)), list_type))
597614
def _calculate_file_hashes(full_path, f_hashers):
    
    if not os.path.exists(full_path):
        raise BagValidationError("%s does not exist" % full_path)

    try:
        with open(full_path, 'rb') as f:
            while True:
                block = f.read(1048576)
                if not block:
                    break
                for i in list(f_hashers.values()):
                    i.update(block)
    except IOError as e:
        raise BagValidationError("could not read %s: %s" % (full_path, str(e)))
    except OSError as e:
        raise BagValidationError("could not read %s: %s" % (full_path, str(e)))

    return dict(
        (alg, h.hexdigest()) for alg, h in list(f_hashers.items())
    )
1070375
def ListHashers(self):
    """"""
    hashers_information = hashers_manager.HashersManager.GetHashersInformation()

    table_view = views.ViewsFactory.GetTableView(
        self._views_format_type, column_names=['Name', 'Description'],
        title='Hashers')

    for name, description in sorted(hashers_information):
      table_view.AddRow([name, description])
    table_view.Write(self._output_writer)
754507
def load_hashes(filename):
    """"""
    # { filename : (sha1 of header if available or 'NA',
    #               sha1 of input,
    #               sha1 of output) }

    hashes = {}
    try:
        with open(filename, 'r') as cython_hash_file:
            for hash_record in cython_hash_file:
                (filename, header_hash,
                 cython_hash, gen_file_hash) = hash_record.split()
                hashes[filename] = (header_hash, cython_hash, gen_file_hash)
    except (KeyError, ValueError, AttributeError, IOError):
        hashes = {}
    return hashes
930467
def load_numpy(self, hash_list):
        
        assert len(hash_list) == 1
        self._check_hashes(hash_list)
        with open(self.object_path(hash_list[0]), 'rb') as fd:
            return np.load(fd, allow_pickle=False)
621752
def calculate_hashes(self):
        
        hashers = []
        if not self.mardata.signatures:
            return []

        for s in self.mardata.signatures.sigs:
            h = make_hasher(s.algorithm_id)
            hashers.append((s.algorithm_id, h))

        for block in get_signature_data(self.fileobj, self.mardata.signatures.filesize):
            [h.update(block) for (_, h) in hashers]

        return [(algo_id, h.finalize()) for (algo_id, h) in hashers]
1031570
def hashone(self):
    ""
    rs = self.one()
    if not rs: 
      return {}
    else:
      finds = " ".join(self._find).split(' ')
      return dict(zip((x.replace('?','') for x in finds), rs))