Fixes modularity/fedmod#83
Metadata Update from @nphilipp: - Request assigned
dict
E.g. rather do it like this:
def print_summary(profiles, sdefaults=None, pdefaults=None, restrict_to=None): if sdefaults is None: sdefaults = {} if pdefaults is None: pdefaults = {} if restrict_to is None: restrict_to = [] ...
(*): with sdefaults=dict above, this will cause an exception if no value is provided
sdefaults=dict
You might want to fix the preceding lines. :wink:
I like using comments to describe the structure of the dicts!
There should be a space after the comma.
PEP8 advises two blank lines between top-level "things", i.e. import blocks, classes, functions.
I won't comment every new PEP8 violation because flake8 flags so many of them (both in the existing code and this PR). If you prefer, I can fix the PEP8 issues before committing (I'll want to rebase your PR on top of the current master branch anyway).
flake8
This looks like it's lifted from _repodata.py. Let's use these functions instead and import them here.
_repodata.py
Ugh, I really don't like the nested function + map here. How about using a list comprehension instead:
map
ln[cl_prof] = ", ".join(p + " [d]" for p in plist if pdefaults.get(modname, {}).get(sname, []) else p)
Same issue with mutable default values as above.
If we don't reuse the compiled regex, we can skip that step. Additionally, because we only target Python 3.6+, we can use f-strings here, too, and make the code a bit less dense:
def matches(self, mod, strm, prof, out): return ( re.search(fr'^{mod}\s+{strm}\s+{profile}$', out, re.MULTILINE) is not None )
Ugh, I really don't like the nested function + map here. How about using a list comprehension instead: ln[cl_prof] = ", ".join(p + " [d]" for p in plist if pdefaults.get(modname, {}).get(sname, []) else p) Don't know why you don't like the map, I find it more readable than the list comprehension. Anyway I'll change it.
Ugh, I really don't like the nested function + map here. How about using a list comprehension instead: ln[cl_prof] = ", ".join(p + " [d]" for p in plist if pdefaults.get(modname, {}).get(sname, []) else p)
Don't know why you don't like the map, I find it more readable than the list comprehension. Anyway I'll change it.
rebased onto 0b54e37a0fb3430b97939d3f37c82d9aea5c7402
7 new commits added
module-summarizer: add tests
Add tool for displaying summary of modules
fetchrepodata: make merge_modules public
repodata: make get_dataset public
Add lookup for default stream and profiles
Add lookup for module profiles in cached data
Use new ImprovedModule available in libmodulemd
Thanks! I guess using map() vs. comprehensions can be a matter of taste. The main reason I prefer the latter is because it's easier for novices to understand the code.
map()
I've noticed one other thing, i.e. that you use spec.v1.yaml in the test suite rather thanspec.v2.yaml but I'll just fix that afterwards.
spec.v1.yaml
spec.v2.yaml
Pull-Request has been merged by nphilipp
Fixes modularity/fedmod#83