Changeset 1324

Show
Ignore:
Timestamp:
05/11/08 08:43:26 (4 months ago)
Author:
klattimer
Message:

Tidying up preferences, moving all bottle/installed handling to a seperate space

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wine-doors/branches/0.2/src/bottles/__init__.py

    r1286 r1324  
     1from const import * 
    12 
    23class ParseBottles: 
    3     pass 
    4  
    5 class Bottle: 
    64    pass 
    75 
     
    1816    def CreateBottle( self ): 
    1917        pass 
     18 
     19 
     20 
     21class default: 
     22    pass 
     23# TODO: Ripped from old preferences.py 
     24#        f.write( "  <bottles>\n" ) 
     25#        for name, path, icon in self.bottles: 
     26#            f.write( "    <bottle name=\"%s\" path=\"%s\" icon=\"%s\" />\n" % ( name, path, icon ) ) 
     27#        f.write( "  </bottles>\n" ) 
     28 
     29# endelement 
     30#        elif name == "bottle" and self.in_bottles: 
     31#            self.bottles.append ( [self.bottle_name, self.bottle_path, self.bottle_icon] ) 
     32# start element 
     33#        elif name == "bottle" and self.in_bottles: 
     34#            self.bottle_name = attrs.get( 'name' ) 
     35#            self.bottle_name = self.bottle_name.rstrip() 
     36#            self.bottle_path = attrs.get( 'path' ) 
     37#            self.bottle_path = self.bottle_path.rstrip() 
     38#            self.bottle_icon = attrs.get( 'icon' ) 
     39#            self.bottle_icon = self.bottle_icon.rstrip() 
     40 
  • wine-doors/branches/0.2/src/preferences.py

    r1323 r1324  
    2626     
    2727    def startElement( self, name, attrs ): 
    28         if name == "winedoors-prefernces": 
     28        if name == "prefernces": 
    2929            self.in_conf_file = True 
    3030        elif name == "repositories" and self.in_conf_file: 
     
    4545            self.repo_password = attrs.get( 'password' ) 
    4646            self.repo_password = self.repo_password.rstrip() 
    47         elif name == "bottle" and self.in_bottles: 
    48             self.bottle_name = attrs.get( 'name' ) 
    49             self.bottle_name = self.bottle_name.rstrip() 
    50  
    51             self.bottle_path = attrs.get( 'path' ) 
    52             self.bottle_path = self.bottle_path.rstrip() 
    53  
    54             self.bottle_icon = attrs.get( 'icon' ) 
    55             self.bottle_icon = self.bottle_icon.rstrip() 
    5647 
    5748    def characters ( self, string ): 
     
    5950         
    6051    def endElement( self, name ): 
    61         if name == "winedoors-preferences": 
     52        if name == "preferences": 
    6253            self.in_conf_file = False 
    6354        elif name == "repositories" and self.in_conf_file: 
    6455            self.in_repo_list = False 
    65         elif name == "bottles" and self.in_conf_file: 
    66             self.in_bottles = False 
    6756        elif name == "repo" and self.in_repo_list: 
    6857            self.repositories.append( [self.repo_name, self.repo_uri, 
    6958                                       self.repo_username, self.repo_password] ) 
    70         elif name == "bottle" and self.in_bottles: 
    71             self.bottles.append ( [self.bottle_name, self.bottle_path, self.bottle_icon] ) 
    7259        elif self.in_conf_file: 
    7360            text = ''.join( self.data ) 
     
    9178                preferences_file = "/etc/wine-doors/preferences.xml" 
    9279                if not os.path.isfile( preferences_file ): 
    93                     os.popen( "mkdir " + os.path.expanduser( "~/.wine-doors" ) ) 
     80                    os.system( "mkdir -p " + os.path.expanduser( "~/.wine-doors" ) ) 
    9481                    self.preferences_file = os.path.expanduser( "~/.wine-doors/preferences.xml" ) 
    9582                    self.Default() 
     
    116103   
    117104    def DefaultRepos ( self ): 
    118         preferences.AddRepo( "Applications", "http://www.wine-doors.org/repositories/applications.repo/" ) 
    119         preferences.AddRepo( "System Base", "http://www.wine-doors.org/repositories/base.repo/" ) 
    120         preferences.AddRepo( "Games", "http://www.wine-doors.org/repositories/games.repo/" ) 
    121         preferences.AddRepo( "Libraries and Fonts", "http://www.wine-doors.org/repositories/libraries.repo/" ) 
     105        preferences.AddRepository( "Applications", "http://www.wine-doors.org/repositories/applications.repo/" ) 
     106        preferences.AddRepository( "System Base", "http://www.wine-doors.org/repositories/base.repo/" ) 
     107        preferences.AddRepository( "Games", "http://www.wine-doors.org/repositories/games.repo/" ) 
     108        preferences.AddRepository( "Libraries and Fonts", "http://www.wine-doors.org/repositories/libraries.repo/" ) 
    122109 
    123     def AddRepo( self, name, uri, username=None, password=None ): 
     110    def AddRepository( self, name, uri, username=None, password=None ): 
    124111        for item in self.repositories: 
    125112            if ''.join( item[0:1] ) == name: 
     
    130117 
    131118    # TODO  
    132     def DelRepo( self, name ): 
    133         pass 
    134     def AddBottle ( self, name, path, icon ): 
    135         pass 
    136     def DelBottle ( self, name ): 
     119    def DelRepository( self, name ): 
    137120        pass 
    138121 
     
    167150 
    168151        f = open( preferences_file, "wt" ) 
    169         f.write( "<winedoors-preferences>\n" ) 
     152        f.write( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" ) 
     153        f.write( "<!--DOCTYPE WineDoorsPreferences SYSTEM \"http://www.wine-doors.org/dtd/preferences.dtd\"-->\n" ) 
     154        f.write( "<preferences>\n" ) 
    170155 
    171156        for key, value in self.preferences.iteritems(): 
     
    181166        f.write( "  </repositories>\n" ) 
    182167 
    183         f.write( "  <bottles>\n" ) 
    184         for name, path, icon in self.bottles: 
    185             f.write( "    <bottle name=\"%s\" path=\"%s\" icon=\"%s\" />\n" % ( name, path, icon ) ) 
    186         f.write( "  </bottles>\n" ) 
    187  
    188         f.write( "</winedoors-preferences>\n" ) 
     168        f.write( "</preferences>\n" ) 
    189169        f.close() 
    190170