[Piuparts-devel] piuparts.py - check_results()
Herbert Fortes
terberh at gmail.com
Fri Jan 18 13:13:57 GMT 2019
Hi,
I hope to not disturb. Please review and let
me know (Cc) if it is right or wrong.
check_results functions is:
# https://salsa.debian.org/debian/piuparts/blob/develop/piuparts.py#L2185
reference_info = chroot_state["tree"]
ok = True
if settings.check_broken_diversions:
(removed, added) = chroot.get_modified_diversions(chroot_state["diversions"])
if added; if removed
current_info = chroot.get_tree_meta_data()
if settings.warn_on_others and deps_info is not None:
(new, removed, modified) = diff_meta_data(reference_info, current_info)
(depsnew, depsremoved, depsmodified) = diff_meta_data(reference_info,
deps_info, quiet=True)
prune_files_list() 3x
else:
(new, removed, modified) = diff_meta_data(reference_info, current_info)
if new; if removed; if modified
if settings.warn_on_others and deps_info is not None:
if warnnew; if warnremoved; if warnmodified
return ok
diff_meta_data() will be called with the same reference_info
and current_info values
My suggestion is to run:
"(new, removed, modified) = diff_meta_data(reference_info, current_info)"
Before the first
"if settings.warn_on_others and deps_info is not None:"
reference_info = chroot_state["tree"]
ok = True
if settings.check_broken_diversions:
(removed, added) = chroot.get_modified_diversions(chroot_state["diversions"])
if added; if removed
current_info = chroot.get_tree_meta_data()
+(new, removed, modified) = diff_meta_data(reference_info, current_info)
+if new; if removed; if modified
if settings.warn_on_others and deps_info is not None:
- #(new, removed, modified) = diff_meta_data(reference_info, current_info)
(depsnew, depsremoved, depsmodified) = diff_meta_data(reference_info,
deps_info, quiet=True)
prune_files_list() 3x
-# else:
-# (new, removed, modified) = diff_meta_data(reference_info, current_info)
-# if new; if removed; if modified
-# if settings.warn_on_others and deps_info is not None:
if warnnew; if warnremoved; if warnmodified
return ok
In my opinion it is easier to read. I ran that against
one package.
Note that if new, removed and modified are empty,
warnew, warnremoved and warnmodified are empty too.
There will be no logging, no 'ok = False'. And maybe
4 functions call.
prune_files_list() is called with new, removed and modified
like this:
# https://salsa.debian.org/debian/piuparts/blob/develop/piuparts.py#L2091
warnnew = prune_files_list(new, depsnew)
def prune_files_list(files, depsfiles): # files = new
"""Remove elements from 'files' that are in 'depsfiles', and return the
list of removed elements.
"""
warn = []
depfiles_names = [x[0] for x in depsfiles]
for vfile in files[:]: # files is an empty list
if vfile[0] in depfiles_names:
files.remove(vfile)
warn.append(vfile)
return warn
Regards,
Herbert
More information about the Piuparts-devel
mailing list