Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(17)

Side by Side Diff: Lib/shutil.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/runpy.py ('k') | Lib/smtplib.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Utility functions for copying and archiving files and directory trees. 1 """Utility functions for copying and archiving files and directory trees.
2 2
3 XXX The functions here don't copy the resource fork or other metadata on Mac. 3 XXX The functions here don't copy the resource fork or other metadata on Mac.
4 4
5 """ 5 """
6 6
7 import os 7 import os
8 import sys 8 import sys
9 import stat 9 import stat
10 from os.path import abspath 10 from os.path import abspath
11 import fnmatch 11 import fnmatch
12 import collections 12 import collections
13 import errno 13 import errno
14 import tarfile 14 import tarfile
15 from collections import namedtuple
16 15
17 try: 16 try:
18 import bz2 17 import bz2
19 _BZ2_SUPPORTED = True 18 _BZ2_SUPPORTED = True
20 except ImportError: 19 except ImportError:
21 _BZ2_SUPPORTED = False 20 _BZ2_SUPPORTED = False
22 21
23 try: 22 try:
24 from pwd import getpwnam 23 from pwd import getpwnam
25 except ImportError: 24 except ImportError:
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 func(filename, extract_dir, **dict(format_info[2])) 747 func(filename, extract_dir, **dict(format_info[2]))
749 else: 748 else:
750 # we need to look at the registered unpackers supported extensions 749 # we need to look at the registered unpackers supported extensions
751 format = _find_unpack_format(filename) 750 format = _find_unpack_format(filename)
752 if format is None: 751 if format is None:
753 raise ReadError("Unknown archive format '{0}'".format(filename)) 752 raise ReadError("Unknown archive format '{0}'".format(filename))
754 753
755 func = _UNPACK_FORMATS[format][1] 754 func = _UNPACK_FORMATS[format][1]
756 kwargs = dict(_UNPACK_FORMATS[format][2]) 755 kwargs = dict(_UNPACK_FORMATS[format][2])
757 func(filename, extract_dir, **kwargs) 756 func(filename, extract_dir, **kwargs)
758
759 if hasattr(os, "statvfs") or os.name == 'nt':
760 _ntuple_diskusage = namedtuple('usage', 'total used free')
761
762 def disk_usage(path):
763 """Return disk usage statistics about the given path as a namedtuple
764 including total, used and free space expressed in bytes.
765 """
766 if hasattr(os, "statvfs"):
767 st = os.statvfs(path)
768 free = (st.f_bavail * st.f_frsize)
769 total = (st.f_blocks * st.f_frsize)
770 used = (st.f_blocks - st.f_bfree) * st.f_frsize
771 else:
772 import nt
773 total, free = nt._getdiskusage(path)
774 used = total - free
775 return _ntuple_diskusage(total, used, free)
OLDNEW
« no previous file with comments | « Lib/runpy.py ('k') | Lib/smtplib.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+