make the GUI script YAML-compatible

This commit is contained in:
k4yt3x 2019-11-16 01:50:41 -05:00
parent dce778b3bf
commit 95416f68a8

View File

@ -4,9 +4,9 @@
Creator: Video2X GUI Creator: Video2X GUI
Author: K4YT3X Author: K4YT3X
Date Created: July 27, 2019 Date Created: July 27, 2019
Last Modified: November 15, 2019 Last Modified: November 16, 2019
Description: GUI for Video2X Description: A simple GUI for Video2X made with tkinter.
""" """
# local imports # local imports
@ -18,14 +18,16 @@ from tkinter import *
from tkinter import messagebox from tkinter import messagebox
from tkinter import ttk from tkinter import ttk
from tkinter.filedialog import * from tkinter.filedialog import *
import json
import pathlib import pathlib
import tempfile import tempfile
import threading import threading
import time import time
import yaml
VERSION = '1.1.2' VERSION = '1.1.2'
VIDEO2X_CONFIG = pathlib.Path(sys.argv[0]).parent.absolute() / 'video2x.yaml'
LEGAL_INFO = f'''Video2X GUI Version: {VERSION} LEGAL_INFO = f'''Video2X GUI Version: {VERSION}
Author: K4YT3X Author: K4YT3X
License: GNU GPL v3 License: GNU GPL v3
@ -268,7 +270,7 @@ class Video2xGui():
begin_time = time.time() begin_time = time.time()
# read configuration file # read configuration file
config = read_config('video2x.json') config = read_config(VIDEO2X_CONFIG)
config = absolutify_paths(config) config = absolutify_paths(config)
input_file = pathlib.Path(self.input_file.get()) input_file = pathlib.Path(self.input_file.get())
@ -414,10 +416,10 @@ class Video2xGui():
def read_config(config_file): def read_config(config_file):
""" Reads configuration file """ Reads configuration file
Returns a dictionary read by JSON. Returns a dictionary read by parsing Video2X config.
""" """
with open(config_file, 'r') as raw_config: with open(config_file, 'r') as raw_config:
config = json.load(raw_config) config = yaml.load(raw_config, Loader=yaml.FullLoader)
return config return config