Module my_autopylot.folder39

Functions

def file_get_json_details(path_of_json_file='', section='')

Description

Returns all the details of the given section in a dictionary

Args

path_of_json_file (str) : Location of the json file. section (str) : section of the json file.

Returns

[status, data] status (bool) - True if the file is renamed successfully. data - The contents of the JSON file.

def file_rename(old_file_path='', new_file_name='', print_status=False)

Description

Renames the given file name to new file name with same extension

Args

old_file_path (str) : Location of the file. new_file_name (str) : New file name. print_status (bool) : True if the status is to be printed.

Returns

[status, data] status (bool) - True if the file is renamed successfully. data (List) - list of all the contents of the text file.

def folder_create(strFolderPath='')

Description

while making leaf directory if any intermediate-level directory is missing, folder_create() method will create them all.

Args

folderPath (str) : path to the folder where the folder is to be created.

Returns

[status] status (bool) - True if the folder is created successfully.

def folder_create_text_file(textFolderPath='', txtFileName='', custom=False)

Description

Creates Text file in the given path. Internally this uses folder_create() method to create folders if the folder/s does not exist. automatically adds txt extension if not given in textFilePath.

Args

textFolderPath (str) : path to the folder where the text file is to be created. txtFileName (str) : name of the text file. custom (bool) : True if the text file name is to be customised.

Returns

[status] status (bool) - True if the file is created successfully.

def folder_delete_all_files(fullPathOfTheFolder='', file_extension_without_dot='all', print_status=False)

Description

Deletes all the files of the given folder

Args

fullPathOfTheFolder (str) : Location of the folder. extension (str) : extention of the file. by default all the files will be deleted inside the given folder regarless of the extension.

Returns

[status] status (bool) - True if the file is deleted successfully.

def folder_delete_file_or_folder(file_or_folder_path: str = '', print_status=False)

Description

Deletes single file or entire folder with all its contents.

Args

file_or_folder_path (str) : Location of the file or folder.

Returns

[status] status (bool) - True if the file is deleted successfully.

def folder_get_all_filenames_as_list(strFolderPath='', extension='all')

Description

Get all the files of the given folder in a list.

Args

strFolderPath (str) : Location of the folder. extension (str) : extention of the file. by default all the files will be listed regarless of the extension.

Returns

[status, data] status (bool) - True if the file is read successfully. data (List) - list of all the files in the folder.

def folder_read_text_file(txt_file_path='')

Description

Reads from a given text file and returns entire contents as a single list

Args

txt_file_path (str) : path to the text file.

Returns

[status, data] status (bool) - True if the file is read successfully. data (List) - list of all the contents of the text file.

def folder_write_text_file(txt_file_path='', contents='')

Description

Writes to a given text file and returns entire contents as a single list

Args

txt_file_path (str) : path to the text file. contents (str) : contents to be written to the text file.

Returns

[status, data] status (bool) - True if the file is read successfully. data (List) - list of all the contents of the text file.