Added configuration file class
This commit is contained in:
37
classes/utils/configs.py
Normal file
37
classes/utils/configs.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Created on Fri Jan 8 10:26:56 2021
|
||||||
|
|
||||||
|
@author: neal
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import system
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
class ArrowHandle():
|
||||||
|
def __init__(self, icon):
|
||||||
|
self.pathfilename = "./" + "config.yaml"
|
||||||
|
self.config = []
|
||||||
|
|
||||||
|
def find_config(self, path=".", file="config.yaml"):
|
||||||
|
# local first
|
||||||
|
if path.isfile(file):
|
||||||
|
self.pathfilename = file
|
||||||
|
return 1
|
||||||
|
elif path.isfile(path + "/" + file):
|
||||||
|
self.pathfilename = path + "/" + file
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
print("Config file not found:", file)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def read_config(self, path=".", file="config.yaml"):
|
||||||
|
if self.find_config(path, file):
|
||||||
|
with open(self.pathfilename) as f:
|
||||||
|
self.config = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
|
f.close()
|
||||||
|
else:
|
||||||
|
self.config= []
|
||||||
|
return self.config
|
||||||
@ -25,7 +25,7 @@ config_file = "vcones.yaml"
|
|||||||
# audio stuff
|
# audio stuff
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
vc_path = os.path.realpath(__file__)
|
vc_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
def play_sound(file):
|
def play_sound(file):
|
||||||
wave_obj = sa.WaveObject.from_wave_file(vc_path + "/" + file)
|
wave_obj = sa.WaveObject.from_wave_file(vc_path + "/" + file)
|
||||||
|
|||||||
Reference in New Issue
Block a user