Skip to content

Fixes the validation script #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions first_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ def hash_for_fname(fname):
"""
# Convert a string filename to a Path object.
fpath = Path(fname)
content = fpath.read_bytes()
hash_value = sha1(content).hexdigest()
# Your code here.
return 'not-really-the-hash'
return hash_value


# Fill in the function above to make the test below pass.
Expand All @@ -54,7 +56,19 @@ def check_hashes(hash_fname):
# Calculate actual hash for given filename.
# Check actual hash against expected hash
# Return False if any of the hashes do not match.
return False

data_list = hash_fname.read_text().split('\n')
del data_list[3]
boolean = True
for i in data_list:
line = i.split(' ')
filename_pth = data_dir / line[1]
expected_hash = line[0]
calculated_hash = hash_for_fname(filename_pth)
if calculated_hash != expected_hash:
boolean = False

return boolean


assert check_hashes(hashes_pth), 'Check hash list does not return True'