A library that is used to remove print statements or converting quotes in python files (if present) in a folder
Project description
wrapup
This is a python library that will help you to remove print statements or convert the quotes of python files based on your given input. You have to input the path of the file or folder, and if the filepath is correct then the changes will be applied to all the python files in the folder or the file whose path was added.
IMPORTANT NOTES TO CONSIDER:
- In case if path of folder is passed as parameter, then the changes will be applied to all the python files (if possible) in the folder.
- No changes will be made to the python file, if by any chance removing print statement or converting the quotes leads to some syntactical errors.
To install the library, type in the command line:
pip install wrapup
Import the package using: import wrapup
Usage:
-
To remove print statements from the files, use rmv_print function which takes the following arguments:
-
filepath: The path of the file to be provided. The path can be relative or absolute. (If not provided; current working directory is considered)
-
rmv_main: (default: False) Boolean value if True then, print statements should be removed from the main function main( ) or under
if __name__ == "__main__":
-
rmv_root: : (default: False) Boolean value if True then, print statements from level 0 indentations will be removed
-
funcs_to_spare: Optional argument of list type that will ignore the functions specified in the list (not removing the print statements from the specified functions)
Return value of the function is a list of path of python files to which changes were applied.
-
-
To convert single quotes to double quotes or vices versa, use convert_quotes function which takes the following arguments:
-
filepath: The path of the file to be provided. The path can be relative or absolute. (If not provided; current working directory is considered)
-
single: (default: True) Boolean value if True, convert all the quotes of the file to single quotes and to double quotes if False
Return value of the function is a list of path of python files to which changes were applied.
The below example will convert all the quotes of all the python files in the folder (subsequently in all sub-folders) to double quotes,
from wrapup import convert_quotes convert_quotes(filepath="folder", single=False)
-
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.