/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/config.py

  • Committer: Tim Marston
  • Date: 2016-02-16 00:26:53 UTC
  • Revision ID: tim@ed.am-20160216002653-oa8dgponknyislg3
added home directory change reporting to CopyOutWalker; added --quiet option to
update, resolve, revert and init commands; replace use of re.match with
re.search for clarity (and fixed related bug in FileMatcher); added BzrVcs.run
command output when verbose >= 2

Show diffs side-by-side

added added

removed removed

55
55
                        if line[ :1 ] == '#': continue
56
56
 
57
57
                        # if section
58
 
                        matches = re.match( '\[(.*)\]$', line );
 
58
                        matches = re.search( '^\[(.*)\]$', line );
59
59
                        if matches:
60
60
                                section = matches.group( 1 )
61
61
                                continue
62
 
                        matches = re.match( '([a-z0-9_-]+)\\s*=\\s*(.*)$', line, re.I )
 
62
                        matches = re.search( '^([a-z0-9_-]+)\\s*=\\s*(.*)$', line, re.I )
63
63
                        if matches:
64
64
                                name = matches.group( 1 )
65
65
                                value = matches.group( 2 )
66
66
 
67
67
                                # parse value
68
 
                                matches = re.match( '(["\'])((?:\\.|[^\\1])*)\\1(?:\\s*#.*)?$',
69
 
                                                                        value )
 
68
                                matches = re.search(
 
69
                                        '^(["\'])((?:\\.|[^\\1])*)\\1(?:\\s*#.*)?$', value )
70
70
                                if matches:
71
71
                                        value = matches.group( 2 )
72
72
                                else:
73
 
                                        matches = re.match( '([^#]+?)(?:\\s*#.*)?$', value )
 
73
                                        matches = re.search( '^([^#]+?)(?:\\s*#.*)?$', value )
74
74
                                        if( matches ):
75
75
                                                value = matches.group( 1 )
76
76
                                config[ "%s.%s" % ( section, name ) ] = value
88
88
        def to_bool( self, value ):
89
89
                value = value.lower()
90
90
                return value == 't' or value == 'true' or value == 'yes' or \
91
 
                        ( re.match( '[0-9]+$', value ) and int( value ) != 0 )
 
91
                        ( re.search( '^[0-9]+$', value ) and int( value ) != 0 )