* [gentoo-guis] new gettext like command retrieval
@ 2008-05-14 13:32 Brian
0 siblings, 0 replies; only message in thread
From: Brian @ 2008-05-14 13:32 UTC (permalink / raw
To: gentoo-guis
[-- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-05-14 13:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-14 13:32 [gentoo-guis] new gettext like command retrieval Brian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox