[Yum] new daily snapshot
Vladimir Bormotov
bor at vb.dn.ua
Sat Jul 20 12:28:58 UTC 2002
Hi, seth!
>>>>> "sv" == seth vidal <skvidal at phy.duke.edu> writes:
sv> - implemented yum info [pkgname] ....
firs step: "one print, one format".
def displayinfo(hdr):
print """\
Name : %s
Version: %s
Release: %s
Size : %s
Summary: %s
Description:
%s
""" % (hdr[rpm.RPMTAG_NAME], hdr[rpm.RPMTAG_VERSION], hdr[rpm.RPMTAG_RELEASE],
clientStuff.descfsize(hdr[rpm.RPMTAG_SIZE]), hdr[rpm.RPMTAG_SUMMARY],
hdr[rpm.RPMTAG_DESCRIPTION])
Next step - move out 'output format' from source, into...
Who know? Maybe to text constant at top of module, maybe into config
file ;-))
Another step - incapsulate data into class hdr with dict-interface, and
simplify format-string:
For example, hdr['rpm_tag_name'] return value hdr[rpm.RPMTAG_NAME],
hdr['desc_fsize'] return clientStuff.descfsize(hdr[rpm.RPMTAG_SIZE])...
result of this two steps:
=== cut == yum.conf ==
output_format = """\
Name : %(rpm_tag_name)s
Version: %(rpm_tag_version)s
Release: %(rpm_tag_release)s
Size : %(desc_fsize)s
Summary: %(rpm_tag_summary)s
Description:
%(rpm_tag_description)s
"""
=== cut ==
def displayinfo(hdr):
print yumconf['info_fmt'] % hdr
Final step - diplayinfo move to hdr class. As result, instead
displayinfo(hdr) we use hdr.displayinfo().
finally,
for (name, arch) in pkglist:
hdr=nevral.getHeader(name,arch)
displayinfo(hdr)
del hdr
will looks like:
for package in pkglist:
nevral[package].getHeader().getDisplayinfo()
- no unnecessary object creation, memory allocation.
- programm code can be readed as 'text line at english'.
--
Bor.
More information about the Yum
mailing list