def call(self, glob, start): stack = [] for ent in os.listdir("."): if isdir(ent) and (self.allow_dots() or ent[0] != "."): stack.append(ent) self.next.call(glob, ent) self.call_with_stack(glob, None, stack)
def call(self, glob, path): if path and not os.path.exists(path): return for ent in [".", ".."] + os.listdir(path if path else "."): if self.ismatch(glob.cache, ent): full = self.path_join(path, ent) if isdir(full): self.next.call(glob, full)
def setup(self, executable): """ Performs runtime setup. """ path = rpath.rabspath(self.find_executable(executable)) # Fallback to a path relative to the compiled location. lib_path = self.base_lib_path kernel_path = os.path.join(os.path.join(lib_path, os.path.pardir), "lib-topaz") while path: path = rpath.rabspath(os.path.join(path, os.path.pardir)) if isdir(os.path.join(path, "lib-ruby")): lib_path = os.path.join(path, "lib-ruby") kernel_path = os.path.join(path, "lib-topaz") break self.send(self.w_load_path, self.newsymbol("unshift"), [self.newstr_fromstr(lib_path)]) self.load_kernel(kernel_path)
def call_with_stack(self, glob, start, stack): old_sep = self.next.separator self.next.separator = self.separator self.next.call(glob, start) self.next.separator = old_sep while stack: path = stack.pop() try: entries = os.listdir(path) except OSError: continue for ent in entries: full = self.path_join(path, ent) if isdir(full) and (self.allow_dots() or ent[0] != "."): stack.append(full) self.next.call(glob, full)
def setup(self, executable): """ Performs runtime setup. """ path = rpath.rabspath(self.find_executable(executable)) # Fallback to a path relative to the compiled location. lib_path = self.base_lib_path kernel_path = os.path.join(os.path.join(lib_path, os.path.pardir), "lib-topaz") while True: par_path = rpath.rabspath(os.path.join(path, os.path.pardir)) if par_path == path: break path = par_path if isdir(os.path.join(path, "lib-ruby")): lib_path = os.path.join(path, "lib-ruby") kernel_path = os.path.join(path, "lib-topaz") break self.send(self.w_load_path, "unshift", [self.newstr_fromstr(lib_path)]) self.load_kernel(kernel_path)
def setup(self, executable): """ Performs runtime setup. """ path = rpath.rabspath(self.find_executable(executable)) # Fallback to a path relative to the compiled location. lib_path = self.base_lib_path kernel_path = os.path.join( os.path.join(lib_path, os.path.pardir), "lib-topaz") while True: par_path = rpath.rabspath(os.path.join(path, os.path.pardir)) if par_path == path: break path = par_path if isdir(os.path.join(path, "lib-ruby")): lib_path = os.path.join(path, "lib-ruby") kernel_path = os.path.join(path, "lib-topaz") break self.send(self.w_load_path, "unshift", [self.newstr_fromstr(lib_path)]) self.load_kernel(kernel_path) self.set_const( self.w_object, "RUBY_ENGINE", self.newstr_fromstr(system.RUBY_ENGINE)) self.set_const( self.w_object, "RUBY_VERSION", self.newstr_fromstr(system.RUBY_VERSION)) self.set_const( self.w_object, "RUBY_PATCHLEVEL", self.newint(system.RUBY_PATCHLEVEL)) self.set_const( self.w_object, "RUBY_PLATFORM", self.newstr_fromstr(system.RUBY_PLATFORM)) self.set_const( self.w_object, "RUBY_DESCRIPTION", self.newstr_fromstr(system.RUBY_DESCRIPTION)) self.set_const( self.w_object, "RUBY_REVISION", self.newstr_fromstr(system.RUBY_REVISION))
def method_directoryp(self, space, filename): return space.newbool(isdir(filename))