+def get_files(path):
+ """Get all files recursively in path as a list"""
+ filepaths = []
+ for root, dirnames, filenames in os.walk(path):
+ for filename in filenames:
+ filepath = os.path.join(root, filename)
+ filepaths.append(filepath)
+ return filepaths
+
+
+def get_sha1sum(debug=False):
+ """Get sha1sum for dists + .gitlab-ci.yml"""
+ filepaths = get_files(HERE)
+ m = hashlib.sha1()
+ i = 0
+ for filepath in sorted(list(filepaths)):
+ _filepath = os.path.relpath(filepath)
+ i += 1
+ if filepath == SHA1SUM_FILE_PATH:
+ d = "skip "
+ if debug:
+ print("%s: %s: %s" % (i, d, _filepath))
+ continue
+ if filepath == README_FILE_PATH:
+ d = "skip "
+ if debug:
+ print("%s: %s: %s" % (i, d, _filepath))
+ continue
+ if filepath.endswith('.pyc'):
+ d = "skip "
+ if debug:
+ print("%s: %s: %s" % (i, d, _filepath))
+ continue
+ with io.open(filepath, mode='rb') as _file:
+ _bytes = _file.read()
+
+ m1 = hashlib.sha1()
+ m1.update(_bytes)
+ d = m1.hexdigest()
+ if debug:
+ print("%s: %s: %s" % (i, d, _filepath))
+
+ m.update(_bytes)
+ return m.hexdigest()
+
+