forked from Trygve/otime
29 lines
899 B
Python
29 lines
899 B
Python
|
from yaml import load, dump
|
||
|
try:
|
||
|
from yaml import CLoader as Loader, CDumper as Dumper
|
||
|
except ImportError:
|
||
|
from yaml import Loader, Dumper
|
||
|
|
||
|
from copy import deepcopy
|
||
|
import otime
|
||
|
|
||
|
# Disse funksjonene er for å kunne lese og skrive seperate config, mtr og databasefiler.
|
||
|
def write_config(event, file_path):
|
||
|
output_event = deepcopy(event)
|
||
|
output_event.runners = []
|
||
|
output_event.card_dumps = []
|
||
|
with open(file_path, 'w') as f:
|
||
|
dump(output_event, f)
|
||
|
|
||
|
def write_card_dumps(event, file_path):
|
||
|
card_dumps = deepcopy(event.card_dumps)
|
||
|
with open(file_path, 'w') as f:
|
||
|
dump(card_dumps, f)
|
||
|
|
||
|
def event_from_config_and_card_dumps(config_path, mtr_path):
|
||
|
with open(mtr_path, 'r') as f:
|
||
|
card_dumps = load(f, Loader=Loader)
|
||
|
with open(config_path, 'r') as f:
|
||
|
event = load(f, Loader=Loader)
|
||
|
event.card_dumps = card_dumps
|
||
|
return event
|