parent
8bb547cfb4
commit
30c3d61974
@ -0,0 +1,35 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
import yaml
|
||||
|
||||
CONFIG_PATH = "~/.config/smallprint/config.yml"
|
||||
|
||||
config = {
|
||||
"OWM": "Your OpenWeatherMap token goes here",
|
||||
"CITY": "City name",
|
||||
"PRINTER_FILE": "/dev/usb/lp0",
|
||||
"PRINTER_USB_ID": "",
|
||||
"PRINTER_INTERFACE": 0,
|
||||
"PRINTER_ENDPOINT": 0x01,
|
||||
}
|
||||
|
||||
|
||||
def load_config():
|
||||
global config
|
||||
path = Path(CONFIG_PATH).expanduser() # Generate the path to the config file
|
||||
|
||||
if not path.parent.is_dir():
|
||||
os.mkdir(path.parent)
|
||||
|
||||
if not path.is_file():
|
||||
# Create sample file
|
||||
with path.open("w") as cfg_file:
|
||||
cfg_file.write(yaml.dump(config))
|
||||
|
||||
return False
|
||||
|
||||
else:
|
||||
with path.open("r") as cfg_file:
|
||||
config = yaml.load(cfg_file.read(), Loader=yaml.FullLoader)
|
||||
|
||||
return True
|
@ -1,9 +0,0 @@
|
||||
# Simple configuration example
|
||||
|
||||
config = {
|
||||
"OWM": "Your OpenWeatherMap token geos here",
|
||||
"CITY": "City name",
|
||||
"PRINTER_USB_ID": "",
|
||||
"PRINTER_INTERFACE": 0,
|
||||
"PRINTER_ENDPOINT": 0x01,
|
||||
}
|
Loading…
Reference in new issue