當前位置: 首頁>>代碼示例>>Python>>正文


Python Option.fix_up方法代碼示例

本文整理匯總了Python中splunklib.searchcommands.Option.fix_up方法的典型用法代碼示例。如果您正苦於以下問題:Python Option.fix_up方法的具體用法?Python Option.fix_up怎麽用?Python Option.fix_up使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在splunklib.searchcommands.Option的用法示例。


在下文中一共展示了Option.fix_up方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __call__

# 需要導入模塊: from splunklib.searchcommands import Option [as 別名]
# 或者: from splunklib.searchcommands.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 import Option [as 別名]
# 或者: from splunklib.searchcommands.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.Option.fix_up方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。