paulvangentcom / python_corona_simulation

An agent-based simulation of corona and other viruses in python
GNU General Public License v3.0
292 stars 76 forks source link

implemented read_from_file(filename) in config.py #38

Closed raymond-van closed 5 months ago

raymond-van commented 3 years ago

I noticed _read_fromfile(path) was on your TODO list so I went ahead and implemented it. We can now easily create custom configurations for more unique simulations.

_read_fromfile reads through the plaintext file custom_config.txt and parses each line and sets the corresponding configuration variable.

Great work on this repo and sorry on behalf of my fellow students for bombarding your repo with endless PRs.

paulvangentcom commented 3 years ago

Thanks Raymond, for adding functionality. I've been closing PRs left and right since not much actual functionality is added or they break things (although I've learned a thing or two glossing through them).

I like your implementation, but was thinking to implement the config through python's configparser from the stdlib.

If you like and have the time, could you consider adapting your PR to reflect this? Not much change should be needed and it will give some more functionality like sections which could be of use later. If you don't have the time, don't worry, in that case I'll update your PR later in the week.

Cheers

raymond-van commented 3 years ago

Hey Paul,

Thanks for getting back!

I gave it a go at implementing _read_fromfile using configparser. I replaced the custom_config.txt file with an .ini file that contains sections. The code in _read_fromfile is essentially the same, just reworked so that it works with .ini files.

Let me know if this is what you were looking for. If not, I’ll try to fix it when I get the chance.