def __init__ (self, var, local_depot, dep, sub_depot): """Return an HTTP `Depot` object.""" # This is better, but doesn't work for classic classes: # super (http, self).__init__ (dep) # So, we're forced to hardcode the superclass for now: Depot.__init__ (self, dep) if type (dep) == types.InstanceType: self.var = dep.var else: self.var = var # full URL path where packages are to be found pkg_path = None if type (dep) == types.InstanceType: self.pkg_url = urljoin (dep.pkg_url, sub_depot) elif var is not None: # path to "root" of package directory pkg_path = var['dist'] if pkg_path: self.pkg_url = urljoin (self.pkg_url, pkg_path) if not local_depot: return # make local depot mirror the directory structure of the # remote depot. This is to make it possible to specify the # path of the local depot as a depot to future sessions. if type (dep) == types.InstanceType: self.local_path = os.path.join (dep.local_path, sub_depot) else: if pkg_path: self.local_path = os.path.join (local_depot, pkg_path) else: self.local_path = local_depot if not os.path.exists (self.local_path): os.makedirs (self.local_path)
def __init__ (self, var, dep, sub_depot): # This is better, but doesn't work for classic classes: # super (file, self).__init__ (dep) # So, we're forced to hardcode the superclass for now: Depot.__init__ (self, dep) if type (dep) == types.InstanceType: url = dep.url self.var = dep.var else: url = dep self.var = var self.local_path = urlparse (url).path # add to existing depot path if type (dep) == types.InstanceType: self.local_path = os.path.join (dep.local_path, sub_depot) self.pkg_url = urljoin (dep.pkg_url, sub_depot) else: if var and var['dist'] and os.path.exists (os.path.join (self.local_path, var['dist'])): self.local_path = os.path.join (self.local_path, var['dist']) self.pkg_url = urljoin (self.pkg_url, var['dist'])