#16 Updating filters
Closed by psabata. Opened by cpacheco.
filter_update  into  master

Download 16.patch

Hi, I've updated the filtering feature to accommodate binary filtering, which we plan to later use in Rida (fm-orchestrator). The only file affected is __init__.py along with its related tests.

1 new commit added

  • Fixing bug with filtering

That could be filtered_packages = {}.

A couple of things about this block:

  • introduce & use "shortcut variables" rather than drill down through yaml every time
  • use dict.items() if and only if you need to access both keys and values
  • if you don't know that a dict contains an element, you can use the get() method to conditionally retrieve it
  • put operators besides operands (i.e. or on the beginning of the next lines), see PEP8
  • drop unnecessary parentheses
  • indent continued lines of if-conditions by one additional level to easier distinguish it from the following block (PEP8)
  • more and more verbose comments please :wink:, check PEP 8 guidelines about them

E.g.:

rpms_yaml = yml['data']['components']['rpms']
filter_yaml = rpms_yaml['filter']
packages_yaml = rpms_yaml['packages']
for filtkey, filter in filter_yaml.items():
    for p in packages_yaml:
        if (p == filtkey
                or filtkey in filtered_packages
                or filtkey in packages_yaml):
            # exclude this package
            continue
        arches = filter.get('arches')
        if arches:
            # pls add comment: what does the following mean?
            if arches[0] == ".+":
                arches = ["*"]
                filtkey += ".+"
        else:
            # filter is for all architectures
            arches = ["*"]
        filtered_packages[filtkey] = arches

similar here:

...
for pkey, pvalue in filtered_packages.items():
    for a in pvalue:
...

What does str(filtered).replace("'",'"') do here?

Another instance where dict.items() is handy...

Hmm, this is something I remember discussing with Lubos a few times.
I was always against this as it's already solved on the RPM level. There's no need to filter packages that don't get built on those particular architectures.

Well the deal here is to filter out packages that are build ... like, We don't want ship -devel packages at all :-)

Lubos

1 new commit added

  • Updating code to follow new coding guidelines

We still have no use for this and it's no longer compatible. I'll close this PR now.

Pull-Request has been closed by psabata

Metadata