Re: yum source code

James Antill <[email protected]>
Newsgroups gmane.linux.rpm.yum
Message-ID <[email protected]>
pranjal pandit <[email protected]> writes:

> hello,
>
> I want to know about certain variables in source code mainly in files
> yumRepo.py and __init__.py
>
> 1) What is the variable 'i' for in line 1240 of __init__.py function
> and its connection with 'text' variable in line 1272 that follows

 I'd hope that this was more obvious...

i = 0
local_size = 0
for po in remote_pkgs:
    if os.path.exists(local):
    [...]
    i += 1

    if i == 1 and not local_size and remote_size == po.size:
        text = os.path.basename(po.relativepath)
    else:
        text = '(%s/%s): %s' % (i, len(remote_pkgs),
                                os.path.basename(po.relativepath))

...here we are walking remote_pkgs, and i is a count of how many pkgs
we've processed. We combine i with len(remote_pkgs) to get the (2/32)
output you see when downloading.

> 2)how are the urls to be tried for urlgrab() obtained in the function
> _getFile() of file yumRepo.py

 This is pretty magic, you can work it out by downloading and putting
print statements inside the functions (often a good recommendation,
even if only to confirm what you think you know).

 What happens is that this line:


    result = self.grab.urlgrab(misc.to_utf8(relative), local,

...results in a call to _setupGrab() (via. _getgrab() from the
self.grab property). _setupGrab() uses self.urls, which is another
property setup in _geturls(), which calls _baseurlSetup() this then
gets the mirrors from the mirrorlist or metalink metadata configured
for the repo.

-- 
James Antill -- [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.