osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Do I need a parser?


On 01Jul2019 08:23, jos? mariano <jmariano65 at gmail.com> wrote:
>The new software would use a settings files in one "standard" format. I 
>like INI. It's note very powerful, but is easy to read and enough for 
>the matter at hand. I could then use configparser to parse the settings 
>to the main module. One separate module would convert the original 
>format into the new one.

I agree with this. I also like INI for configurations which are not 
complex (==> do not have deeply nested structure).

Another advantage of the configparser module it that has a fine mapping 
interface (like a dict of dicts) _and_ it will write itself out. So if 
your programme can run "bare", you can get it to write out a default INI 
file for the user to modify subsequently.

>The same for the script files. The new format would be plain python, in one separated file, that could be imported into the main file. A separated module would convert the old script format to the new one (python).

I am a bit uncomfortable with fully executable python script files; it 
is far too easy for someone to send you "here is a nice script file" 
which does ANYTHING. They are unsecurable.

It is better (though much more work) to devise a simple script language 
which you parse and turn into some kind of rule system. That way the 
semantics are constrained.

Cheers,
Cameron Simpson <cs at cskk.id.au>