convert python f-string to older and compatible python string
This project provides a tool to convert:
- python expression with f-strings to expression with simple python string
- python files with f-strings to files with simple python strings
- folders of python files with f-strings to folders of python files with simple python strings
- re
- os
- itertools
All are provided by the python 3 installation
old_expr:
s = f"{alpha},{beta},{gamma:06d}"
to new_expr:
s = "{},{},{:06d}".format(alpha, beta, gamma)
from deconverter import deconvert_string
old_expr = 's = f"{alpha},{beta},{gamma:06d}"'
new_expr = deconvert_string(old_expr)
file1.py to file2.py
from deconverter import deconvert_strings_in_file
deconvert_strings_in_file('file1.py', 'file2.py')
folder1 to folder2
from deconverter import deconvert_project
deconvert_project(folder1, folder2)
vod-converter: [https://github.com/umautobots/vod-converter] uses python3.6 f-strings can be converted just by running this script:
python3 deconv_tool.py /full/path/to/vod-converter /full/path/to/vod-converter
After this command vod-converter can be executed with python3.5 which is python3 in older Linux distros.
Users can also import the deconverter.py as a module or use the deconv_tool.py.
There is a python file in tests .in.py and a desired output file .out.py in tests. So if you run vod converter in any of these examples in the file, there should be no diffence with the desired output file.
This repo is still under development/testing, if you find any bugs, please report them to the issues tab.
Thanks for using it!!!