parsing grub's menu.lst
I need some code that will read in grubs menu.lst file, and give me a
list of dicts:
[{'title':'Ubuntu, kernel 2.6.15-23-686',
'root':'(hd0,0)',
'kernel':'/boot/vmlinuz-2.6.15-23-686 root=/dev/hda1 ro quiet splash',
'initrd':'/boot/initrd.img-2.6.15-23-686',
'savedefault':'',
'boot':''},
{'title':} ]
I am not really sure what the rules are, like does it have to have a
title, and do blank lines mean anything? so 1/2 of what I am looking
for is something that already knows what the rules are.
What I really want to parse is pxelinux.cfg/default file typically
used when pxe booting. which I 'think' is the same format is grub/
menu.lst, and it uses 'label' instead of 'title' which is making me
wonder if I should rely n the rules being the same. For now I am
willing to take that chance.
Carl K
--
http://mail.python.org/mailman/listinfo/python-list
Re: parsing grub's menu.lst
On Nov 17, 12:56 pm, Albert Hopkins <[EMAIL PROTECTED]> wrote:
> On Mon, 2008-11-17 at 10:27 -0800, CarlFK wrote:
> > I need some code that will read in grubs menu.lst file, and give me a
> > list of dicts:
>
> > [{'title':'Ubuntu, kernel 2.6.15-23-686',
> > 'root':'(hd0,0)',
> > 'kernel':'/boot/vmlinuz-2.6.15-23-686 root=/dev/hda1 ro quiet splash',
> > 'initrd':'/boot/initrd.img-2.6.15-23-686',
> > 'savedefault':'',
> > 'boot':''},
> > {'title':} ]
>
> > I am not really sure what the rules are, like does it have to have a
> > title, and do blank lines mean anything? so 1/2 of what I am looking
> > for is something that already knows what the rules are.
>
> > What I really want to parse is pxelinux.cfg/default file typically
> > used when pxe booting. which I 'think' is the same format is grub/
> > menu.lst, and it uses 'label' instead of 'title' which is making me
> > wonder if I should rely n the rules being the same. For now I am
> > willing to take that chance.
>
> Why take a chance when you can get it right the first time? There is
> documentation on the syslinux config formats at their web site
> (http://syslinux.zytor.com/).
Um... I poked around, best I could find was:
http://syslinux.zytor.com/wiki/index.php/SYSLINUX#How_do_I_Configure_SYSLINUX.3F
Which explains what each option does, but not how they are grouped.
Carl K
--
http://mail.python.org/mailman/listinfo/python-list
Re: Multiple equates
On Nov 17, 2:54 pm, [EMAIL PROTECTED] (Cameron Laird) wrote: > In article <[EMAIL PROTECTED]>, > Tim Chase <[EMAIL PROTECTED]> wrote: > . > . > .>To the OP, I think rather than cluttering my code, > I'd just > >create a loop > > > for i in [x1,x2,x3,x4,...x1024]: > > a[i] = False > > . > . > . > I much prefer this, too. > > I've been trying to decide if there's any sober reason to advocate > the one-liner > > map(lambda i: a.__setitem__(i, False), [x1, x2, x3, ..., x1024]) > > My answer: no. well, the OP was "...faster?" not "best, cleanest, pythonic..." so the reason would be speed. (looks faster, don't know for sure) (and yeah, looks ugly. but we need the speed...) Carl K -- http://mail.python.org/mailman/listinfo/python-list
