diff options
author | Keewis <keewis@posteo.de> | 2021-08-17 18:32:19 +0200 |
---|---|---|
committer | Keewis <keewis@posteo.de> | 2021-08-17 18:32:19 +0200 |
commit | 7cc37692ebfc09f851c6c2bbec968af390390f2d (patch) | |
tree | a072a52ed60d23dee132bfdcd2dfc0f08e8b0bef /pint/formatting.py | |
parent | 8c719483f6499eb860b4a0ec1a28aa23a736049e (diff) | |
download | pint-7cc37692ebfc09f851c6c2bbec968af390390f2d.tar.gz |
extract the custom flags before passing them to the unit formatter
Diffstat (limited to 'pint/formatting.py')
-rw-r--r-- | pint/formatting.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pint/formatting.py b/pint/formatting.py index 4a83377..6835917 100644 --- a/pint/formatting.py +++ b/pint/formatting.py @@ -442,6 +442,15 @@ def siunitx_format_unit(units): return "".join(lpos) + "".join(lneg) +def extract_custom_flags(spec): + import re + + flag_re = re.compile("(" + "|".join(list(_FORMATTERS.keys()) + ["~"]) + ")") + custom_flags = flag_re.findall(spec) + + return "".join(custom_flags) + + def remove_custom_flags(spec): for flag in list(_FORMATTERS.keys()) + ["~"]: if flag: |