Re: Python API: TRIGGERTYPE unsupported type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 19, 2004 at 12:15:03PM -0500, Jeff Johnson wrote:
> 
> Hehe, see, even I can't remember header extensions ;-)
> 
> Thanks for the correction, I looked at rpmlib.h, not --querytags.
> 
> If there *is* a trigger type extension, it's used in exactly one place,
> rpm -q --scripts display output from /usr/lib/rpm/rpmpopt*.
> 
> That means that h.sprintf() (think: same as --queryformat arg but in python)
> rather than h['xxx'] might have to be used top retrieve the value instead.
> 
> 73 de Jeff

OK, so 

  #!/usr/bin/python
  import rpm,sys
  tn = rpm.tagnames
  ts = rpm.TransactionSet()
  mi = ts.dbMatch('name', 'termcap')
  h = mi.next()
  for tagname in ['FOOBAR', 'PREUNPROG', 'VENDOR', 'TRIGGERTYPE']:
    if tagname  in tn.values():
      print "%s is a tagname" % tagname
      for key in tn.keys():
        if tn[key] == tagname:
          print "%s key is %d" % (tagname,key)
          ttkey = key
          break
    else:
      print "%s is not a tagname" % tagname
      continue
    if ttkey in h.keys():
      print "keys include %s's" % tagname
    else:
      print "keys do not include %s's" % tagname
      continue
    print "tn[ttkey] is %s" % tn[ttkey]
    print "\"%%%%{%%s}\" %% tn[ttykey] is %s" % ("%%{%s}" % tn[ttkey])
    print "h.sprintf(\"%%%%{%%s}\" %% tn[ttkey]) is %s" % h.sprintf("%%{%s}" % tn[ttkey])

yields

  FOOBAR is not a tagname
  PREUNPROG is a tagname
  PREUNPROG key is 1087
  keys do not include PREUNPROG's
  VENDOR is a tagname
  VENDOR key is 1011
  keys include VENDOR's
  tn[ttkey] is VENDOR
  "%%{%s}" % tn[ttykey] is %{VENDOR}
  h.sprintf("%%{%s}" % tn[ttkey]) is Red Hat, Inc.
  TRIGGERTYPE is a tagname
  TRIGGERTYPE key is 1146
  keys include TRIGGERTYPE's
  tn[ttkey] is TRIGGERTYPE
  "%%{%s}" % tn[ttykey] is %{TRIGGERTYPE}
  h.sprintf("%%{%s}" % tn[ttkey]) is (none)

Thus, it appears that a bunch of RPMS are getting a None (or
null of some form) stuffed into TRIGGERTYPE.

Thanks, that answers my immediate question, and gives me a way
to iterate through all the header tags without it barfing, [1]
although I suppose that for the long term y'all might want to
wonder why this (none) thing is happening at all...

--Bob

[1] not that I wanted to do this on a regular basis, I was
developing something else and was just doing that to help me
understand what all was in there...


_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux