Changeset 1454

Show
Ignore:
Timestamp:
06/06/08 12:10:29 (7 months ago)
Author:
astormont
Message:

RegParser?.py pretty much ready for production use

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/astormont/RegParser.py

    r1453 r1454  
    88class RegParser( ConfigParser ): 
    99 
    10     header = "REGEDIT 4" 
     10    HEADER = "REGEDIT 4" 
    1111 
    12     # Fixed regex for .regs. Handles quotes better than the default class, too.  
    13     OPTCRE = re.compile( r'"?(?P<option>[^:=\s][^="]*)"?\s*(?P<vi>[:=])\s*"?(?P<value>.*)"?$' ) 
     12    # Fixed regex for .regs. Handles quotes better than the default class, too. 
     13    OPTCRE = re.compile( r'"?(?P<option>[^:=\s][^="]*)"?\s*(?P<vi>[:=])\s*"?(?P<value>[^"]*)' ) 
    1414 
    1515    # Disable case-insensitivty 
     
    4949            # skip first line (contains file header like: REGEDIT 4, or WINE REGISTRY 2) 
    5050            if lineno == 1 and not line.startswith(";") and not line.startswith("["): 
    51                 self.header = line 
     51                self.HEADER = line 
    5252                continue 
    5353            # comment or blank line? 
     
    7979                # no section header in the file? 
    8080                elif cursect is None: 
    81                     continue 
     81                    raise MissingSectionHeaderError(fpname, lineno, line) 
    8282                # an option line? 
    8383                else: 
     
    9292                                optval = optval[:pos] 
    9393                        optval = optval.strip() 
    94                         # Strip the quotes off the name & val, fix @ 
    95                         #if optname == "@": 
    96                         #    optname = "" 
    97                         #elif optname.startswith("\"") and optname.endswith("\""): 
    98                         #    optname = optname[1:-1] 
    99                         #if optval.startswith("\"") and optval.endswith("\""): 
    100                         #    optval = optval[1:-1] 
    10194                        cursect[optname] = optval 
    10295                    else: