Generic info fields input into 'custom'.

This commit is contained in:
lwark
2024-09-24 15:23:51 -05:00
parent 7bc356e205
commit b0e9f9996d
13 changed files with 898 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
"""
Constructs main application.
"""
import yaml
from PyQt6.QtWidgets import (
QTabWidget, QWidget, QVBoxLayout,
QHBoxLayout, QScrollArea, QMainWindow,
@@ -10,8 +11,9 @@ from PyQt6.QtGui import QAction
from pathlib import Path
from markdown import markdown
from __init__ import project_path
from tools import check_if_app, Settings, Report, jinja_template_loading
from .functions import select_save_file
from datetime import date
from .pop_ups import HTMLPop
from .misc import LogParser
@@ -74,6 +76,7 @@ class App(QMainWindow):
helpMenu.addAction(self.docsAction)
helpMenu.addAction(self.githubAction)
fileMenu.addAction(self.importAction)
fileMenu.addAction(self.yamlAction)
methodsMenu.addAction(self.searchLog)
methodsMenu.addAction(self.searchSample)
reportMenu.addAction(self.generateReportAction)
@@ -108,6 +111,7 @@ class App(QMainWindow):
self.searchLog = QAction("Search Log", self)
self.searchSample = QAction("Search Sample", self)
self.githubAction = QAction("Github", self)
self.yamlAction = QAction("Export Type Template", self)
def _connectActions(self):
"""
@@ -124,6 +128,7 @@ class App(QMainWindow):
self.searchLog.triggered.connect(self.runSearch)
self.searchSample.triggered.connect(self.runSampleSearch)
self.githubAction.triggered.connect(self.openGithub)
self.yamlAction.triggered.connect(self.export_ST_yaml)
def showAbout(self):
"""
@@ -197,6 +202,17 @@ class App(QMainWindow):
logger.warning(f"Backup function not yet implemented for psql")
current_month_bak = current_month_bak.with_suffix(".psql")
def export_ST_yaml(self):
if check_if_app():
yaml_path = Path(sys._MEIPASS).joinpath("resources", "viral_culture.yml")
else:
yaml_path = project_path.joinpath("src", "submissions", "resources", "viral_culture.yml")
with open(yaml_path, "r") as f:
data = yaml.safe_load(f)
fname = select_save_file(obj=self, default_name="Submission Type Template.yml", extension="yml")
with open(fname, "w") as f:
yaml.safe_dump(data=data, stream=f)
class AddSubForm(QWidget):

View File

@@ -546,7 +546,10 @@ class SubmissionFormWidget(QWidget):
# logger.debug(f"Kits received for {submission_type}: {uses}")
if check_not_nan(value):
# logger.debug(f"The extraction kit in parser was: {value}")
uses.insert(0, uses.pop(uses.index(value)))
try:
uses.insert(0, uses.pop(uses.index(value)))
except ValueError:
logger.warning(f"Couldn't find kit in list, skipping move to top of list.")
obj.ext_kit = value
else:
logger.error(f"Couldn't find {obj.prsr.sub['extraction_kit']}")