/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/osutils.py

Update to bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
529
529
    return False
530
530
 
531
531
 
532
 
def pumpfile(fromfile, tofile):
 
532
def pumpfile(from_file, to_file, read_length=-1, buff_size=32768):
533
533
    """Copy contents of one file to another.
534
 
    
 
534
 
 
535
    The read_length can either be -1 to read to end-of-file (EOF) or
 
536
    it can specify the maximum number of bytes to read.
 
537
 
 
538
    The buff_size represents the maximum size for each read operation
 
539
    performed on from_file.
 
540
 
535
541
    :return: The number of bytes copied.
536
542
    """
537
 
    BUFSIZE = 32768
538
543
    length = 0
539
 
    while True:
540
 
        b = fromfile.read(BUFSIZE)
541
 
        if not b:
542
 
            break
543
 
        tofile.write(b)
544
 
        length += len(b)
 
544
    if read_length >= 0:
 
545
        # read specified number of bytes
 
546
 
 
547
        while read_length > 0:
 
548
            num_bytes_to_read = min(read_length, buff_size)
 
549
 
 
550
            block = from_file.read(num_bytes_to_read)
 
551
            if not block:
 
552
                # EOF reached
 
553
                break
 
554
            to_file.write(block)
 
555
 
 
556
            actual_bytes_read = len(block)
 
557
            read_length -= actual_bytes_read
 
558
            length += actual_bytes_read
 
559
    else:
 
560
        # read to EOF
 
561
        while True:
 
562
            block = from_file.read(buff_size)
 
563
            if not block:
 
564
                # EOF reached
 
565
                break
 
566
            to_file.write(block)
 
567
            length += len(block)
545
568
    return length
546
569
 
547
570
 
825
848
        return False
826
849
 
827
850
 
 
851
def host_os_dereferences_symlinks():
 
852
    return (has_symlinks()
 
853
            and sys.platform not in ('cygwin', 'win32'))
 
854
 
 
855
 
828
856
def contains_whitespace(s):
829
857
    """True if there are any whitespace characters in s."""
830
858
    # string.whitespace can include '\xa0' in certain locales, because it is
1344
1372
    # Windows returns 'cp0' to indicate there is no code page. So we'll just
1345
1373
    # treat that as ASCII, and not support printing unicode characters to the
1346
1374
    # console.
1347
 
    if user_encoding in (None, 'cp0'):
 
1375
    #
 
1376
    # For python scripts run under vim, we get '', so also treat that as ASCII
 
1377
    if user_encoding in (None, 'cp0', ''):
1348
1378
        user_encoding = 'ascii'
1349
1379
    else:
1350
1380
        # check encoding