jferard / py4lo

Py4LO is a simple toolkit to help you write and include Python scripts in LibreOffice Calc spreadsheets.
GNU General Public License v3.0
5 stars 2 forks source link

Merge lib versions #3

Closed jferard closed 7 years ago

jferard commented 7 years ago

It will be difficult to maintain files for each version of Python. It's more easy to use directives to separate Python 2 code from Python 3 code.

Note : py4lo uses Python 3 to pack scripts in ods files, but thoses scripts may be Python 2 scripts, e.g. for old versions of LO/OO. The version has to be specified with the python_version key of the toml file. The format has to be major.minor (currently, it's just major).

What would those directives like ? Well, just like the good old C preprocessor directive :

# py4lo: if python_version < 2.7
... some code ...
# py4lo: elif python_version < 3.0
... some other code ...
# py4lo: else
... some other code ...
# py4lo: endif

Parsing with shlex, a code for comparators. It has to be simple : no imbrication allowed.

jferard commented 7 years ago

Done. It remains simple (just a yes/no stack), but imbrications are allowed.

After parsing, skipped lines start with ###.