MCPcopy Create free account
hub / github.com/nodejs/node / IsStrCanonicalInt

Function IsStrCanonicalInt

tools/gyp/pylib/gyp/input.py:691–710  ·  view source on GitHub ↗

Returns True if |string| is in its canonical integer form. The canonical form is such that str(int(string)) == string.

(string)

Source from the content-addressed store, hash-verified

689
690
691def IsStrCanonicalInt(string):
692 """Returns True if |string| is in its canonical integer form.
693
694 The canonical form is such that str(int(string)) == string.
695 """
696 if isinstance(string, str):
697 # This function is called a lot so for maximum performance, avoid
698 # involving regexps which would otherwise make the code much
699 # shorter. Regexps would need twice the time of this function.
700 if string:
701 if string == "0":
702 return True
703 if string[0] == "-":
704 string = string[1:]
705 if not string:
706 return False
707 if "1" <= string[0] <= "9":
708 return string.isdigit()
709
710 return False
711
712
713# This matches things like "<(asdf)", "<!(cmd)", "<!@(cmd)", "<|(list)",

Callers 1

ExpandVariablesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected