def get_hook_dict(hook): if isinstance(hook, dict): hook_dict = hook else: hook_dict = _parse_hook_to_dict(to_string(hook)) return hook_dict
def get_hook_dict(hook, index): if isinstance(hook, dict): hook_dict = hook else: hook_dict = _parse_hook_to_dict(to_string(hook)) hook_dict['index'] = index return hook_dict
def exception_handler(self, sql): try: yield # TODO: introspect into `DatabaseError`s and expose `errorName`, # `errorType`, etc instead of stack traces full of garbage! except Exception as exc: logger.debug("Error while running:\n{}".format(sql)) logger.debug(exc) raise RuntimeException(to_string(exc))
def as_kwarg(key, value): test_value = to_string(value) is_function = re.match(r'^\s*(ref|var)\s*\(.+\)\s*$', test_value) # if the value is a function, don't wrap it in quotes! if is_function: formatted_value = value else: formatted_value = value.__repr__() return "{key}={value}".format(key=key, value=formatted_value)
def as_kwarg(key, value): test_value = to_string(value) is_function = re.match(r'^\s*(env_var|ref|var|source|doc)\s*\(.+\)\s*$', test_value) # if the value is a function, don't wrap it in quotes! if is_function: formatted_value = value else: formatted_value = value.__repr__() return "{key}={value}".format(key=key, value=formatted_value)