Skip to content
Snippets Groups Projects
Commit 73d5ffb2 authored by Stefano Zacchiroli's avatar Stefano Zacchiroli
Browse files

bin/swh-hash-file: new binary to compute SWH-style content identifiers

reincarnation of the old shw.model bin/ script, which is now gone
parent a5f7d1e0
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python3
# Copyright (C) 2018 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import sys
from swh.model.from_disk import Content
from swh.model.hashutil import hash_to_hex
HASH_ALGO = 'sha1_git'
def hash_file(fname):
return hash_to_hex(Content.from_file(path=fname).hash)
def main(fnames):
for f in fnames:
print(f, hash_file(f), sep='\t')
if __name__ == '__main__':
fnames = sys.argv[1:]
if not fnames:
print('Usage: swh-hash-file FILE...')
sys.exit(2)
main(fnames)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment