From 453455b8bc6557c35ad279a208235f0b44aa251e Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 4 May 2021 23:34:32 +0300 Subject: base: species: Rewrite TheSpecies class using a dataclass --- wqflask/base/species.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'wqflask') diff --git a/wqflask/base/species.py b/wqflask/base/species.py index 3ec7556d..3865f450 100644 --- a/wqflask/base/species.py +++ b/wqflask/base/species.py @@ -1,5 +1,7 @@ import collections +from dataclasses import dataclass +from typing import Optional, Dict from flask import g @@ -7,13 +9,18 @@ from utility.logger import getLogger logger = getLogger(__name__) +@dataclass class TheSpecies: - def __init__(self, dataset=None, species_name=None): - if species_name != None: - self.name = species_name + """Data related to species.""" + dataset: Optional[Dict] = None + species_name: Optional[str] = None + + def __post_init__(self): + if self.species_name is not None: + self.name = self.species_name self.chromosomes = Chromosomes(species=self.name) else: - self.dataset = dataset + self.dataset = self.dataset self.chromosomes = Chromosomes(dataset=self.dataset) -- cgit v1.2.3