comparison fetch.py @ 47:72d461e2ccbd

more stubbing of copytree
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 15 Nov 2011 15:00:10 -0800
parents fb05b7616bd8
children bedef9761af9
comparison
equal deleted inserted replaced
46:fb05b7616bd8 47:72d461e2ccbd
23 """ 23 """
24 replacement for shutil.copytree because of this nonsense from help(shutil.copytree): 24 replacement for shutil.copytree because of this nonsense from help(shutil.copytree):
25 "The destination directory must not already exist." 25 "The destination directory must not already exist."
26 """ 26 """
27 27
28 assert os.path.exists(src), "'%s' does not exist" % src
29
28 # if its a file, just copy it 30 # if its a file, just copy it
29 if os.path.isfile(src): 31 if os.path.isfile(src):
30 shutil.copy2(src, dst) 32 shutil.copy2(src, dst)
31 return 33 return
32 34
35 if os.path.exists(dst): 37 if os.path.exists(dst):
36 assert os.path.isdir(dst), "%s is a file, %s is a directory" % (src, dst) 38 assert os.path.isdir(dst), "%s is a file, %s is a directory" % (src, dst)
37 else: 39 else:
38 os.makedirs(dst) 40 os.makedirs(dst)
39 41
42 src = os.path.realpath(src)
40 for dirpath, dirnames, filenames in os.walk(src): 43 for dirpath, dirnames, filenames in os.walk(src):
44 for d in dirnames:
45 pass
46 for f in filenames:
47 path = os.path.join(dirpath, f)
48 _dst = os.path.join(dst, os.path.relpath(path, src))
49 import pdb; pdb.set_trace()
50 # shutil.copy2(path
41 import pdb; pdb.set_trace() 51 import pdb; pdb.set_trace()
42 52
43 class Fetcher(object): 53 class Fetcher(object):
44 """abstract base class for resource fetchers""" 54 """abstract base class for resource fetchers"""
45 55
172 export a clone of the directory 182 export a clone of the directory
173 """ 183 """
174 dest = os.path.abspath(dest) 184 dest = os.path.abspath(dest)
175 tmpdir = tempfile.mkdtemp() 185 tmpdir = tempfile.mkdtemp()
176 self.clone(tmpdir) 186 self.clone(tmpdir)
187 if self.vcs_dir:
188 shutil.rmtree(os.path.join(tmpdir, self.vcs_dir))
177 path = tmpdir 189 path = tmpdir
178 if self.subpath: 190 if self.subpath:
179 path = os.path.join([tmpdir] + self.subpath) 191 path = os.path.join([tmpdir] + self.subpath)
180 assert os.path.exists(path), "subpath %s of %s not found" % (os.path.sep.join(self.subpath), self.url) 192 assert os.path.exists(path), "subpath %s of %s not found" % (os.path.sep.join(self.subpath), self.url)
181 if os.path.isdir(path): 193 if os.path.isdir(path):