camstream/classes/config.py
2022-02-20 17:21:11 +01:00

18 lines
No EOL
557 B
Python

from configparser import ConfigParser
from static import CONFIG_SECTION, CONFIG_FALLBACK, CONFIG_FREQUENCY, CONFIG_SOURCE, CONFIG_PORT
class Config:
@classmethod
def fromFile(cls, path):
obj = cls()
parser = ConfigParser()
parser.read(path)
obj.source = parser.get(CONFIG_SECTION, CONFIG_SOURCE)
obj.frequency = parser.getint(CONFIG_SECTION, CONFIG_FREQUENCY)
obj.fallback = parser.get(CONFIG_SECTION, CONFIG_FALLBACK)
obj.port = parser.get(CONFIG_SECTION, CONFIG_PORT)
return obj