~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2005-11-30 15:43:57 UTC
  • mto: (1185.50.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1518.
  • Revision ID: john@arbash-meinel.com-20051130154357-614206b3a7b83cd0
Refactored bzrlib/ui.py into a module with the possibility for multiple ui forms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
240
240
 
241
241
def pumpfile(fromfile, tofile):
242
242
    """Copy contents of one file to another."""
243
 
    tofile.write(fromfile.read())
 
243
    BUFSIZE = 32768
 
244
    while True:
 
245
        b = fromfile.read(BUFSIZE)
 
246
        if not b:
 
247
            break
 
248
        tofile.write(b)
244
249
 
245
250
 
246
251
def sha_file(f):
484
489
        raise NotBranchError("path %r is not within branch %r" % (rp, base))
485
490
 
486
491
    return os.sep.join(s)
 
492
 
 
493
 
 
494
 
 
495
def terminal_width():
 
496
    """Return estimated terminal width."""
 
497
 
 
498
    # TODO: Do something smart on Windows?
 
499
 
 
500
    # TODO: Is there anything that gets a better update when the window
 
501
    # is resized while the program is running? We could use the Python termcap
 
502
    # library.
 
503
    try:
 
504
        return int(os.environ['COLUMNS'])
 
505
    except (IndexError, KeyError, ValueError):
 
506
        return 80