mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
metadata: auto-convert YAML special float values: .nan .inf -.inf
Even for people who know what the special floats not-a-number, infinity, and negative infinity, they don't necessarily know the YAML 1.2 syntax for these. I didn't. And I've spent some quality time fighting things with those values. They are also easy to reliably convert to string values.
This commit is contained in:
parent
8374842faa
commit
9f606d0fbb
2 changed files with 27 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
import git
|
||||
from pathlib import Path
|
||||
import math
|
||||
import platform
|
||||
import os
|
||||
import re
|
||||
|
@ -897,6 +898,14 @@ def _normalize_type_string(v):
|
|||
if v:
|
||||
return 'true'
|
||||
return 'false'
|
||||
if isinstance(v, float):
|
||||
# YAML 1.2 values for NaN, Inf, and -Inf
|
||||
if math.isnan(v):
|
||||
return '.nan'
|
||||
if math.isinf(v):
|
||||
if v > 0:
|
||||
return '.inf'
|
||||
return '-.inf'
|
||||
return str(v)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue