-
Notifications
You must be signed in to change notification settings - Fork 20
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
print-summary: New script to dump a summary file #11
Conversation
Example output:
|
Works for me. Very useful! Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I left some python nitpicks, but this is good as is.
print-summary
Outdated
action='store') | ||
args = parser.parse_args() | ||
|
||
bytedata = GLib.Bytes.new(open(args.path).read()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more python-y way to do this would be with a context manager:
with open(args.path) as f:
bytedata = GLib.Bytes.new(f.read())
Then the file is closed immediately whether there's an error or not.
print-summary
Outdated
d = GLib.Variant.new_from_bytes(typestr, bytedata, False) | ||
|
||
refs = d[0] | ||
other = d[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more python-y way to write this is like:
refs, other = GLib.Variant.new_from_bytes(typestr, bytedata, False)
print-summary
Outdated
refs = d[0] | ||
other = d[1] | ||
|
||
for (refname, refdata) in refs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No parentheses needed here.
print-summary
Outdated
continue | ||
csum = '' | ||
for v in csumarray: | ||
csum += '%x' % v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
csum = ''.join(['%x' % v for v in csumarray])
for a one liner.
print-summary
Outdated
print("{} → {} (size={})".format(refname, csum, size)) | ||
|
||
deltas = other.get('ostree.static-deltas') | ||
if deltas is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you pass an empty dict as the default to get
, then you don't need to check for None
and can just loop way:
deltas = others.get('ostree.static-deltas', {})
2315fe6
to
2dc1690
Compare
Thanks @dbnicholson ! I've merged in all your changes. |
Useful for debugging:
https://mail.gnome.org/archives/ostree-list/2017-March/msg00000.html