Determine whether tkn is a valid python identifier

    :param tkn:
    :return:
437304
def is_valid_python(tkn: str) -> bool:
    
    try:
        root = ast.parse(tkn)
    except SyntaxError:
        return False
    return len(root.body) == 1 and isinstance(root.body[0], ast.Expr) and isinstance(root.body[0].value, ast.Name)
1107408
def checkvalid(s, m, pk):
    
    if len(s) != b // 4:
        raise ValueError("signature length is wrong")

    if len(pk) != b // 8:
        raise ValueError("public-key length is wrong")

    s = bytearray(s)
    m = bytearray(m)
    pk = bytearray(pk)

    R = decodepoint(s[: b // 8])
    A = decodepoint(pk)
    S = decodeint(s[b // 8 : b // 4])
    h = Hint(encodepoint(R) + pk + m)

    (x1, y1, z1, t1) = P = scalarmult_B(S)
    (x2, y2, z2, t2) = Q = edwards_add(R, scalarmult(A, h))

    if (
        not isoncurve(P)
        or not isoncurve(Q)
        or (x1 * z2 - x2 * z1) % q != 0
        or (y1 * z2 - y2 * z1) % q != 0
    ):
        raise SignatureMismatch("signature does not pass verification")
417391
def verify(self):
        
        if self._verify is None:
            from twilio.rest.verify import Verify
            self._verify = Verify(self)
        return self._verify
1337873
def is_valid(identifier):
    

    return (
        isinstance(identifier, six.string_types)
        and bool(NAME_RE.search(identifier))
        and not keyword.iskeyword(identifier)
    )
153281
def t_INITIAL_ID(self, t):
        '  # Any identifier

        tmp = t.value  # Saves original value
        if tmp[-1] == ':':
            t.type = 'LABEL'
            t.value = tmp[:-1].strip()
            return t

        t.value = tmp.upper()  # Convert it to uppercase, since our internal tables uses uppercase
        id_ = tmp.lower()

        t.type = reserved_instructions.get(id_)
        if t.type is not None:
            return t

        t.type = pseudo.get(id_)
        if t.type is not None:
            return t

        t.type = regs8.get(id_)
        if t.type is not None:
            return t

        t.type = flags.get(id_)
        if t.type is not None:
            return t

        t.type = regs16.get(id_, 'ID')
        if t.type == 'ID':
            t.value = tmp  # Restores original value

        return t
1289033
def is_valid_int_param(param):
    
    if param is None:
        return False
    try:
        param = int(param)
        if param < 0:
            return False
    except (TypeError, ValueError):
        return False
    return True
803788
def isSignatureValid(expected, received):
    
    if expected:
        if not received or expected != received:
            return False
    else:
        if received:
            return False
    return True
1100596
def is_valid_key(key):
    

    if PY3 and isinstance(key, bytes):
        raise TypeError("needs to be str not bytes")

    for c in key:
        if c < " " or c > "}" or c == "=":
            return False
    else:
        return bool(key)
153661
def identifier(self):
        
        if len(self.polygons_full) != 1:
            raise TypeError('Identifier only valid for single body')
        return polygons.polygon_hash(self.polygons_full[0])
766444
def t_ANY_ID(self, token):
        '
        if token.value in self.KEYWORDS:
            if (token.value == 'annotation_type') and self.cur_indent:
                # annotation_type was added as a reserved keyword relatively
                # late, when there could be identifers with the same name
                # in existing specs. because annotation_type-the-keyword can
                # only be used at the beginning of a non-indented line, this
                # check lets both the keyword and the identifer coexist and
                # maintains backward compatibility.
                # Note: this is kind of a hack, and we should get rid of it if
                # the lexer gets better at telling keywords from identifiers in general.
                return token
            token.type = self.RESERVED.get(token.value, 'KEYWORD')
            return token
        else:
            return token
727493
def _is_tp(pkt):
        """"""

        tp = [SOMEIP.TYPE_TP_REQUEST, SOMEIP.TYPE_TP_REQUEST_NO_RET,
              SOMEIP.TYPE_TP_NOTIFICATION, SOMEIP.TYPE_TP_RESPONSE,
              SOMEIP.TYPE_TP_ERROR]
        if isinstance(pkt, Packet):
            return pkt.msg_type in tp
        else:
            return pkt[15] in tp
370505
def verifyCert(self, cert):
        
        tbsCert = cert.tbsCertificate
        sigAlg = tbsCert.signature
        h = hash_by_oid[sigAlg.algorithm.val]
        sigVal = raw(cert.signatureValue)
        return self.verify(raw(tbsCert), sigVal, h=h, t='pkcs')
360868
def _verify_jws(self, payload, key):
        """"""
        jws = JWS.from_compact(payload)

        try:
            alg = jws.signature.combined.alg.name
        except KeyError:
            msg = 'No alg value found in header'
            raise SuspiciousOperation(msg)

        if alg != self.OIDC_RP_SIGN_ALGO:
            msg = "The provider algorithm {!r} does not match the client's " \
                  "OIDC_RP_SIGN_ALGO.".format(alg)
            raise SuspiciousOperation(msg)

        if isinstance(key, six.string_types):
            # Use smart_bytes here since the key string comes from settings.
            jwk = JWK.load(smart_bytes(key))
        else:
            # The key is a json returned from the IDP JWKS endpoint.
            jwk = JWK.from_json(key)

        if not jws.verify(jwk):
            msg = 'JWS token verification failed.'
            raise SuspiciousOperation(msg)

        return jws.payload
803166
def reference(self, tkn: str):
        
        return self.grammarelts[tkn] if tkn in self.grammarelts else UndefinedElement(tkn)
58081
def _is_string(thing):
    
    if (_py3k and isinstance(thing, str)):
        return True
    if (not _py3k and isinstance(thing, basestring)):
        return True
    return False
438044
def valid_kdf(self, kdf):
        
        if kdf.input_length is None:
            return True

        if self.data_key_length > kdf.input_length(self):
            raise InvalidAlgorithmError(
                "Invalid Algorithm definition: data_key_len must not be greater than kdf_input_len"
            )

        return True
603313
def message_identification=(value)
      raise ArgumentError.new('message_identification must be a string!') unless value.is_a?(String)

      regex = /\A([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|\,|\'|\ ]){1,35}\z/
      raise ArgumentError.new("message_identification does not match #{regex}!") unless value.match(regex)

      @message_identification = value
    end