diff options
| author | Joseph Hunkeler <jhunk@stsci.edu> | 2015-11-21 12:52:53 -0500 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunk@stsci.edu> | 2015-11-21 12:52:53 -0500 | 
| commit | 8a68a451d435f62b0f666d748d27afc522d0a860 (patch) | |
| tree | 95260e1dcc864d321f246fdc4d1a4d58ccde9b4d /scripts | |
| parent | 5bfa88347bdefd9a674c5ac6ca17111216e19aec (diff) | |
| download | cbc-8a68a451d435f62b0f666d748d27afc522d0a860.tar.gz | |
Initial commit
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/cbc_repo2html | 37 | 
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/cbc_repo2html b/scripts/cbc_repo2html new file mode 100755 index 0000000..87bbc81 --- /dev/null +++ b/scripts/cbc_repo2html @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import argparse +import json +import os + + +if __name__ == '__main__': +    parser = argparse.ArgumentParser() +    parser.add_argument('repodata', action='store') +    args = parser.parse_args() + +    filename = args.repodata + +    if '.json' not in os.path.splitext(filename)[1]: +        print("JSON formatted file required.") +        exit(1) + +    repodata = None +    with open(filename, 'r') as data: +        repodata = json.load(data) + +    if repodata is None: +        print("Invalid JSON file.") +        exit(1) + +    print('<html>') +    print('<head>') +    print('<title>Repository Contents</title>') +    print('</head>') +    print('<body') +    print('<pre>') +    for key, subdict in sorted(repodata['packages'].items()): +        print("{0:50s} {1:>40s} {2:>20d}kb".format(key, subdict['md5'], subdict['size'])) +    print('</pre>') +    print('</body>') +    print('</html>')  | 
