Bugfix/Installer: properly track task queueing (#46293)
* Bugfix/Installer: properly track task queueing * Move ordinal() to llnl.string; change time to attempt * Convert BuildTask to use kwargs (after pkg); convert STATUS_ to BuildStats enum * BuildTask: instantiate with keyword only args after the request * Installer: build request is required for initializing task * Installer: only the initial BuildTask cannnot have status REMOVED * Change queueing check * ordinal(): simplify suffix determination [tgamblin] * BuildStatus: ADDED -> QUEUED [becker33] * BuildTask: clarify TypeError for 'installed' argument
This commit is contained in:
@@ -41,6 +41,20 @@ def comma_and(sequence: List[str]) -> str:
|
||||
return comma_list(sequence, "and")
|
||||
|
||||
|
||||
def ordinal(number: int) -> str:
|
||||
"""Return the ordinal representation (1st, 2nd, 3rd, etc.) for the provided number.
|
||||
|
||||
Args:
|
||||
number: int to convert to ordinal number
|
||||
|
||||
Returns: number's corresponding ordinal
|
||||
"""
|
||||
idx = (number % 10) << 1
|
||||
tens = number % 100 // 10
|
||||
suffix = "th" if tens == 1 or idx > 6 else "thstndrd"[idx : idx + 2]
|
||||
return f"{number}{suffix}"
|
||||
|
||||
|
||||
def quote(sequence: List[str], q: str = "'") -> List[str]:
|
||||
"""Quotes each item in the input list with the quote character passed as second argument."""
|
||||
return [f"{q}{e}{q}" for e in sequence]
|
||||
|
||||
Reference in New Issue
Block a user