Module control.typ.cust.score
Expand source code
from config import Config as C, Names as N
from control.html import HtmlElements as H
from control.utils import pick as G, E
from control.typ.value import Value
CW = C.web
Qq = H.icon(CW.unknown[N.generic], asChar=True)
class Score(Value):
"""Type class for scores."""
def __init__(self, context):
super().__init__(context)
def titleStr(self, record, markup=True, **kwargs):
"""Put the score and the level in the title."""
score = G(record, N.score)
if score is None:
return E if markup is None else Qq
levelBare = G(record, N.level)
return (
f"""{score or E} - {levelBare or E}"""
if markup is None
else f"""{H.he(score)} - {H.he(levelBare) or Qq}"""
)
Classes
class Score (context)
-
Type class for scores.
Initialization
Store a handle to the Context singleton.
Parameters
context
:object
- See below.
Expand source code
class Score(Value): """Type class for scores.""" def __init__(self, context): super().__init__(context) def titleStr(self, record, markup=True, **kwargs): """Put the score and the level in the title.""" score = G(record, N.score) if score is None: return E if markup is None else Qq levelBare = G(record, N.level) return ( f"""{score or E} - {levelBare or E}""" if markup is None else f"""{H.he(score)} - {H.he(levelBare) or Qq}""" )
Ancestors
Methods
def titleStr(self, record, markup=True, **kwargs)
-
Put the score and the level in the title.
Expand source code
def titleStr(self, record, markup=True, **kwargs): """Put the score and the level in the title.""" score = G(record, N.score) if score is None: return E if markup is None else Qq levelBare = G(record, N.level) return ( f"""{score or E} - {levelBare or E}""" if markup is None else f"""{H.he(score)} - {H.he(levelBare) or Qq}""" )
Inherited members