def run(self): if self.app_name == None: i = InfoCompiler(None) data_container = i.getSetupFileInfo() else: i = InfoCompiler(self.app_name) data_container = i.getUserInfo() db = DirectoryBuilder(data_container) db.build() fb = FileBuilder(data_container) if fb.build_and_write(): # file writes were successful main_script_path = make_path(data_container.app_name, 'lib', data_container.app_name, 'app.py') settings_path = make_path(data_container.app_name, 'lib', data_container.app_name, 'settings.py') command_dir = make_path(data_container.app_name, 'lib', data_container.app_name, 'commands') setuppy_path = make_path(data_container.app_name, 'setup.py') print(" ") print(data_container.app_name + " was successfully built.") print(" ") print("-----") print("Main application script: " + main_script_path) print("Settings file: " + settings_path) print("Commands directory: " + command_dir) print("setup.py file: " + setuppy_path) print("-----") print(" ") print("Use 'python setup.py develop' from the top level of your project and you can begin testing your application with the executable, " + data_container.app_name) exit_success()
def unpack_and_get_keypath(self, project_path): # unpack the archive and get the root directory from the archive root_directory = unpack_run(project_path) if root_directory is None or root_directory == "": key_path = None try: for root, dirs, files in os.path.walk(cwd()): for test_file in files: if test_file == "project.yaml": key_path = make_path(root, dirs, test_file) except Exception as e: stderr("[!] doxx: Unable to locate the 'project.yaml' project settings file in your unpacked archive. Error: " + str(e), exit=1) if key_path is None: # can't find key path stderr("[!] doxx: Unable to locate the 'project.yaml' project settings file in your unpacked archive.", exit=1) else: return key_path # return key path to the calling method else: if root_directory == ".": key_path = 'project.yaml' # in current working directory else: # make the path to the key file root_directory = make_path(cwd(), root_directory) key_path = make_path(root_directory, 'project.yaml') # return the key path to the calling method return key_path
def test_escape_tar_encrypt(self): try: # change to the sub test directory for tar tests os.chdir("testdir11") command = "crypto --tar testtar" child = self.submit_same_esc_passphrase(command) self.assertTrue(file_exists("testtar.tar.crypt")) # test new encrypted archive exists child.close() shutil.move('testtar', 'testtar_temp') decrypt_command = "decrypto testtar.tar.crypt" child = self.submit_same_esc_passphrase(decrypt_command) self.assertTrue(dir_exists(make_path("testtar"))) # test decrypted tar archive exists self.assertTrue(file_exists(make_path("testtar", "esc_test.txt"))) self.assertTrue(file_exists(make_path("testtar", "esc_test2.txt"))) child.close() # cleanup os.remove(make_path("testtar.tar.crypt")) # remove encrypted archive shutil.rmtree(make_path("testtar")) # remove the decrypted, unpacked directory shutil.move('testtar_temp', 'testtar') # move the original tar testing dir back to original path except Exception as e: # return to top level testing directory os.chdir(self.cwd) raise e finally: # return to top level testing directory os.chdir(self.cwd)
def run(self): if self.app_name == None: i = InfoCompiler(None) data_container = i.getSetupFileInfo() else: i = InfoCompiler(self.app_name) data_container = i.getUserInfo() db = DirectoryBuilder(data_container) db.build() fb = FileBuilder(data_container) if fb.build_and_write(): # file writes were successful main_script_path = make_path(data_container.app_name, 'lib', data_container.app_name, 'app.py') settings_path = make_path(data_container.app_name, 'lib', data_container.app_name, 'settings.py') command_dir = make_path(data_container.app_name, 'lib', data_container.app_name, 'commands') setuppy_path = make_path(data_container.app_name, 'setup.py') print(" ") print(data_container.app_name + " was successfully built.") print(" ") print("-----") print("Main application script: " + main_script_path) print("Settings file: " + settings_path) print("Commands directory: " + command_dir) print("setup.py file: " + setuppy_path) print("-----") print(" ") print( "Use 'python setup.py develop' from the top level of your project and you can begin testing your application with the executable, " + data_container.app_name) exit_success()
def test_escape_tar_encrypt(self): try: # change to the sub test directory for tar tests os.chdir("testdir11") command = "crypto --tar testtar" child = self.submit_same_esc_passphrase(command) self.assertTrue(file_exists( "testtar.tar.crypt")) # test new encrypted archive exists child.close() shutil.move('testtar', 'testtar_temp') decrypt_command = "decrypto testtar.tar.crypt" child = self.submit_same_esc_passphrase(decrypt_command) self.assertTrue(dir_exists( make_path("testtar"))) # test decrypted tar archive exists self.assertTrue(file_exists(make_path("testtar", "esc_test.txt"))) self.assertTrue(file_exists(make_path("testtar", "esc_test2.txt"))) child.close() # cleanup os.remove( make_path("testtar.tar.crypt")) # remove encrypted archive shutil.rmtree(make_path( "testtar")) # remove the decrypted, unpacked directory shutil.move( 'testtar_temp', 'testtar' ) # move the original tar testing dir back to original path except Exception as e: # return to top level testing directory os.chdir(self.cwd) raise e finally: # return to top level testing directory os.chdir(self.cwd)
def setUp(self): self.sysfilepath = make_path("testfiles", "testdir", "systest.txt") self.sysdirpath = make_path("testfiles", "testdir") self.bogusfilepath = make_path("testfiles", "testdir", "bogusfile.text") self.metafilepath = make_path("testfiles", "keep", "metadata.txt") self.dir_file_path = make_path("testfiles", "keep") self.dir_file_list = ["file1.txt", "file2.txt", "file3.py", "metadata.txt", "test.tar.gz"] FileWriter(self.sysfilepath).write("test")
def test_decrypt_singlefile_ascfile(self): command = "decrypto testdir5/test3.txt.asc" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir5", "test3.txt"))) child.close() # cleanup os.remove(make_path("testdir5", "test3.txt"))
def test_singlefile_encrypt_jpg(self): command = "crypto testdir1/tiger.jpg" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir1", "tiger.jpg.crypt"))) child.close() # cleanup os.remove(make_path("testdir1", "tiger.jpg.crypt"))
def test_singlefile_encrypt_gif(self): command = "crypto testdir1/banana.gif" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir1", "banana.gif.crypt"))) child.close() # cleanup os.remove(make_path("testdir1", "banana.gif.crypt"))
def test_singlefile_encrypt_dotfile(self): command = "crypto testdir1/.testfile" child = self.submit_same_passphrase(command) child.close() self.assertTrue(file_exists(make_path("testdir1", ".testfile.crypt"))) # cleanup os.remove(make_path("testdir1", ".testfile.crypt"))
def test_unicode_passphrase_single_file_encrypt(self): command = "crypto testdir7/uni_test.txt" child = self.submit_same_uni_passphrase(command) self.assertTrue(file_exists(make_path("testdir7", "uni_test.txt.crypt"))) #test that new encrypted file exists child.close() # cleanup os.remove(make_path("testdir7","uni_test.txt.crypt"))
def test_asciifile_encrypt_png(self): command = "crypto -a testdir1/star.png" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir1", "star.png.crypt"))) child.close() # cleanup os.remove(make_path("testdir1", "star.png.crypt"))
def test_singlefile_encrypt_txt(self): command = "crypto testdir1/test1.txt" child = self.submit_same_passphrase(command) #stdout_string = child.logfile.getvalue() self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt"))) #test that new encrypted file exists child.close() # cleanup os.remove(make_path("testdir1","test1.txt.crypt"))
def test_multifile_goodbad_filepath(self): command = "crypto testdir1/test1.txt testdir1/bogusfile.txt" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt"))) self.assertFalse(file_exists(make_path("testdir1", "bogusfile.txt.crypt"))) #should not be present when original does not exist child.close() # cleanup os.remove(make_path("testdir1", "test1.txt.crypt"))
def build(self): top_level_dir = self.data_container.app_name second_level_dirs = ['docs', 'lib', 'tests'] lib_subdir = make_path(self.data_container.app_name, 'commands') for xdir in second_level_dirs: make_dirs(make_path(top_level_dir, xdir)) make_dirs(make_path(top_level_dir, 'lib', lib_subdir))
def test_asciifile_encrypt_multiple_files(self): command = "crypto --armor testdir1/.testfile testdir1/test1.txt" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir1", ".testfile.crypt"))) self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt"))) child.close() # cleanup os.remove(make_path("testdir1", ".testfile.crypt")) os.remove(make_path("testdir1", "test1.txt.crypt"))
def test_multifile_encrypt_txt(self): command = "crypto testdir1/test1.txt testdir2/test1.txt" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt"))) #test that new encrypted file exists self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt"))) child.close() # cleanup os.remove(make_path("testdir1","test1.txt.crypt")) os.remove(make_path("testdir2","test1.txt.crypt"))
def test_multifile_encrypt_image(self): command = "crypto testdir1/star.png testdir1/tiger.jpg" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir1", "star.png.crypt"))) self.assertTrue(file_exists(make_path("testdir1", "tiger.jpg.crypt"))) child.close() # cleanup os.remove(make_path("testdir1", "star.png.crypt")) os.remove(make_path("testdir1", "tiger.jpg.crypt"))
def test_multifile_encrypt_withdotfile(self): command = "crypto testdir1/test1.txt testdir1/.testfile" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir1", "test1.txt.crypt"))) self.assertTrue(file_exists(make_path("testdir1", ".testfile.crypt"))) #should encrypt an explicitly included dotfile child.close() # cleanup os.remove(make_path("testdir1", "test1.txt.crypt")) os.remove(make_path("testdir1", ".testfile.crypt"))
def test_singledir_file_encrypt(self): command = "crypto testdir2" child = self.submit_same_passphrase(command) child.close() self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt"))) self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt"))) self.assertFalse(file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt"))) os.remove(make_path("testdir2","test1.txt.crypt")) os.remove(make_path("testdir2","test2.txt.crypt"))
def test_decrypt_singlegpgfile_overwrite_shortflag(self): command = "decrypto -o testdir6/test2.txt.gpg" child = pexpect.spawn(command) child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.expect("'testdir6/test2.txt.gpg' decrypted to 'testdir6/test2.txt'") child.close() self.assertTrue(file_exists(make_path("testdir6", "test2.txt"))) # confirm decrypted file present self.assertFalse(file_exists(make_path("testdir6", "test2.txt.tmp"))) # confirm tmp file erased
def test_multifile_encrypt_withencryptedfile(self): command = "crypto testdir2/test1.txt testdir2/test2.txt testdir2/testcrypt.txt.crypt" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt"))) self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt"))) self.assertFalse(file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt"))) # assert that did not encrypt previously encrypted file child.close() # cleanup os.remove(make_path("testdir2", "test1.txt.crypt")) os.remove(make_path("testdir2", "test2.txt.crypt"))
def test_unicode_passphrase_single_file_encrypt(self): command = "crypto testdir7/uni_test.txt" child = self.submit_same_uni_passphrase(command) self.assertTrue( file_exists(make_path( "testdir7", "uni_test.txt.crypt"))) #test that new encrypted file exists child.close() # cleanup os.remove(make_path("testdir7", "uni_test.txt.crypt"))
def setUp(self): self.sysfilepath = make_path("testfiles", "testdir", "systest.txt") self.sysdirpath = make_path("testfiles", "testdir") self.bogusfilepath = make_path("testfiles", "testdir", "bogusfile.text") self.metafilepath = make_path("testfiles", "keep", "metadata.txt") self.dir_file_path = make_path("testfiles", "keep") self.dir_file_list = [ "file1.txt", "file2.txt", "file3.py", "metadata.txt", "test.tar.gz" ] FileWriter(self.sysfilepath).write("test")
def test_multidir_bad_single_dir_path(self): command = "crypto bogusdir1 testdir2" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt"))) self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt"))) self.assertFalse(file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt"))) # cleanup os.remove(make_path("testdir2","test1.txt.crypt")) os.remove(make_path("testdir2","test2.txt.crypt"))
def test_decrypt_singlefile_nosuffix(self): command = "decrypto testdir5/test5" child = pexpect.spawn(command) child.expect("Could not confirm that the requested file is encrypted based upon the file type. Attempting decryption. Keep your fingers crossed...") child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.interact() self.assertTrue(file_exists(make_path("testdir5", "test5.decrypt"))) child.close() # cleanup os.remove(make_path("testdir5", "test5.decrypt"))
def test_asciifile_single_directory(self): command = "crypto --armor testdir2" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt"))) self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt"))) self.assertFalse( file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt")) ) # test that did not encrypt previously encrypted file child.close() # cleanup os.remove(make_path("testdir2", "test1.txt.crypt")) os.remove(make_path("testdir2", "test2.txt.crypt"))
def test_multidir_bad_single_dir_path(self): command = "crypto bogusdir1 testdir2" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir2", "test1.txt.crypt"))) self.assertTrue(file_exists(make_path("testdir2", "test2.txt.crypt"))) self.assertFalse( file_exists(make_path("testdir2", "testcrypt.txt.crypt.crypt"))) # cleanup os.remove(make_path("testdir2", "test1.txt.crypt")) os.remove(make_path("testdir2", "test2.txt.crypt"))
def test_escape_passphrase_with_unicode_chars_and_spaces(self): command = "crypto testdir11/esc_test.txt" child = pexpect.spawn(command) child.expect("Please enter your passphrase: ") child.sendline("$@`!\%^&*()_ -+=3'A\\\ 'M'\W<>?,./|[]{}œœ") child.expect("Please enter your passphrase again: ") child.sendline("$@`!\%^&*()_ -+=3'A\\\ 'M'\W<>?,./|[]{}œœ") child.interact() self.assertTrue(file_exists(make_path("testdir11", "esc_test.txt.crypt"))) # test new encrypted file exists child.close() # cleanup os.remove(make_path("testdir11", "esc_test.txt.crypt"))
def test_decrypt_multifile_bad_filepath(self): command = "decrypto testdir5/bogusfile.txt.crypt testdir5/test1.txt.crypt" child = pexpect.spawn(command) child.expect("'testdir5/bogusfile.txt.crypt' does not appear to be an existing file or directory. Aborting decryption attempt for this request.") child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.interact() child.close() self.assertTrue(file_exists(make_path("testdir5", "test1.txt"))) # cleanup os.remove(make_path("testdir5", "test1.txt"))
def test_escape_directory_encrypt_decrypt(self): command = "crypto testdir11" child = self.submit_same_esc_passphrase(command) self.assertTrue( file_exists(make_path( "testdir11", "esc_test.txt.crypt"))) # test new encrypted file exists self.assertTrue( file_exists(make_path( "testdir11", "esc_test2.txt.crypt"))) # test new encrypted file exists child.close() os.rename("testdir11/esc_test.txt.crypt", "testdir11/SUBTEST1.txt.crypt") os.rename("testdir11/esc_test2.txt.crypt", "testdir11/SUBTEST2.txt.crypt") decrypt_command = "decrypto testdir11" child = self.submit_same_esc_passphrase(decrypt_command) self.assertTrue(file_exists(make_path( "testdir11", "SUBTEST1.txt"))) # test decrypted file exists self.assertTrue(file_exists(make_path( "testdir11", "SUBTEST2.txt"))) # test decrypted file exists child.close() # cleanup os.remove(make_path("testdir11", "SUBTEST1.txt")) os.remove(make_path("testdir11", "SUBTEST1.txt.crypt")) os.remove(make_path("testdir11", "SUBTEST2.txt")) os.remove(make_path("testdir11", "SUBTEST2.txt.crypt"))
def test_decrypt_singlegpgfile_overwrite_shortflag(self): command = "decrypto -o testdir6/test2.txt.gpg" child = pexpect.spawn(command) child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.expect( "'testdir6/test2.txt.gpg' decrypted to 'testdir6/test2.txt'") child.close() self.assertTrue(file_exists(make_path( "testdir6", "test2.txt"))) # confirm decrypted file present self.assertFalse(file_exists(make_path( "testdir6", "test2.txt.tmp"))) # confirm tmp file erased
def setUp(self): self.template_path = make_path("testfiles", "keep", "inktests", "test_setup_template.py") self.template_path2 = make_path("testfiles", "keep", "inktests", "test_setup_template2.py") self.standard_path = make_path("testfiles", "keep", "inktests", "test_setup_standard.py") self.key_dictionary = { 'appname': 'test', 'description': 'A cool app', 'url': 'http://test.com', 'license': 'MIT', 'author': 'Christopher Simpkins', 'email': '*****@*****.**' }
def test_decrypt_multifile_overwrite_file(self): command = "decrypto testdir5/test1.txt.crypt testdir6/test1.txt.crypt" child = pexpect.spawn(command) child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.expect("The file path 'testdir6/test1.txt' already exists. This file was not decrypted") child.close() self.assertTrue(file_exists(make_path("testdir5", "test1.txt"))) self.assertTrue(file_exists(make_path("testdir6", "test1.txt"))) self.assertFalse(file_exists(make_path("testdir6", "test1.txt.tmp"))) # confirm that there is no .tmp file #cleanup os.remove(make_path("testdir5", "test1.txt"))
def test_decrypt_multifile_overwrite_shortflag(self): command = "decrypto -o testdir5/test1.txt.crypt testdir6/test1.txt.crypt" child = pexpect.spawn(command) child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.interact() child.close() self.assertTrue(file_exists(make_path("testdir5", "test1.txt"))) self.assertTrue(file_exists(make_path("testdir6", "test1.txt"))) self.assertFalse(file_exists(make_path("testdir6", "test1.txt.tmp"))) # confirm that there is no .tmp file #cleanup os.remove(make_path("testdir5", "test1.txt"))
def test_decrypt_singlefile_nosuffix(self): command = "decrypto testdir5/test5" child = pexpect.spawn(command) child.expect( "Could not confirm that the requested file is encrypted based upon the file type. Attempting decryption. Keep your fingers crossed..." ) child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.interact() self.assertTrue(file_exists(make_path("testdir5", "test5.decrypt"))) child.close() # cleanup os.remove(make_path("testdir5", "test5.decrypt"))
def test_escape_passphrase_with_unicode_chars_and_spaces(self): command = "crypto testdir11/esc_test.txt" child = pexpect.spawn(command) child.expect("Please enter your passphrase: ") child.sendline("$@`!\%^&*()_ -+=3'A\\\ 'M'\W<>?,./|[]{}œœ") child.expect("Please enter your passphrase again: ") child.sendline("$@`!\%^&*()_ -+=3'A\\\ 'M'\W<>?,./|[]{}œœ") child.interact() self.assertTrue( file_exists(make_path( "testdir11", "esc_test.txt.crypt"))) # test new encrypted file exists child.close() # cleanup os.remove(make_path("testdir11", "esc_test.txt.crypt"))
def test_escape_passphrase_single_file_encrypt_decrypt(self): command = "crypto testdir11/esc_test.txt" child = self.submit_same_esc_passphrase(command) self.assertTrue(file_exists(make_path("testdir11", "esc_test.txt.crypt"))) # test new encrypted file exists child.close() os.rename("testdir11/esc_test.txt.crypt", "testdir11/SUBTEST.txt.crypt") decrypt_command = "decrypto testdir11/SUBTEST.txt.crypt" child = self.submit_same_esc_passphrase(decrypt_command) self.assertTrue(file_exists(make_path("testdir11", "SUBTEST.txt"))) # test decrypted file exists child.close() # cleanup os.remove(make_path("testdir11", "SUBTEST.txt")) os.remove(make_path("testdir11", "SUBTEST.txt.crypt"))
def test_decrypt_singledir_multiplefiles(self): command = "decrypto testdir5" child = pexpect.spawn(command) child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.expect( "'testdir5/test1.txt.crypt' decrypted to 'testdir5/test1.txt'") child.expect( "'testdir5/test2.txt.gpg' decrypted to 'testdir5/test2.txt'") child.expect( "'testdir5/test3.txt.asc' decrypted to 'testdir5/test3.txt'") child.expect( "The file path 'testdir5/test4.txt' already exists. This file was not decrypted." ) child.interact() self.assertTrue(file_exists(make_path("testdir5", "test1.txt"))) self.assertTrue(file_exists(make_path("testdir5", "test2.txt"))) self.assertTrue(file_exists(make_path("testdir5", "test3.txt"))) self.assertFalse(file_exists(make_path( "testdir5", "test5.decrypt"))) # should not decrypt this file child.close() #cleanup os.remove(make_path("testdir5", "test1.txt")) os.remove(make_path("testdir5", "test2.txt")) os.remove(make_path("testdir5", "test3.txt"))
def test_crypto_tar_commandline_tararchive(self): command = "crypto --tar testdir9/tar_dir" child = pexpect.spawn(command) child.expect("Please enter your passphrase: ") child.sendline("test") child.expect("Please enter your passphrase again: ") child.sendline("test") child.expect( "\r\ntestdir9/tar_dir.tar.crypt was generated from testdir9/tar_dir.tar\r\n" ) self.assertTrue(file_exists(make_path('testdir9', 'tar_dir.tar.crypt')) ) # confirm that the encrypted tar file is there self.assertFalse(file_exists( make_path('testdir9', 'tar_dir.tar'))) # confirm that the tar file is removed self.assertTrue(dir_exists(make_path( 'testdir9', 'tar_dir'))) # confirm that the test directory is not removed child.close() os.remove('testdir9/tar_dir.tar.crypt')
def test_decrypt_multifile_same_directory(self): command = "decrypto testdir5/test1.txt.crypt testdir5/test2.txt.gpg testdir5/test3.txt.asc" child = self.submit_same_passphrase(command) self.assertTrue(file_exists(make_path("testdir5", "test1.txt"))) self.assertTrue(file_exists(make_path("testdir5", "test2.txt"))) self.assertTrue(file_exists(make_path("testdir5", "test3.txt"))) child.close() #cleanup os.remove(make_path("testdir5", "test1.txt")) os.remove(make_path("testdir5", "test2.txt")) os.remove(make_path("testdir5", "test3.txt"))
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)