def __init__(self, expression, s_symbols): """ BRIEF Cache the expression and sentence symbols """ self.expression = expression self.s_symbols = s_symbols # TODO - Maybe we can statically initialize these globals()["T"] = boolean.boolean(boolean.boolean.TRUE) globals()["F"] = boolean.boolean(boolean.boolean.FALSE)
def testTrue(self): """Test all true cases""" self.assertTrue(boolean('True')) self.assertTrue(boolean('true')) self.assertTrue(boolean('yes')) self.assertTrue(boolean('y')) self.assertTrue(boolean('1')) self.assertTrue(boolean('t'))
def testFalse(self): """Test all true cases""" self.assertFalse(boolean('False')) self.assertFalse(boolean('false')) self.assertFalse(boolean('no')) self.assertFalse(boolean('n')) self.assertFalse(boolean('0')) self.assertFalse(boolean('f'))
import jsonschema from slackclient import SlackClient from tenacity import retry, retry_if_exception_type, stop_after_delay, wait_exponential log_level = os.environ.get('LOG_LEVEL', 'INFO') logging.root.setLevel(logging.getLevelName(log_level)) # type: ignore _logger = logging.getLogger(__name__) SLACK_API_TOKEN = os.environ.get('SLACK_API_TOKEN') SLACK_DEFAULT_CHANNEL = os.environ.get('SLACK_DEFAULT_CHANNEL') SLACK = SlackClient(SLACK_API_TOKEN) SLACK_SCHEMA_FILE_PATH = os.path.join(os.path.dirname(__file__), '../slack-message-schema.json') with open(SLACK_SCHEMA_FILE_PATH) as f: SLACK_MESSAGE_SCHEMA = json.load(f) SNS_PUBLISH_RESPONSE = boolean(os.environ.get('SNS_PUBLISH_RESPONSE', 'false')) RESPONSE_SNS_TOPIC_ARN = os.environ.get('RESPONSE_SNS_TOPIC_ARN') SNS = boto3.client('sns') class HandlerBaseError(Exception): '''Base error class''' class SlackBaseError(HandlerBaseError): '''Base Slack Error''' class SlackApiError(SlackBaseError): '''Slack API error class''' def __init__(self, response: dict): self.msg = 'Slack error - {}'.format(response.get('error'))
def _MakeAssignments(self, *values): """ BRIEF Assign variables in the global namespace """ for i, s in enumerate(self.s_symbols): globals()[s] = boolean.boolean(values[i])