[Fedora-livecd-list] 04userconfig.py small cleanup

Toshio Kuratomi toshio at tiki-lounge.com
Thu Apr 20 23:10:12 UTC 2006


On Thu, 2006-04-20 at 14:37 -0500, Jasper O'neal Hartline wrote:
> Toshio Kuratomi wrote:
> 
> >It separates lokkit from ntsysv fine, but still contains duplicate code.
> >This is what's there now::
> >  if anaconda_args:
> >      if cmdline or kickstart:
> >          exit
> >      Run interactive
> >  else:
> >      Run interactive
> >
> >Because the code is exiting if it finds the anaconda_args it's looking
> >for we can make things simpler and remove duplicate code like so::
> >  if anaconda_args:
> >      if cmdline or kickstart:
> >          exit
> >  Run interactive
> >
> >  
> >
> Here we check if anaconda_args isn't empty, and if we aren't in cmdline 
> or kickstart:
> if anaconda_args != []:
>     for args in anaconda_args:
>
> Otherwise when anaconda_args is empty, we check just for lokkit and 
> ntsysv, we already know cmdline
> nor kickstart are in an empty anaconda_args.

Actually, the current code looks for lokkit and ntsysv before checking
the anaconda args but doesn't stop the processing until after.  So this
is less efficient (if efficiency can be talked about in a <50 line
context :-).

But the point I was making is not what the code does.  It's how it's
coded to do that.  Currently you have to edit two spots in the code
anytime you make a change to the lokkit/ntsysv detection.  If you add
another program you need to check the presence of, you'll have to add
the code in two places again.

By refactoring it, the code performs the same function as before but we,
the programmers, will only have to make changes in one place.

Attached patch:
- refactors the duplicate code to one location.
- moves checking of lokkit/ntsysv after the anaconda_args test because
I'm a perfectionist.

-Toshio

-------------- next part --------------
A non-text attachment was scrubbed...
Name: kadischi-userconfig.patch
Type: text/x-patch
Size: 2276 bytes
Desc: not available
Url : http://lists.fedoraproject.org/pipermail/livecd/attachments/20060420/58c802d6/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://lists.fedoraproject.org/pipermail/livecd/attachments/20060420/58c802d6/attachment-0001.bin 


More information about the livecd mailing list