/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: v.ladeuil+lp at free
  • Date: 2006-12-01 15:06:29 UTC
  • mto: (2172.3.1 bzr.73948)
  • mto: This revision was merged to the branch mainline in revision 2181.
  • Revision ID: v.ladeuil+lp@free.fr-20061201150629-zjd2an87u0r7nhhw
The tests that would have help avoid bug #73948 and all that mess :)

* bzrlib/transport/http/response.py:
(handle_response): Translate a 416 http error code into a bzr
exception.

* bzrlib/transport/http/_urllib2_wrappers.py:
(HTTPDefaultErrorHandler.http_error_default): Translate a 416 http
error code into a bzr exception.

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._curl_perform): It could happen that pycrul
itself detect a short read.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase._retry_get): New method, factorizing the retry
logic.
(HttpTransportBase.readv): We can have exception during the
initial GET worth degrading the range requirements (i.e. retrying
the GET request with either single or not ranges).

* bzrlib/tests/test_transport_implementations.py:
(TransportTests.test_readv_short_read): InvalidRange can also be
raised.

* bzrlib/tests/test_http.py:
(TestRangeRequestServer.test_readv_invalid_ranges): Was named
test_readv_short_read, the new name make the intent
clearer. Depending of the code path used (urllib or pycurl), both
exceptions can be raised.

* bzrlib/tests/HttpServer.py:
(TestingHTTPRequestHandler.do_GET): If invalid ranges are
specified, returns a 416 instead of the whole file (both are valid
according to the RFC).

Show diffs side-by-side

added added

removed removed

Lines of Context:
353
353
        if not isinstance(key, StringTypes):
354
354
            raise ValueError, 'The key "%s" is not a string.' % key
355
355
        # add the comment
356
 
        if not self.comments.has_key(key):
 
356
        if key not in self.comments:
357
357
            self.comments[key] = []
358
358
            self.inline_comments[key] = ''
359
359
        # remove the entry from defaults
361
361
            self.defaults.remove(key)
362
362
        #
363
363
        if isinstance(value, Section):
364
 
            if not self.has_key(key):
 
364
            if key not in self:
365
365
                self.sections.append(key)
366
366
            dict.__setitem__(self, key, value)
367
367
        elif isinstance(value, dict):
368
368
            # First create the new depth level,
369
369
            # then create the section
370
 
            if not self.has_key(key):
 
370
            if key not in self:
371
371
                self.sections.append(key)
372
372
            new_depth = self.depth + 1
373
373
            dict.__setitem__(
380
380
                    indict=value,
381
381
                    name=key))
382
382
        else:
383
 
            if not self.has_key(key):
 
383
            if key not in self:
384
384
                self.scalars.append(key)
385
385
            if not self.main.stringify:
386
386
                if isinstance(value, StringTypes):
1024
1024
            else:
1025
1025
                self.configspec = None
1026
1026
            return
1027
 
        elif hasattr(infile, 'read'):
 
1027
        elif getattr(infile, 'read', None) is not None:
1028
1028
            # This supports file like objects
1029
1029
            infile = infile.read() or []
1030
1030
            # needs splitting into lines - but needs doing *after* decoding
1344
1344
                        NestingError, infile, cur_index)
1345
1345
                #
1346
1346
                sect_name = self._unquote(sect_name)
1347
 
                if parent.has_key(sect_name):
 
1347
                if sect_name in parent:
1348
1348
##                    print >> sys.stderr, sect_name
1349
1349
                    self._handle_error(
1350
1350
                        'Duplicate section name at line %s.',
1394
1394
                #
1395
1395
##                print >> sys.stderr, sline
1396
1396
                key = self._unquote(key)
1397
 
                if this_section.has_key(key):
 
1397
                if key in this_section:
1398
1398
                    self._handle_error(
1399
1399
                        'Duplicate keyword name at line %s.',
1400
1400
                        DuplicateError, infile, cur_index)
1745
1745
        for entry in configspec.sections:
1746
1746
            if entry == '__many__':
1747
1747
                continue
1748
 
            if not section.has_key(entry):
 
1748
            if entry not in section:
1749
1749
                section[entry] = {}
1750
1750
            self._set_configspec_value(configspec[entry], section[entry])
1751
1751
 
1776
1776
        #
1777
1777
        section.configspec = scalars
1778
1778
        for entry in sections:
1779
 
            if not section.has_key(entry):
 
1779
            if entry not in section:
1780
1780
                section[entry] = {}
1781
1781
            self._handle_repeat(section[entry], sections[entry])
1782
1782
 
2852
2852
    >>> uc2 = ConfigObj(file_like)
2853
2853
    >>> uc2 == uc
2854
2854
    1
2855
 
    >>> uc2.filename == None
 
2855
    >>> uc2.filename is None
2856
2856
    1
2857
2857
    >>> uc2.newlines == '\\r'
2858
2858
    1