OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 def copyfile(self, source, destination): | 73 def copyfile(self, source, destination): |
74 shutil.copyfile(source, destination) | 74 shutil.copyfile(source, destination) |
75 | 75 |
76 def dirname(self, path): | 76 def dirname(self, path): |
77 return os.path.dirname(path) | 77 return os.path.dirname(path) |
78 | 78 |
79 def exists(self, path): | 79 def exists(self, path): |
80 return os.path.exists(path) | 80 return os.path.exists(path) |
81 | 81 |
82 def getsize(self, path): | |
83 return os.path.getsize(path) | |
84 | |
85 def files_under(self, path, dirs_to_skip=[], file_filter=None): | 82 def files_under(self, path, dirs_to_skip=[], file_filter=None): |
86 """Return the list of all files under the given path in topdown order. | 83 """Return the list of all files under the given path in topdown order. |
87 | 84 |
88 Args: | 85 Args: |
89 dirs_to_skip: a list of directories to skip over during the | 86 dirs_to_skip: a list of directories to skip over during the |
90 traversal (e.g., .svn, resources, etc.) | 87 traversal (e.g., .svn, resources, etc.) |
91 file_filter: if not None, the filter will be invoked | 88 file_filter: if not None, the filter will be invoked |
92 with the filesystem object and the dirname and basename of | 89 with the filesystem object and the dirname and basename of |
93 each file found. The file is included in the result if the | 90 each file found. The file is included in the result if the |
94 callback returns True. | 91 callback returns True. |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 def split(self, path): | 274 def split(self, path): |
278 """Return (dirname, basename + '.' + ext)""" | 275 """Return (dirname, basename + '.' + ext)""" |
279 return os.path.split(path) | 276 return os.path.split(path) |
280 | 277 |
281 def splitext(self, path): | 278 def splitext(self, path): |
282 """Return (dirname + os.sep + basename, '.' + ext)""" | 279 """Return (dirname + os.sep + basename, '.' + ext)""" |
283 return os.path.splitext(path) | 280 return os.path.splitext(path) |
284 | 281 |
285 def make_executable(self, file_path): | 282 def make_executable(self, file_path): |
286 os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_
IRGRP | stat.S_IXGRP) | 283 os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_
IRGRP | stat.S_IXGRP) |
OLD | NEW |