On Wed, Dec 3, 2008 at 1:03 AM, Douglas Anderson <[EMAIL PROTECTED]> wrote:
> On Wed, Dec 3, 2008 at 7:21 AM, Michael Smith <[EMAIL PROTECTED]> wrote:
>> I had the same idea and even began working on a roadmap for it.
>>
>> Step 1: move gentoolkit to site-packages
>> Step 2: move individual command classes to functionally-organized
>> module-files
>> Step 3: refactor and enhance docstrings to allow primary help/usage()
>> function to construct from individual modules. (The goal here is to create a
>> drop-in mechanism for adding new modules, so that usage() is automatically
>> updated when a new module is added.)
>> Step 4: Profit!
>>
>> Actually another approach would be to create a core __init__.py that handled
>> the usage() and getopt functionality I outlined in Step 3 above, and then
>> one-by-one modify the individual modules that are in the current equery so
>> they could be dropped in.
>>
>> Thoughts?
>>
>> Michael
>>
>> On Dec 2, 2008, at 5:01 AM, Douglas Anderson wrote:
>>
>>> Hi, I'm interesting in tinkering with equery and doing some
>>> refactorization in my spare time. I wrote a script that some people
>>> mentioned would be a good module for equery (emeta, it's on bugzilla), but
>>> as I was looking into that, I noticed that equery is written as a script,
>>> even though it would probably really benifit from being modularized.
>>>
>>> Again, this is just because I have some free time right now and a
>>> willingness to learn about Portage, but I thought I'd check with you guys
>>> first. If I'm willing to do it without bother you all too much, would it be
>>> something you're interested in me doing? My idea is to set it up more like a
>>> Python package than a script, like:
>>> /usr/lib/gentoolkit/pym/gentoolkit/equery/
>>> /usr/lib/gentoolkit/pym/gentoolkit/equery/__init__.py
>>> /usr/lib/gentoolkit/pym/gentoolkit/equery/belongs.py
>>> /usr/lib/gentoolkit/pym/gentoolkit/equery/check.py
>>> /usr/lib/gentoolkit/pym/gentoolkit/equery/depends.py
>>> etc...
>>>
>>> I think it would increase startup time and make adding or upgraded modules
>>> easier in the future.
>>>
>>> Well, I have a few more questions but I'll wait and see if this would be a
>>> positive thing or not.
>>>
>>> Thanks for your time,
>>> -Doug
>>
>>
>>
>
> Great, I'd like to give this a try, then.
>
> Michael, I was personally going to go for your "other approach" of
> having an __init__.py do all the setup and handle the input and send
> the local opts to the individual modules. If you're interested in
> working on it together, that would be great. I have a googlecodes repo
> that we can work out of, or whatever (same goes for anyone else) :)
> I'll also open up a bug for it when I have some work done.

<nitpick feel free to ignore me>
Don't put stuff in __init__.py.

Make a file called equery (no .py) and do all the work in the modules
you import; eg.

from equery import driver

if __name__ == "__main__":
  driver.Run()

Then put all this code in driver.py (option parsing, signal handling,
etc...).  Don't try to hide the code in __init__.py; it confuses
people who are trying to figure out what the module is for (since
__init__.py has very specific duties in declaring what is in the
module when you inspect the query module).  Putting the code in a file
named 'driver.py' or similarly makes it pretty obvious (to me anyway)
what the code in that file is for (to drive a program).

Does that make sense or am I full of crap?

</nitpick>

>
> A little RFC:
> 1) Spaces or tabs? Python standard is spaces, Gentoo seems to be
> predominantly tabs. I personally like to use spaces when I'm writing
> Python, but if that would annoy everyone later on, I'll stick to tabs.

Gentoo has no official coding standards.  I'd personally prefer spaces
(along with basically everything else in the Google Python Style
Guide[1]), but I'm probably not going to nitpick.  It is my opinion
that tabs are used because that is what the tools were written in and
it is annoying to change from tabs to spaces ;)

[1] http://code.google.com/p/soc/wiki/PythonStyleGuide

>
> 2) Are there any other progs that depend on equery and gentoolkit that
> you know of? If there are, I can try and keep an eye on things and
> create as little hassle as possible.
>
> Any other ideas?
>
> -Doug
>
>

Reply via email to