#2388 change getRPMHeaders default to fetching all headers if none are otherwise supplied
Merged 2 years ago by tkopecek. Opened 2 years ago by cobrien.
cobrien/koji all_headers  into  master

file modified
+1 -2
@@ -11660,8 +11660,7 @@ 

          is not valid or the rpm does not exist on the file system, an empty map

          will be returned.

          """

-         if not headers:

-             headers = []

+ 

          if rpmID:

              rpm_info = get_rpm(rpmID)

              if not rpm_info or not rpm_info['build_id']:

file modified
+14 -1
@@ -1037,18 +1037,31 @@ 

      return hdr[hdr_key]

  

  

- def get_header_fields(X, fields, src_arch=False):

+ def get_header_fields(X, fields=None, src_arch=False):

      """Extract named fields from an rpm header and return as a dictionary

  

      X may be either the rpm header or the rpm filename

      """

+ 

      if isinstance(X, str):

          hdr = get_rpm_header(X)

      else:

          hdr = X

      ret = {}

+ 

+     if fields is None:

+         if not rpm:

+             # while get_rpm_header will also check this, it's possible

+             # that X was constructed without rpm's help, bypassing

+             # that function.

+             raise GenericError("rpm's python bindings are not installed")

+ 

+         # resolve the names of all the keys we found in the header

+         fields = [rpm.tagnames[k] for k in hdr.keys()]

+ 

      for f in fields:

          ret[f] = get_header_field(hdr, f, src_arch=src_arch)

+ 

      return ret

  

  

This is a preliminary PR to start discussion off on allowing the getRPMHeaders hub call to default to all headers when none are specified explicitly.

This adds special treatment to a sentinel None value for the headers parameter to get_header_fields. An empty list would still be treated as if no headers were specified. To this end, the conversion of None to an empty list is therefore removed from the beginning of the getRPMHeaders call.

It may seem strange to support the call wanting no data back, but as that's the current default behavior anyway, I think that's fine.

Potential problems: is rpm.tagnames available in historic copies of the rpm library? It's in at least the RHEL 6 version.

@julian8628 per conversation on IRC today

Even rhel5 (py 2.4 + rpm 4.4) supports this. I would be ok with including this change.

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

2 years ago

Commit aa8f0f3 fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago