[Yum-devel] urlgrabber questions and comment

Ryan Tomayko rtomayko at naeblis.cx
Mon Mar 8 04:31:52 UTC 2004


On Sun, 2004-03-07 at 16:42, Michael Stenner wrote:
> On Sun, Mar 07, 2004 at 02:30:04PM -0700, Michael Stenner wrote:
> > I haven't changed these occurances except in the mirror-related stuff.
> > I wanted to figure out our cvs policies first to minimize conflicts.
> 
> Aw, crap.  I forgot we were going with URLGrabber for the package
> name.  Perhaps we should think about this again.  I hate all these
> collisions.  Now the package is the same name as a class in the
> grabber module. 

Yea, I noticed that to. 

>  Ick.  My brain is fried, so I'm not going to suggest
> anything now, but if anyone has some radical agenda they want to push,
> now is the best time to get it past me :)

Funny you mentioned it, I _was_ thinking about proposing something kind
of radical here a while back. I've noticed a few packages using
__init__.py to bring all public interfaces into a single place (can't
think of any off hand but I will try to find them and send out some
links). Basically, the idea is to make the package look like a module
containing everything that should be generally useful outside of the
package.

An example would be something like this:

__init__.py:
<<
import grabber
URLGrabber = grabber.URLGrabber
URLGrabError = grabber.URLGrabError
urlgrab = grabber.urlgrab
urlopen = grabber.urlopen
urlread = grabber.urlread
default_grabber = grabber.default_grabber

import progress
text_progress_meter = progress.text_progress_meter
>>

Let's say we named the package "urlgrabber". We can now import all of
these objects from the package instead of having to dig into specific
modules. 

import urlgrabber
urlgrabber.urlgrab(..)
g = urlgrabber.URLGrabber()
g.urlgrab(...)
etc..

I thought that was kind of a clever way of separating functionality that
should be exposed by a package from internal stuff.

Optik is one of the packages I found that does this, although a bit
differently than my example:

optik/__init__.py
<<
# Re-import these for convenience
from optik.option import Option
from optik.option_parser import *
from optik.help import *
from optik.errors import *
>>

Anyway, this is less of a suggestion and more of something to keep in
mind when thinking about how we want the package laid out. I don't have
any really great ideas for getting around the name clashes. I really
don't like "URLGrabber.grabber.URLGrabber" though. We probably need to
go with "urlgrabber" or "URLGrabber" for the package name; not much
wiggle room there. I'm more partial to the lowercase version for some
reason that I have no real explanation for. 

Oh well, let me know if you think of something clever.

- Ryan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.baseurl.org/pipermail/yum-devel/attachments/20040307/dc3fbb3b/attachment.pgp 


More information about the Yum-devel mailing list