python类ArgumentError()的实例源码

base.py 文件源码 项目:pyetje 作者: rorlika 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def set_isolation_level(self, connection, level):
        try:
            isolation_level = self._isolation_lookup[level.replace('_', ' ')]
        except KeyError:
            raise exc.ArgumentError(
                "Invalid value '%s' for isolation_level. "
                "Valid isolation levels for %s are %s" %
                (level, self.name, ", ".join(self._isolation_lookup))
                )
        cursor = connection.cursor()
        cursor.execute("PRAGMA read_uncommitted = %d" % isolation_level)
        cursor.close()
base.py 文件源码 项目:pyetje 作者: rorlika 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, precision=None, scale=None, asdecimal=True, **kw):
        if isinstance(self, (REAL, DOUBLE)) and \
            (
                (precision is None and scale is not None) or
                (precision is not None and scale is None)
            ):
            raise exc.ArgumentError(
                "You must specify both precision and scale or omit "
                "both altogether.")

        super(_FloatType, self).__init__(precision=precision,
                                         asdecimal=asdecimal, **kw)
        self.scale = scale
langhelpers.py 文件源码 项目:pyetje 作者: rorlika 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def assert_arg_type(arg, argtype, name):
    if isinstance(arg, argtype):
        return arg
    else:
        if isinstance(argtype, tuple):
            raise exc.ArgumentError(
                "Argument '%s' is expected to be one of type %s, got '%s'" %
                (name, ' or '.join("'%s'" % a for a in argtype), type(arg)))
        else:
            raise exc.ArgumentError(
                "Argument '%s' is expected to be of type '%s', got '%s'" %
                (name, argtype, type(arg)))
__main__.py 文件源码 项目:MishMash 作者: nicfit 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def main(args):
    import multiprocessing

    try:
        multiprocessing.set_start_method("fork")
    except RuntimeError as ex:
        log.warn("multiprocessing.set_start_method: " + str(ex))

    if not args.command:
        # No command was given.
        args.app.arg_parser.print_help()
        return 1

    # In the case fileConfig undid the command line, which has precedence.
    args.applyLoggingOpts(args.log_levels, args.log_files)

    if args.db_url:
        args.config.set(MAIN_SECT, SA_KEY, args.db_url)
        # Don't want commands and such to use this, so reset.
        args.db_url = None
    elif "MISHMASH_DBURL" in os.environ:
        log.verbose("Using environment MISHMASH_DBURL over configuration: {}"
                    .format(os.environ["MISHMASH_DBURL"]))
        args.config.set(MAIN_SECT, SA_KEY, os.environ["MISHMASH_DBURL"])

    try:
        # Run command
        retval = args.command_func(args, args.config) or 0
    except (KeyboardInterrupt, PromptExit) as ex:
        # PromptExit raised when CTRL+D during prompt, or prompts disabled
        retval = 0
    except (sql_exceptions.ArgumentError,
            sql_exceptions.OperationalError) as ex:
        _pErr("Database error")
        retval = 1
    except Exception as ex:
        log.exception(ex)
        _pErr("General error")
        retval = 2

    return retval
test_lambda.py 文件源码 项目:clickhouse-sqlalchemy 作者: xzkostyan 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_lambda_is_callable(self):
        with self.assertRaises(exc.ArgumentError) as ex:
            self.compile(Lambda(1))

        self.assertEqual(str(ex.exception), 'func must be callable')
clauses.py 文件源码 项目:clickhouse-sqlalchemy 作者: xzkostyan 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, func):
        if not util.callable(func):
            raise exc.ArgumentError('func must be callable')

        self.type = type_api.NULLTYPE
        self.func = func


问题


面经


文章

微信
公众号

扫码关注公众号