Changeset 1329

Show
Ignore:
Timestamp:
05/11/08 12:53:23 (2 months ago)
Author:
klattimer
Message:

Added bottles parser

Files:

Legend:

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

    r1328 r1329  
    33class ParseBottles( ContentHandler ): 
    44    def __init__( self, bottles ): 
    5         pass 
     5        self.bottles = bottles 
     6        self.bottle = {} 
     7        self.in_bottles = False 
     8        self.in_bottle = False 
     9        self.data = [] 
    610 
    711    def startElement( self, name, attrs ): 
    8         pass 
     12        if name == "bottles": 
     13            self.in_bottles = True 
     14        if name == "bottle": 
     15            self.in_bottle = True 
    916 
    1017    def characters ( self, string ): 
     
    1219 
    1320    def endElement (self, name ) 
    14         pass 
     21        if name == "bottles" and self.in_bottles: 
     22            self.bottles.append ( self.bottle ) 
     23            self.in_bottles = False 
     24        elif name == "bottle" and self.in_bottle: 
     25            self.in_bottle = False 
     26        elif self.in_bottle: 
     27            text = ''.join( self.data ) 
     28            text = text.rstrip() 
     29            self.bottle[name] = unquote( str( text ) ) 
     30        self.data = [] 
    1531 
    1632class Bottles: 
     
    2743        pass 
    2844 
    29  
    30  
    3145class default: 
    3246    pass 
     47 
    3348# TODO: Ripped from old preferences.py 
    3449#        f.write( "  <bottles>\n" ) 
  • wine-doors/branches/0.2/src/preferences.py

    r1327 r1329  
    6363        self.repositories = [] 
    6464        self.licenses = [] 
    65         self.preferences = {} 
     65        self.Reset() 
    6666 
    6767        if not preferences_file or not os.path.isfile( preferences_file ): 
     
    112112        self.repositories.append( (name, src, username, password) ) 
    113113 
    114     # TODO  
    115114    def DelRepository( self, name ): 
    116         pass 
     115        for index, (ename, esrc, eusername, epassword) in enumerate(self.repositories): 
     116            if ename == name: 
     117                del self.repositories[index] 
    117118 
    118119    def Reset( self ): 
  • wine-doors/branches/0.2/src/repositories.py

    r1320 r1329  
    104104             
    105105            if self.in_application and not self.in_packages: 
    106                 self.metadata[name] = text 
     106                self.metadata[name] = unquote( str( text ) ) 
    107107 
    108108    def characters( self, string ):