OLD | NEW |
1 # Copyright (C) 2009 Google Inc. All rights reserved. | 1 # Copyright (C) 2009 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 self.files[destination] = self.files[source] | 118 self.files[destination] = self.files[source] |
119 self.written_files[destination] = self.files[source] | 119 self.written_files[destination] = self.files[source] |
120 | 120 |
121 def dirname(self, path): | 121 def dirname(self, path): |
122 return self._split(path)[0] | 122 return self._split(path)[0] |
123 | 123 |
124 def exists(self, path): | 124 def exists(self, path): |
125 return self.isfile(path) or self.isdir(path) | 125 return self.isfile(path) or self.isdir(path) |
126 | 126 |
127 def getsize(self, path): | |
128 if not self.exists(path): | |
129 self._raise_not_found(path) | |
130 return len(self.read_binary_file(path)) | |
131 | |
132 def files_under(self, path, dirs_to_skip=None, file_filter=None): | 127 def files_under(self, path, dirs_to_skip=None, file_filter=None): |
133 dirs_to_skip = dirs_to_skip or [] | 128 dirs_to_skip = dirs_to_skip or [] |
134 | 129 |
135 filter_all = lambda fs, dirpath, basename: True | 130 filter_all = lambda fs, dirpath, basename: True |
136 | 131 |
137 file_filter = file_filter or filter_all | 132 file_filter = file_filter or filter_all |
138 files = [] | 133 files = [] |
139 if self.isfile(path): | 134 if self.isfile(path): |
140 if file_filter(self, self.dirname(path), self.basename(path)) and se
lf.files[path] is not None: | 135 if file_filter(self, self.dirname(path), self.basename(path)) and se
lf.files[path] is not None: |
141 files.append(path) | 136 files.append(path) |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 return self.data.readline(length) | 495 return self.data.readline(length) |
501 | 496 |
502 def __iter__(self): | 497 def __iter__(self): |
503 return self.data.__iter__() | 498 return self.data.__iter__() |
504 | 499 |
505 def next(self): | 500 def next(self): |
506 return self.data.next() | 501 return self.data.next() |
507 | 502 |
508 def seek(self, offset, whence=os.SEEK_SET): | 503 def seek(self, offset, whence=os.SEEK_SET): |
509 self.data.seek(offset, whence) | 504 self.data.seek(offset, whence) |
OLD | NEW |