def _remove_doxt(): # check main directory cwd_doxt_list = list_filter_files_cwd(".doxt") # check for a templates directory if dir_exists('templates'): templates_dir_doxt_list = list_filter_files(".doxt", "templates") else: templates_dir_doxt_list = [] # remove template files from the working directory if len(cwd_doxt_list) > 0: for doxt_file in cwd_doxt_list: try: remove(doxt_file) stdout("[-] doxx: -- " + doxt_file + " ... removed") except Exception as e: stderr("[!] doxx: Unable to remove the file " + doxt_file + "'. Error: " + str(e), exit=0) # remove any template files from the templates directory if len(templates_dir_doxt_list) > 0: for doxt_file in templates_dir_doxt_list: new_doxt_path = make_path('templates', doxt_file) remove(new_doxt_path) stdout("[-] doxx: -- " + new_doxt_path + " ... removed") # if there are files still remaining in the templates directory, leave it # otherwise, remove the templates directory as well if dir_exists('templates'): remaining_template_file_list = list_all_files('templates') # get the remaining non-.doxt files in the directory if len(remaining_template_file_list) > 0: pass # do nothing, skip the removal of the 'templates' directory from the project because other files are present in it else: try: rmtree('templates') stdout("[-] doxx: -- templates (directory) ... removed") except Exception as e: stderr("[!] doxx: Unable to remove the 'templates' directory. Error: " + str(e), exit=1)
def test_sys_list_filter_files_nomatch(self): """Test list of filtered files from explicitly assigned directory, no files that match""" test_list = system.list_filter_files(".rb", self.dir_file_path) self.assertEqual(test_list, []) #should return empty list
def test_sys_list_filter_files(self): """Test list of filtered files from an explicitly assigned directory""" test_list = system.list_filter_files(".txt", self.dir_file_path) self.assertEqual(test_list, ["file1.txt", "file2.txt", "metadata.txt"])
def test_sys_list_filter_files_nomatch(self): """Test list of filtered files from explicitly assigned directory, no files that match""" test_list = system.list_filter_files(".rb", self.dir_file_path) self.assertEqual(test_list, []) #should return empty list
def test_sys_list_filter_files(self): """Test list of filtered files from an explicitly assigned directory""" test_list = system.list_filter_files(".txt", self.dir_file_path) self.assertEqual(test_list, ["file1.txt", "file2.txt", "metadata.txt"])