Molara-Lab / Molara

Molara is a Python package for the visualization of chemical structures such as molecules or crystals. It provides a graphical user interface for importing structures from output files of popular computational chemistry software as well as for creating custom structures.
GNU General Public License v3.0
11 stars 0 forks source link

Store molara settings files per default in ~/.molara/ #382

Open ab5424 opened 2 months ago

ab5424 commented 2 months ago

It is not a good idea to save the settings files into the installation path of a library.

Michel-Heinz commented 2 months ago

Yes that would be wise! I was asking myself this question this weekend

adrianusler commented 2 months ago

If we create a directory outside of the molara install directory, it would be nice to have an uninstaller that cleans it up, right?

ab5424 commented 2 months ago

A textfile of a few kB shouldn't matter. I don't think other python packages do that either.

Michel-Heinz commented 1 month ago

How can we move the default.json settings file to that dir upon installation?

ab5424 commented 1 month ago

How can we move the default.json settings file to that dir upon installation?

We can store the default in the code and overwrite it with custom settings in the user settings file.

adrianusler commented 1 month ago

Does the "~" operator work in Windows?

ab5424 commented 1 month ago

Does the "~" operator work in Windows?

Sure. Or Path.home().

Michel-Heinz commented 1 month ago

@ab5424 I created a branch for this, can you please change the installation script in order to create the ~/.molara directory upon installation?

ab5424 commented 1 month ago

@Michel-Heinz Why no upon startup? Something like

try:
    with open(...) as file
    settings = json.load(file)
except FileNotFoundError:
    settings = _default_settings
    os.makedirs("~/molara/", exist_ok=True)
    with open("~/molara/settings.json") as file:
        json.dump(settings, file)
Michel-Heinz commented 1 month ago

Okay good idea :+1: