当前位置: 首页>>代码示例>>Python>>正文


Python Option.fix_up方法代码示例

本文整理汇总了Python中splunklib.searchcommands.decorators.Option.fix_up方法的典型用法代码示例。如果您正苦于以下问题:Python Option.fix_up方法的具体用法?Python Option.fix_up怎么用?Python Option.fix_up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在splunklib.searchcommands.decorators.Option的用法示例。


在下文中一共展示了Option.fix_up方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from splunklib.searchcommands.decorators import Option [as 别名]
# 或者: from splunklib.searchcommands.decorators.Option import fix_up [as 别名]
def __call__(self, o):

        if isfunction(o):
            # We must wait to finalize configuration as the class containing this function is under construction
            # at the time this call to decorate a member function. This will be handled in the call to
            # o.ConfigurationSettings.fix_up(o) in the elif clause of this code block.
            o._settings = self.settings
        elif isclass(o):

            # Set command name

            name = o.__name__
            if name.endswith(b'Command'):
                name = name[:-len(b'Command')]
            o.name = unicode(name.lower())

            # Construct ConfigurationSettings instance for the command class

            o.ConfigurationSettings = ConfigurationSettingsType(
                module=o.__module__ + b'.' + o.__name__,
                name=b'ConfigurationSettings',
                bases=(o.ConfigurationSettings,))

            ConfigurationSetting.fix_up(o.ConfigurationSettings, self.settings)
            o.ConfigurationSettings.fix_up(o)
            Option.fix_up(o)
        else:
            raise TypeError('Incorrect usage: Configuration decorator applied to {0}'.format(type(o), o.__name__))

        return o 
开发者ID:jruaux,项目名称:mongodb-monitoring,代码行数:32,代码来源:decorators.py

示例2: fix_up

# 需要导入模块: from splunklib.searchcommands.decorators import Option [as 别名]
# 或者: from splunklib.searchcommands.decorators.Option import fix_up [as 别名]
def fix_up(cls, command_class):

        is_option = lambda attribute: isinstance(attribute, Option)
        definitions = getmembers(command_class, is_option)
        validate_option_name = OptionName()
        i = 0

        for name, option in definitions:

            if option.name is None:
                option.name = name  # no validation required
            else:
                validate_option_name(option.name)

            if option.fget is None and option.fset is None and option.fdel is None:
                backing_field_name = '_' + name

                def fget(bfn):
                    return lambda this: getattr(this, bfn, None)

                option = option.getter(fget(backing_field_name))

                def fset(bfn, validate):
                    if validate is None:
                        return lambda this, value: setattr(this, bfn, value)
                    return lambda this, value: setattr(this, bfn, validate(value))

                option = option.setter(fset(backing_field_name, option.validate))
                setattr(command_class, name, option)

            elif option.validate is not None:

                def fset(function, validate):
                    return lambda this, value: function(this, validate(value))

                option = option.setter(fset(option.fset, option.validate))
                setattr(command_class, name, option)

            definitions[i] = name, option
            i += 1

        command_class.option_definitions = definitions 
开发者ID:jruaux,项目名称:mongodb-monitoring,代码行数:44,代码来源:decorators.py


注:本文中的splunklib.searchcommands.decorators.Option.fix_up方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。