public inbox for gentoo-guis@lists.gentoo.org
 help / color / mirror / Atom feed
From: Brian <dol-sen@telus.net>
To: gentoo-guis@lists.gentoo.org
Subject: [gentoo-guis] new gettext like command retrieval
Date: Wed, 14 May 2008 06:32:38 -0700	[thread overview]
Message-ID: <1210771958.18161.77.camel@localhost> (raw)

[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]

I've put together a little test config file and extremely basic
commands.py.

It works quite well from my live python trials.

brian@big_squirt ~/porthole/trunk/porthole/backends/test $ python
Python 2.5.2 (r252:60911, Apr 25 2008, 19:29:41) 
[GCC 4.1.2 (Gentoo 4.1.2 p1.0.2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from commands import get_cmd as g
>>> from commands import get_sections, get_items, get_options
>>> get_sections()
['sync', 'install_opts', 'update', 'install', 'uninstall']
>>> get_options('install')
['install_pv', 'install_p', 'install']
>>> get_items('install')
[('install_pv', 'emerge -pv'), ('install_p', 'emerge -p'), ('install',
'emerge')]
>>> g('install','install_p')
'emerge -p'
>>> g('install','install_pv')
'emerge -pv'
>>> 


Of course it can be refined a lot more, but seems to work quite well.  I
will need to change the way porthole builds it commands to be more
compatible with pkgcore.  But I think this method will work better
overall.  I have had requests for the ability to specify custom scripts
for several of the currently hard coded 'emerge' commands.  That part of
it can be taken care of by checking for a users ~/.porthole/portage.cfg
or ~/.porthole/pkgcore.cfg depending on the backend selected and using
it instead of the pre-configured one in the backend subdirectory.
-- 
Brian <dol-sen@telus.net>

[-- Attachment #2: commands.py --]
[-- Type: text/x-python, Size: 434 bytes --]

#!/usr/bin/env python

from ConfigParser import SafeConfigParser

cp = SafeConfigParser()
cp.read('portage.cfg')


def get_cmd(section,cmd):
    global cp
    try:
        return cp.get(section, cmd)
    except:
        return ''

def get_sections():
    global cp
    return cp.sections()
    
def get_items(section):
    global cp
    return cp.items(section)

def get_options(section):
    global cp
    return cp.options(section)

[-- Attachment #3: portage.cfg --]
[-- Type: text/plain, Size: 396 bytes --]

[install]
install = emerge
install_p = emerge -p
install_pv = emerge -pv

[uninstall]
uninstall_cmd = emerge --unmerge

[update]
update_basic = emerge --update
update_deep = emerge --update --deep
update_pv = emerge -pv
update_pvd = emerge -pvD

[sync]
sync_default = emerge --sync
sync_web = emerge webrsync

[install_opts]
pretend = --pretend
deep = --Deep
verbose = --verbose
newuse = --newuse

                 reply	other threads:[~2008-05-14 13:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1210771958.18161.77.camel@localhost \
    --to=dol-sen@telus.net \
    --cc=gentoo-guis@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox