Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
u"""decorators for API permissions and the permissions themselves
:copyright: Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved.
:license: http://www.apache.org/licenses/LICENSE-2.0.html
"""
from __future__ import absolute_import, division, print_function
from pykern.pkdebug import pkdc, pkdexc, pkdlog, pkdp
from pykern import pkinspect
import aenum
#: decorator sets this attribute with an APIPerm
ATTR = 'api_perm'
class APIPerm(aenum.Flag):
#: A user is required but there might not be a cookie yet
ALLOW_COOKIELESS_REQUIRE_USER = aenum.auto()
#: cookie.set_user can be called even if a cookie wasn't received
ALLOW_COOKIELESS_SET_USER = aenum.auto()
#: anybody can view this page, even without cookies
ALLOW_VISITOR = aenum.auto()
#: use basic auth authentication (only)
REQUIRE_AUTH_BASIC = aenum.auto()
#: a cookie has to have been returned, which might contain a user
REQUIRE_COOKIE_SENTINEL = aenum.auto()
#: a user will be created if necessary and auth may be necessary
REQUIRE_USER = aenum.auto()
def _init():
def _new(e):
# -*- coding: utf-8 -*-
from aenum import Flag
from core.results import Results
class MatchingFlags(Flag):
no_flags = 0
match_all = 1
class Person(object):
def __init__(self, name, number, marked_numbers, flags=MatchingFlags.no_flags, email=None, phone=None):
if type(flags) is not MatchingFlags:
raise TypeError('Must use MatchingOptions')
if type(marked_numbers) is not set:
raise TypeError('marked_numbers must be a set')
self._number = number
self._name = name
self._email = email
self._phone = phone
pin = findPinClassByType(pinType)
if pin:
pinClass = pin.internalDataStructure()
return pinClass
return None
class PinReconnectionPolicy(IntEnum):
"""How to behave if pin has connections and another connection about to be performed.
"""
DisconnectIfHasConnections = 0 #: Current connection will be broken
ForbidConnection = 1 #: New connection will be cancelled
class PinOptions(Flag):
"""Used to determine how Pin behaves.
Apply flags on pin instances.
.. seealso:: :meth:`~PyFlow.Core.PinBase.PinBase.enableOptions` :meth:`~PyFlow.Core.PinBase.PinBase.disableOptions`
"""
ArraySupported = auto() #: Pin can hold array data structure
DictSupported = auto() #: Pin can hold dict data structure
SupportsOnlyArrays = auto() #: Pin will only support other pins with array data structure
AllowMultipleConnections = auto() #: This enables pin to allow more that one input connection. See :func:`~PyFlow.Core.Common.connectPins`
ChangeTypeOnConnection = auto() #: Used by :class:`~PyFlow.Packages.PyFlowBase.Pins.AnyPin.AnyPin` to determine if it can change its data type on new connection.
RenamingEnabled = auto() #: Determines if pin can be renamed
Dynamic = auto() #: Specifies if pin was created dynamically (during program runtime)