def __init__(self, tool_box_name, mode = 'create', p2nt2 = None, style = 'usr') : """creation or recovery of a toolbox <tool_box_name> is the name of the toolbox <mode> is the opening mode. Proper modes are create(default) or modify create : creates a new toolbox tree under .../nt2/toolbox/ with the given <tool_box_name> provided that a directory of this name not existed previously (default) update : add all missing directories or files to an existing toolbox without modifying any existing files or directories modify : creates a new toolbox tree or allow access to an existing one to add or suppress functors extensions <p2nt2> is the path to nt2. The path defaults to the computation furnished by the Nt2 class <style> determines if the functors defined in the toolbox functors will reside in the namespace nt2 ('sys') or in the namespace <tool_box_name> ('usr'). It is only needed when mode is 'create' and is 'usr' by default. The other modes recover the creation parameter from existing data: in the present implementation, once created the toolbox mode cannot be modified. """ Mode = [ 'create', 'update', 'check', 'modify'] Style = ['usr','sys'] Nt2.__init__(self,'toolbox') self.__status = True self.logger = Mylogging("nt2.toolbox.Toolbox") if p2nt2 is None : p2nt2 = self.get_path2nt2() self.__tb_name = tool_box_name self.__tb_pathfnt2 = os.path.join(self.get_pathfnt2(),self.__tb_name) self.__tb = os.path.join(self.get_path2nt2(),self.__tb_pathfnt2) self.__tb_path2mode= os.path.join(self.get_path2nt2(),self.get_pathfnt2()) self.__tb_style = style if style == "sys" else "usr" if os.path.exists(self.get_tb_abs_path()) : self.read_style() self.__test_status = True self.__mode = mode self.__tb_tree = Toolbox.Tb_tree self.__tb_files= Toolbox.Tb_files Tb_files.__init__(self,self.__tb_name,self.__tb_path2mode, self.__tb_tree, self.__tb_files, style) if mode in Mode : self.logger.info( ("\nopening toolbox %s with mode: "% self.__tb_name) + mode+"\nin directory\n" + self.__tb ) action = getattr(self,mode+'_tbox') action() else: self.logger.error( "\nopening with unknown mode: "+mode+"\n"+ " raising SystemExit\n" ) raise SystemExit
def __init__(self, tb_list = None) : Nt2.__init__(self) if tb_list is None : self.tb_list = self.get_all_toolboxes() else : self.tb_list = tb_list
def __init__(self, tb_list = None, scalar_or_simd=None, datas = None) : Nt2.__init__(self) self.__tb_list = self.get_all_toolboxes() if tb_list is None else tb_list self.__sc_si = "scalar" if scalar_or_simd is None else scalar_or_simd self.__datas = ModifyUnitTests.Datas if datas is None else datas