Mercurial > ~astiob > upreckon > hgweb
comparison upreckon/files.py @ 178:0d657576b1ac
tests directories are now searched for within archives
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Mon, 20 Jun 2011 17:52:09 +0300 |
parents | e0b2fbd7ebe0 |
children | a76cdc26ba9d |
comparison
equal
deleted
inserted
replaced
176:88e1e6786f67 | 178:0d657576b1ac |
---|---|
3 """File access routines and classes with support for archives.""" | 3 """File access routines and classes with support for archives.""" |
4 | 4 |
5 from __future__ import division, with_statement | 5 from __future__ import division, with_statement |
6 | 6 |
7 from .compat import * | 7 from .compat import * |
8 import contextlib, os, shutil, sys | 8 import contextlib, os, posixpath, shutil, sys |
9 | 9 |
10 # You don't need to know about anything else. | 10 # You don't need to know about anything else. |
11 __all__ = 'File', | 11 __all__ = 'File', |
12 | 12 |
13 # In these two variables, use full stops no matter what os.extsep is; | 13 # In these two variables, use full stops no matter what os.extsep is; |
203 if os.path.exists(path): | 203 if os.path.exists(path): |
204 self.full_real_path = self.real_path = path | 204 self.full_real_path = self.real_path = path |
205 return True | 205 return True |
206 return False | 206 return False |
207 | 207 |
208 def realize_path_archive(self, archive, root, virtpath, archpath): | 208 def realize_path_archive(self, archive, root, virtpath, archpath, hastests=False): |
209 if root and not archive.exists(root): | 209 if root and not archive.exists(root): |
210 return False | 210 return False |
211 if root: path = '/'.join((root, virtpath[0])) | 211 path = posixpath.join(root, virtpath[0]) |
212 else: path = virtpath[0] | |
213 if len(virtpath) > 1: | 212 if len(virtpath) > 1: |
214 if self.realize_path_archive(archive, path, virtpath[1:], archpath): | 213 if self.realize_path_archive(archive, path, virtpath[1:], archpath): |
215 return True | 214 return True |
216 elif self.realize_path_archive(archive, root, virtpath[1:], archpath): | 215 elif self.realize_path_archive(archive, root, virtpath[1:], archpath): |
217 return True | 216 return True |
218 else: | 217 else: |
219 if archive.exists(path): | 218 if archive.exists(path): |
220 self.archive = archive | 219 self.archive = archive |
221 self.real_path = path | 220 self.real_path = path |
222 self.full_real_path = os.path.join(archpath, *path.split('/')) | 221 self.full_real_path = os.path.join(archpath, *path.split('/')) |
222 return True | |
223 if not hastests: | |
224 if self.realize_path_archive(archive, posixpath.join(root, 'tests'), virtpath, archpath, True): | |
223 return True | 225 return True |
224 return False | 226 return False |
225 | 227 |
226 def open(self): | 228 def open(self): |
227 if self.archive: | 229 if self.archive: |