<s> import os <EOL> import sys <EOL> import glob <EOL> import lxml . etree <EOL> import Bcfg2 . Options <EOL> def main ( ) : <EOL> parser = Bcfg2 . Options . get_parser ( <EOL> description = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_options ( [ Bcfg2 . Options . Common . repository ] ) <EOL> parser . parse ( ) <EOL> files = [ ] <EOL> for plugin in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> files . extend ( glob . glob ( os . path . join ( Bcfg2 . Options . setup . repository , <EOL> plugin , "<STR_LIT:*>" ) ) ) <EOL> for bfile in files : <EOL> bdata = lxml . etree . parse ( bfile ) <EOL> changed = False <EOL> for svc in bdata . xpath ( "<STR_LIT>" ) : <EOL> if "<STR_LIT>" not in svc . attrib : <EOL> continue <EOL> mode = svc . get ( "<STR_LIT>" ) <EOL> del svc . attrib [ "<STR_LIT>" ] <EOL> if mode not in [ "<STR_LIT:default>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] : <EOL> print ( "<STR_LIT>" % <EOL> ( svc . get ( "<STR_LIT:name>" ) , mode ) ) <EOL> mode = "<STR_LIT:default>" <EOL> if mode == "<STR_LIT:default>" or mode == "<STR_LIT>" : <EOL> svc . set ( "<STR_LIT>" , "<STR_LIT:true>" ) <EOL> svc . set ( "<STR_LIT>" , "<STR_LIT:true>" ) <EOL> elif mode == "<STR_LIT>" : <EOL> svc . set ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> svc . set ( "<STR_LIT>" , "<STR_LIT:true>" ) <EOL> elif mode == "<STR_LIT>" : <EOL> svc . set ( "<STR_LIT>" , "<STR_LIT:false>" ) <EOL> svc . set ( "<STR_LIT>" , "<STR_LIT:false>" ) <EOL> changed = True <EOL> if changed : <EOL> print ( "<STR_LIT>" % bfile ) <EOL> try : <EOL> open ( bfile , "<STR_LIT:w>" ) . write ( lxml . etree . tostring ( bdata ) ) <EOL> except IOError : <EOL> err = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> print ( "<STR_LIT>" % ( bfile , err ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( main ( ) ) </s>
