File: _common.py

package info (click to toggle)
python-typepy 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 624 kB
  • sloc: python: 2,886; makefile: 78; sh: 7
file content (17 lines) | stat: -rw-r--r-- 401 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import re
from typing import Any


ansi_escape = re.compile(r"(\x9b|\x1b\[)[0-?]*[ -\/]*[@-~]", re.IGNORECASE)
REGEXP_THOUSAND_SEP = re.compile(r"\d{1,3}(,\d{1,3})+")


def strip_ansi_escape(value: Any) -> str:
    return ansi_escape.sub("", value)


def remove_thousand_sep(value: str) -> str:
    if REGEXP_THOUSAND_SEP.search(value) is None:
        return value

    return value.replace(",", "")