def getSetupFileInfo(self): files = system.list_all_files_cwd() if len(files) > 0: setupfile_exists = False for a_file in files: if 'naked.yaml' == a_file.lower(): # accepts any permutation of upper/lower case 'naked.yaml' print("Detected a Naked project YAML setup file (" + a_file + ").") setupfile_exists = True fr = nfile.FileReader(a_file) the_yaml = fr.read_utf8() self.parseYaml(the_yaml) if setupfile_exists: if self.confirmData(): return self.data else: print("Aborted the project build.") if python.is_py2(): response = raw_input("Would you like to modify this information? (y/n) ") else: response = input("Would you like to modify this information? (y/n) ") if response in ['y', 'Y', 'Yes', 'YES', 'yes']: self.displayed_info_flag = 1 self.data.app_name = None return self.getUserInfo() # return the result from the getUserInfo command to the calling method else: sys.exit(0) else: return self.getUserInfo() # there are files but no setup file, use the manual entry method else: return self.getUserInfo() # there are no files in the directory, use the manual entry method
def test_sys_list_all_files_cwd(self): """Test list of all files from current working directory""" curr_dir = os.getcwd() #capture current directory os.chdir(self.dir_file_path) #change to test directory test_list = system.list_all_files_cwd() os.chdir(curr_dir) #return to previous directory for remaining tests self.assertEqual(test_list, self.dir_file_list)
def getSetupFileInfo(self): files = system.list_all_files_cwd() if len(files) > 0: setupfile_exists = False for a_file in files: if 'naked.yaml' == a_file.lower( ): # accepts any permutation of upper/lower case 'naked.yaml' print("Detected a Naked project YAML setup file (" + a_file + ").") setupfile_exists = True fr = nfile.FileReader(a_file) the_yaml = fr.read_utf8() self.parseYaml(the_yaml) if setupfile_exists: if self.confirmData(): return self.data else: print("Aborted the project build.") if python.is_py2(): response = raw_input( "Would you like to modify this information? (y/n) " ) else: response = input( "Would you like to modify this information? (y/n) " ) if response in ['y', 'Y', 'Yes', 'YES', 'yes']: self.displayed_info_flag = 1 self.data.app_name = None return self.getUserInfo( ) # return the result from the getUserInfo command to the calling method else: sys.exit(0) else: return self.getUserInfo( ) # there are files but no setup file, use the manual entry method else: return self.getUserInfo( ) # there are no files in the directory, use the manual entry method