Exemplo n.º 1
0
 def getQuantityPair(cls, s):
     s = utils.removeBrackets(s)
     match = re.search(
         r"(?P<value>[\-+]?\d+\.?\d*)? *(?P<unit>[a-zA-Z\'\"]+)", s)
     value, unit = None, None
     if match is not None:
         value, unit = match.group("value"), match.group("unit")
     return value, unit
Exemplo n.º 2
0
 def getQuantityPair(cls, s):
     s = utils.removeBrackets(s)
     # . patch
     if s.startswith("."):
         s = "0" + s
     match = re.search(r"(?P<value>[\-+]?\d+\.?\d*)? *(?P<unit>[a-zA-Z]+)", s)
     value, unit = None, None
     if match is not None:
         value, unit = match.group("value"), match.group("unit")
     if value is None:
         value = "1"
     return value, unit
Exemplo n.º 3
0
 def getQuantityPair(cls, s):
     s = utils.removeBrackets(s)
     # TODO: These are temporary patches.
     # Zero patch
     if s.lower() in ["0", "zero"]:
         return 0, "g"
     # Infinity patch
     if s.lower() in ["infinity", "inf", "∞", "yes"]:
         if s.lower() == "yes":
             logger.log(EGG, "Yes.")
         return cls._infinity, "g"
     # . patch
     if s.startswith("."):
         s = "0" + s
     match = re.search(r"(?P<value>[\-+]?\d+\.?\d*)? *(?P<unit>[a-zA-Z\'\"]+)", s)
     value, unit = None, None
     if match is not None:
         value, unit = match.group("value"), match.group("unit")
     return value, unit
Exemplo n.º 4
0
def test_removeBrackets_pointy():
    s = "<value>"
    result = utils.removeBrackets(s)
    assert result == "value"
Exemplo n.º 5
0
def test_removeBrackets_square():
    s = "[value]"
    result = utils.removeBrackets(s)
    assert result == "value"