def __read_control_params(self, fname, section): # fname: Control parameter file name. # section: Control parameter section name. cwd = self.dir['solution'].split(os.sep) top = len(cwd) for n in range(len(cwd)): if cwd[n] in ['tests', 'Samples']: top = n for n in range(top, len(cwd)): up = len(cwd) - n - 1 prefix = '' for n in range(up): prefix += '..' + os.sep if os.path.exists(prefix + fname): kvf = KvFile(prefix + fname) section = self.ctlfile['section'] if kvf.read() > 0: self.__set_control_values(kvf) if self.verbose > 1: cs_control_str = ['AUTO', 'USE', 'UNUSE'] print('\ncontrol_params:') print(' Exclude %s' % self.control['exclude']) print(' SolutionAlias %s' % self.solution) print(' OutputDir %s' % self.dir['output']) print(' UseClosedSrc %s' % self.control['use_closed_src']) print(' CS control %s' % cs_control_str[self.control['cs_control']]) print(' CppMacro %s' % self.control['cppmacro']) print(' Build %s' % self.control['exe'][self.BLD]) print(' Run %s' % self.control['exe'][self.RUN]) print(' Timeout %s' % self.control['timeout']) print(' ExpectedStatus %s' % self.control['expected']) print(' NeedIntervene %s' % self.control['needintervention']) print(' KillProcess %s' % self.control['killprocess'])
def __read_file(self): # initialize self.path_list = {} self.prog_list = {} self.data_list = {} # read file kvf = KvFile(self.path) if kvf.read() <= 0: print('%s: can\'t open file "%s"' % (self.clsname, self.path)) return -1 self.kvf = kvf # prog list keys = kvf.change_section(self.PROG) keys = kvf.keys() for key in keys: self.prog_list[key] = kvf.get(key) # path list keys = kvf.change_section(self.PATH) keys = kvf.keys() for key in keys: self.path_list[key] = kvf.get(key) # data list keys = kvf.change_section(self.DATA) keys = kvf.keys() for key in keys: self.data_list[key] = kvf.get(key) if self.verbose > 1: for key in self.prog_list.keys(): print('prog: %s = %s' % (key, self.prog_list[key])) for key in self.path_list.keys(): print('path: %s = %s' % (key, self.path_list[key])) for key in self.data_list.keys(): print('data: %s = %s' % (key, self.data_list[key])) self.file_read = True return 0
def __read_control_file(self, fname, section): # arguments: # fname: Control file name. # section: Control section name. cwd = os.getcwd().split(os.sep) siz = len(cwd) top = siz for n in range(siz): if cwd[n] in ['core']: top = n + 1 for n in range(top, siz): prefix = '../' * (siz - n - 1) if os.path.exists(prefix + fname): path = Util.upath(os.path.abspath(prefix + fname)) if self.verbose: print('read: %s' % path) kvf = KvFile(path, verbose=0) num_sections = kvf.read(self.control) self.__set_control_values(kvf, section) """
# dirlist = os.getcwd().split(os.sep) found = False for n in range(len(dirlist)): if dirlist[n] == srctop: found = True break if not found: error.print('no such directory "%s"' % srctop) topdir = os.sep.join(dirlist[0:n]) if found else None # ---------------------------------------------------------------------- # Read name definitions. # kvf = KvFile(inifile, sep='=') count = kvf.read(dic={'TOPDIR': topdir}) if count < 0: error.print(kvf.error()) keys = sorted(kvf.keys()) if verbose: def fixed(name, width): name += ':' if len(name) < width-1: name += ' ' * (width-len(name)) return name print('names defined (%d):' % count) for key in keys: value = util.pathconv(kvf.get(key), 'unix') if os.path.isfile(value): kind = 'file'
sys.exit(0) # if len(args) != 0: parser.error("incorrect number of arguments") # Scene name if options.verbose: print(' inifile:\t%s' % (options.inifile)) # ---------------------------------------------------------------------- # Read init file # mandatory_keys = ['UnityTestScript', 'Python', 'Springhead2', 'SceneList'] kvf = KvFile(options.inifile) if (kvf.read() < 0): sys.exit(-1) if kvf.check(mandatory_keys) != 0: sys.exit(-1) # set defaults defaults = {} spr2root = kvf.get('Springhead2') defaults['UnityProject'] = spr2root + '/src/Unity' defaults['TestRoot'] = spr2root + '/src/UnityTest' defaults['IniFile'] = defaults['TestRoot'] + '/UnityTest.ini' defaults['ScenesDir'] = 'Assets/Scenes' defaults['TestMainLogFile'] = defaults['TestRoot'] + '/log/TestMain.log' for key in defaults.keys(): if kvf.get(key) is None: kvf.set(key, defaults[key])
msg = 'no section defined' else: sections = kvf.sections() msg = '%d section(s) defined: %s' % (count, sections) return msg # ---------------------------------------------------------------------- K = KvFile('') print('Test program for class: %s, Ver %s\n' % (K.clsname, K.version)) ## fname = 'test/KvFileTest.ini' print('-- %s --' % fname) kvf = KvFile(fname, verbose=verbose) count = kvf.read() if count < 0: Print(kvf.error()) sys.exit(-1) Print('file: "%s"' % fname) Print(defined_sections(count, kvf)) Print('----') kvf.show(2) print() # keys = ['Springhead2', 'TestRoot', 'OutFile', 'SceneList'] Print('-- all keys are defined --') Print('keys to check: %s' % keys) if kvf.check(keys) == 0: Print('All keys are defined') else: