We need config and session data. config is what the user changes. Only read by the app. session is what the app remembers. Read and written by the app.
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from configparser import ConfigParser
|
|
|
|
|
|
class Settings():
|
|
|
|
def __init__(self, config: ConfigParser, session: ConfigParser):
|
|
self.config = config
|
|
self.session = session
|
|
|
|
def set_config(self, section: str, option: str, value: str):
|
|
return self.config.set(section, option, value)
|
|
|
|
def get_config(self, section: str, option: str):
|
|
return self.config.get(section, option)
|
|
|
|
def getint_config(self, section: str, option: str):
|
|
return self.config.getint(section, option)
|
|
|
|
def getboolean_config(self, section: str, option: str):
|
|
return self.config.getboolean(section, option)
|
|
|
|
def set_session(self, section: str, option: str, value: str):
|
|
return self.session.set(section, option, value)
|
|
|
|
def get_session(self, section: str, option: str):
|
|
return self.session.get(section, option)
|
|
|
|
def getint_session(self, section: str, option: str):
|
|
return self.session.getint(section, option)
|
|
|
|
def getboolean_session(self, section: str, option: str):
|
|
return self.session.getboolean(section, option)
|
|
|
|
@staticmethod
|
|
def max_line_length():
|
|
return 4096
|