Changeset 42

Show
Ignore:
Timestamp:
04/21/06 15:48:06 (3 years ago)
Author:
klattimer
Message:

#18 Started integrating [Source:Resources/contrib/alex/xml/parser.py alex's parser.py] testcase into [Source:src/prefs.py prefs.py] more code is required there though (check comments).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/prefs.py

    r33 r42  
    1 import utils, ui 
    2  
     1import utils, ui, sys 
     2from xml.sax import make_parser 
    33from xml.sax.handler import ContentHandler 
    44from xml.sax import parse 
    55 
    66preferences = list() 
     7repositories = list() 
     8 
     9class ParsePreferences( ContentHandler ): 
     10    in_conf_file = False 
     11    in_repo_list = False 
     12 
     13    def __init__ ( self, prefs, repos ): 
     14        self.prefs = prefs 
     15        self.repos = repos 
     16        self.data = [] 
     17         
     18    def startElement( self, name, attrs ): 
     19        if name == "winedoors": 
     20            self.in_conf_file = True 
     21        elif name == "repositories" and self.in_conf_file: 
     22            self.in_repo_list = True 
     23        elif name == "repo" and self.in_repo_list: 
     24            # Erm I think hehehe 
     25            text = ''.join( self.data ) 
     26            self.repos.append( [attrs.get( 'uri' ), text ] ) 
     27        elif name == "wineroot" and self.in_conf_file: 
     28            text = ''.join( self.data ) 
     29            preferences.append( ["wineroot", text] ) 
     30                     
     31    def characters ( self, string ): 
     32        if self.in_conf_file and self.in_repo_list: 
     33            self.repo.append( string ) 
     34        elif self.in_conf_file: 
     35            self.prefs.append( string ) 
     36                 
     37    def endElement( self, name ): 
     38        if name == "winedoors": 
     39            self.in_conf_file = False 
     40        elif name == "repositories" and self.in_conf_file: 
     41            self.in_repo_list = False 
    742 
    843class Preferences: 
     44    #def SetPref(self, name, value): 
     45    #def AddRepo():... 
     46    #def DefaultPreferences(self): 
     47        # Check queue.py -> CreateWinedrive 
    948    def LoadPreferences( self ): 
     49        handler = ParsePreferences(preferences, repositories) 
     50        parser = make_parser() 
     51        parser.setContentHandler(handler) 
     52        parser.parse(wineroot+"/wine) 
    1053        return 
    1154    def SavePreferences( self ): 
  • src/queue.py

    r33 r42  
    8686        os.symlink( utils.wineroot+"/installer-cache", utils.wineroot+"/dosdevices/e:" ) 
    8787        os.system( "winecfg -D" ) 
    88         # TODO: Should add the configuration for wine doors into this file 
    89         os.system( "echo \"wine doors managed wine drive\" > "+utils.wineroot+"/winedoors" ) 
     88        # Something went terribly wrong if this is true! 
    9089        if not os.path.isdir( utils.wineroot ): 
    9190            return -1 
     
    9392        name = ui.window['en_name'].get_text() 
    9493        company = ui.window['en_company'].get_text() 
     94        # TODO: Should add the configuration for wine doors into this file 
     95        ## deprecated this old thing - os.system( "echo \"wine doors managed wine drive\" > "+utils.wineroot+"/winedoors" ) 
     96        os.mkdir( utils.wineroot+"/winedoors" ) 
     97        prefs = Preferences() 
     98        prefs.DefaultPreferences() 
     99        prefs.SetPref("name", name) 
     100        prefs.SetPref("company", company) 
     101        prefs.SetPref("wineroot", wineroot) 
     102        prefs.SetPref("cdpath", utils.GetCD()) 
     103        prefs.SavePreferences() 
     104         
    95105        if os.path.isfile( utils.wineroot+"/system.reg" ): 
    96106            lines = [ line.replace( "Change preferred owner in ~/.wine/system.reg",  
  • src/utils.py

    r33 r42  
    141141def CheckWinedrive(): 
    142142    print "* Checking wine drive: " + wineroot 
    143     if os.path.isfile( wineroot+"/winedoors" ): 
     143    if os.path.isdir( wineroot+"/winedoors" ): 
    144144        return True 
    145145    else: