1 ##############################################################################
2 # Copyright (c) 2017 Luke Hinds <lhinds@redhat.com>, Red Hat
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 # python generate-sha256.py --project /home/user/opnfv/infra
11 # output made to working directory, file `output.yaml`
17 from binaryornot.check import is_binary
19 hasher = hashlib.sha256()
20 parser = argparse.ArgumentParser()
22 parser.add_argument('--project', help="Full path to project folder",
24 args = parser.parse_args()
25 ignore_dirs = ['.git']
26 sys.stdout = open('output.yaml', 'w')
29 for root, dirs, files in os.walk(args.project):
30 dirs[:] = [d for d in dirs if d not in ignore_dirs]
32 full_path = os.path.join(root, file)
33 if is_binary(full_path):
34 with open(full_path, 'rb') as afile:
37 split_path = full_path.split(args.project + '/', 1)[-1]
38 print(" {}:".format(split_path))
39 sum = hasher.hexdigest()
40 print(" - {}".format(sum))