~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/util/configobj/configobj.py

  • Committer: Robert Collins
  • Date: 2007-10-22 01:23:51 UTC
  • mfrom: (2921.3.1 graph)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20071022012351-16lm27an2lbzk038
Merge graph history-access bugfix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
678
678
        >>> def testuni(val):
679
679
        ...     for entry in val:
680
680
        ...         if not isinstance(entry, unicode):
681
 
        ...             print >> sys.stderr, type(entry)
 
681
        ...             sys.stderr.write(type(entry))
 
682
        ...             sys.stderr.write('\n')
682
683
        ...             raise AssertionError, 'decode failed.'
683
684
        ...         if isinstance(val[entry], dict):
684
685
        ...             testuni(val[entry])
1308
1309
            reset_comment = True
1309
1310
            # first we check if it's a section marker
1310
1311
            mat = self._sectionmarker.match(line)
1311
 
##            print >> sys.stderr, sline, mat
 
1312
##            sys.stderr.write('%s %s\n' % (sline, mat))
1312
1313
            if mat is not None:
1313
1314
                # is a section line
1314
1315
                (indent, sect_open, sect_name, sect_close, comment) = (
1345
1346
                #
1346
1347
                sect_name = self._unquote(sect_name)
1347
1348
                if sect_name in parent:
1348
 
##                    print >> sys.stderr, sect_name
 
1349
##                    sys.stderr.write(sect_name)
 
1350
##                    sys.stderr.write('\n')
1349
1351
                    self._handle_error(
1350
1352
                        'Duplicate section name at line %s.',
1351
1353
                        DuplicateError, infile, cur_index)
1359
1361
                parent[sect_name] = this_section
1360
1362
                parent.inline_comments[sect_name] = comment
1361
1363
                parent.comments[sect_name] = comment_list
1362
 
##                print >> sys.stderr, parent[sect_name] is this_section
 
1364
##                sys.stderr.write(parent[sect_name] is this_section)
 
1365
##                sys.stderr.write('\n')
1363
1366
                continue
1364
1367
            #
1365
1368
            # it's not a section marker,
1366
1369
            # so it should be a valid ``key = value`` line
1367
1370
            mat = self._keyword.match(line)
1368
 
##            print >> sys.stderr, sline, mat
 
1371
##            sys.stderr.write('%s %s\n' % (sline, mat))
1369
1372
            if mat is not None:
1370
1373
                # is a keyword value
1371
1374
                # value will include any inline comment
1392
1395
                            ParseError, infile, cur_index)
1393
1396
                        continue
1394
1397
                #
1395
 
##                print >> sys.stderr, sline
 
1398
##                sys.stderr.write(sline)
 
1399
##                sys.stderr.write('\n')
1396
1400
                key = self._unquote(key)
1397
1401
                if key in this_section:
1398
1402
                    self._handle_error(
1400
1404
                        DuplicateError, infile, cur_index)
1401
1405
                    continue
1402
1406
                # add the key
1403
 
##                print >> sys.stderr, this_section.name
 
1407
##                sys.stderr.write(this_section.name + '\n')
1404
1408
                this_section[key] = value
1405
1409
                this_section.inline_comments[key] = comment
1406
1410
                this_section.comments[key] = comment_list
1407
 
##                print >> sys.stderr, key, this_section[key]
 
1411
##                sys.stderr.write('%s %s\n' % (key, this_section[key]))
1408
1412
##                if this_section.name is not None:
1409
 
##                    print >> sys.stderr, this_section
1410
 
##                    print >> sys.stderr, this_section.parent
1411
 
##                    print >> sys.stderr, this_section.parent[this_section.name]
 
1413
##                    sys.stderr.write(this_section + '\n')
 
1414
##                    sys.stderr.write(this_section.parent + '\n')
 
1415
##                    sys.stderr.write(this_section.parent[this_section.name])
 
1416
##                    sys.stderr.write('\n')
1412
1417
                continue
1413
1418
            #
1414
1419
            # it neither matched as a keyword
2008
2013
        >>> try:
2009
2014
        ...     from validate import Validator
2010
2015
        ... except ImportError:
2011
 
        ...     print >> sys.stderr, 'Cannot import the Validator object, skipping the related tests'
 
2016
        ...     sys.stderr.write('Cannot import the Validator object, skipping the related tests\n')
2012
2017
        ... else:
2013
2018
        ...     config = '''
2014
2019
        ...     test1=40