comparison paint/package.py @ 48:abfb267e8332

debugging info; lord i hate this
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 08 May 2012 10:45:16 -0700
parents 213cf933366d
children 85374a69cf89
comparison
equal deleted inserted replaced
47:213cf933366d 48:abfb267e8332
39 39
40 # TODO: list of temporary files/directories to be deleted 40 # TODO: list of temporary files/directories to be deleted
41 41
42 def _path(self): 42 def _path(self):
43 """filesystem path to package directory""" 43 """filesystem path to package directory"""
44
45 print ">>> Getting path to package"
44 46
45 # return cached copy if it exists 47 # return cached copy if it exists
46 if self._tmppath: 48 if self._tmppath:
47 return self._tmppath 49 return self._tmppath
48 50
176 178
177 def info(self): 179 def info(self):
178 """return info dictionary for package""" 180 """return info dictionary for package"""
179 # could use pkginfo module 181 # could use pkginfo module
180 182
183 print ">>> Getting the info"""
184
181 pkg_info = self._pkg_info() 185 pkg_info = self._pkg_info()
182 186
183 # read the package information 187 # read the package information
184 info_dict = {} 188 info_dict = {}
185 for line in file(pkg_info).readlines(): 189 for line in file(pkg_info).readlines():
188 assert ':' in line 192 assert ':' in line
189 key, value = [i.strip() for i in line.split(':', 1)] 193 key, value = [i.strip() for i in line.split(':', 1)]
190 info_dict[key] = value 194 info_dict[key] = value
191 195
192 # return the information 196 # return the information
197 print ">>> Info: %s" % info_dict
193 return info_dict 198 return info_dict
194 199
195 def dependencies(self): 200 def dependencies(self):
196 """return the dependencies""" 201 """return the dependencies"""
197 # TODO: should probably have a more detailed dict: 202 # TODO: should probably have a more detailed dict:
285 os.makedirs(directory) 290 os.makedirs(directory)
286 assert os.path.isdir(directory) 291 assert os.path.isdir(directory)
287 tempdir = tempfile.mkdtemp() 292 tempdir = tempfile.mkdtemp()
288 try: 293 try:
289 self.download(tempdir) 294 self.download(tempdir)
290 for f in os.listdir(tempdir): 295 files = os.listdir(tempdir)
296 print ">>> Files: %s" % files
297 for f in files:
291 298
292 # full path 299 # full path
293 src = os.path.join(tempdir, f) 300 src = os.path.join(tempdir, f)
294 301
295 # make a package of the thing 302 # make a package of the thing
303 print ">>> pypi:Packaging %s" % src
296 package = Package(src) 304 package = Package(src)
305 print ">>> pypi:DONE packaging %s" % src
297 306
298 # get destination dirname, filename 307 # get destination dirname, filename
308 print ">>> pypi:Getting PyPI path"
299 dirname, filename = package.pypi_path() 309 dirname, filename = package.pypi_path()
310 print ">>> pypi:DONE PyPI path: %s/%s" % (dirname, filename)
300 311
301 # make the directory if it doesn't exist 312 # make the directory if it doesn't exist
302 subdir = os.path.join(directory, dirname) 313 subdir = os.path.join(directory, dirname)
303 if not os.path.exists(subdir): 314 if not os.path.exists(subdir):
304 os.makedirs(subdir) 315 os.makedirs(subdir)
305 assert os.path.isdir(subdir) 316 assert os.path.isdir(subdir)
306 317
307 # move the file 318 # move the file
319 print ">>> pypi:Moving to PyPI path %s/%s" % (subdir, filename)
308 package.package(destination=os.path.join(subdir, filename)) 320 package.package(destination=os.path.join(subdir, filename))
321 print ">>> Done with %s" % src
309 finally: 322 finally:
310 shutil.rmtree(tempdir) 323 shutil.rmtree(tempdir)
311 324
312 def pypi_path(self): 325 def pypi_path(self):
313 """ 326 """
314 returns subpath 2-tuple appropriate for pypi path structure: 327 returns subpath 2-tuple appropriate for pypi path structure:
315 http://k0s.org/portfolio/pypi.html 328 http://k0s.org/portfolio/pypi.html
316 """ 329 """
330 print ">>> pypi_path:Getting info"
317 info = self.info() 331 info = self.info()
332 print ">>> pypi_path:DONE getting info"
318 333
319 # determine the extension 334 # determine the extension
335 print ">>> pypi_path:Getting extension"
320 extension = self.extension() 336 extension = self.extension()
337 print ">>> pypi_path:DONE Getting extension: %s" % extension
321 338
322 # get the filename destination 339 # get the filename destination
323 name = info['Name'] 340 name = info['Name']
324 version = info['Version'] 341 version = info['Version']
325 filename = '%s-%s%s' % (name, version, extension) 342 filename = '%s-%s%s' % (name, version, extension)