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


Python Option.take_action方法代码示例

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


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

示例1: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self, action, dest, opt, value, values, parser):
     if action == 'extend':
         split_value = value.split(',')
         ensure_value(qconfig, dest, []).extend(split_value)
     else:
         Option.take_action(
             self, action, dest, opt, value, qconfig, parser)
开发者ID:student-t,项目名称:quast,代码行数:9,代码来源:options_parser.py

示例2: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self, action, dest, opt, value, values, parser):
     if action == "extend":
         lvalue = value.split(",")
         values.ensure_value(dest, []).extend(lvalue)
     else:
         Option.take_action(
             self, action, dest, opt, value, values, parser)
开发者ID:Callek,项目名称:mozharness,代码行数:9,代码来源:config.py

示例3: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
	def take_action(self, action, dest, opt, value, values, parser):

		if action == "pubsub":

			# read the subscriber and publisher arguments
			value += " "
			for arg in parser.rargs:
				if arg[:2] == "--" and len(arg) > 2: break
				if arg[:1] == "-" and len(arg) > 1: break
				value += arg + " "
			subpubArray = [ x.strip() for x in value.split(",") if x.strip() ] 

			# verify that argument meets requirements
			if len(subpubArray) == 2:
				values.ensure_value(dest, []).append({"name": subpubArray[0], "type": subpubArray[1]})
			else:
				if opt == '-s': exitWithError(ERROR_OPT.SUBSCRIBER_MISSING, len(subpubArray))
				if opt == '-p': exitWithError(ERROR_OPT.PUBLISHER_MISING, len(subpubArray))

		elif action == "strspaces":

			# read the subscriber and publisher arguments
			for arg in parser.rargs:
				if arg[:2] == "--" and len( arg ) > 2: break
				if arg[:1] == "-" and len( arg ) > 1: break
				value += " " + arg

			setattr(values, dest, value )

		else:
			Option.take_action(self, action, dest, opt, value, values, parser)
开发者ID:agdl,项目名称:yunSpacebrew,代码行数:33,代码来源:spacebrew.py

示例4: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self, action, dest, opt, value, values, parser):
     if action == "map":
         values.ensure_value(dest, parser.map[opt.lstrip('-')])
     elif action == "map_extend":
         values.ensure_value(dest, []).extend(parser.map[opt.lstrip('-')])
     else:
         Option.take_action(self, action, dest, opt, value, values, parser)
开发者ID:puiterwijk,项目名称:pykickstart,代码行数:9,代码来源:options.py

示例5: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self,action,dest,opt,value,values,parser):
     log.debug('take_action: %s',action)
     if action in custom_actions:
         custom_actions.get(action)(dest,value,values)
     else:
         Option.take_action(self,action,dest,opt,value,values,parser)
     log.debug('values: %s',values)
开发者ID:rranshous,项目名称:cmdline_utils,代码行数:9,代码来源:cmdline_utils.py

示例6: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
    def take_action(self, action, dest, opt, value, values, parser):
        "Extended to handle generation a config file"
        if action == "generate_config":
            parser.generate_and_print_config_file()
            parser.exit()

        Option.take_action(self, action, dest, opt, value, values, parser)
开发者ID:jwhitlark,项目名称:ConfigurationManager,代码行数:9,代码来源:ConfigManager.py

示例7: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
    def take_action(self, action, dest, opt, value, values, parser):
        """
        This function is a wrapper to take certain options passed on command
        prompt and wrap them into an Array.

        @param action: The type of action that will be taken. For example:
        "store_true", "store_false", "extend".
        @type action: String
        @param dest: The name of the variable that will be used to store the
        option.
        @type dest: String/Boolean/Array
        @param opt: The option string that triggered the action.
        @type opt: String
        @param value: The value of opt(option) if it takes a
        value, if not then None.
        @type value:
        @param values: All the opt(options) in a dictionary.
        @type values: Dictionary
        @param parser: The option parser that was orginally called.
        @type parser: OptionParser
        """
        if (action == "extend") :
            value_list = []
            try:
                for v in value.split(","):
                    # Need to add code for dealing with paths if there is option for paths.
                    new_value = value.strip().rstrip()
                    if (len(new_value) > 0):
                        value_list.append(new_value)
            except:
                pass
            else:
                values.ensure_value(dest, []).extend(value_list)
        else:
            Option.take_action(self, action, dest, opt, value, values, parser)
开发者ID:sbradley7777,项目名称:dot.config,代码行数:37,代码来源:install.py

示例8: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self, action, dest, opt, val, vals, parser):
     if action == 'setitem':
         key = opt.strip('-')
         vals.ensure_value(dest, {})[key] = val
     elif action == 'setitem2':
         key, val = val
         vals.ensure_value(dest, {})[key] = val
     else:
         Opt.take_action(self, action, dest, opt, val, vals, parser)
开发者ID:Cheng--Li,项目名称:disco,代码行数:11,代码来源:cli.py

示例9: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self, action, dest, opt, value, values, parser):
     if action == "extend":
         lvalue = value.split(",")
         for token in lvalue:
             token = token.strip()
             if token:
                 values.ensure_value(dest, []).append(token)
     else:
         Option.take_action(
             self, action, dest, opt, value, values, parser)
开发者ID:peterchang168,项目名称:new-test,代码行数:12,代码来源:conf_util.py

示例10: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
	def take_action(self,action,dest,opt,value,values,parser):
		if action=="dic":
			vals=value.split(",")
			d={}
			for val in vals:
				p=val.split("]")
				k=p[0][1:]
				v=p[1]
				d[k]=v
			setattr(values,dest,d)
		else: Option.take_action(self, action, dest, opt, value, values, parser)
开发者ID:gngrwzrd,项目名称:elsware,代码行数:13,代码来源:dictopt.py

示例11: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self, action, dest, opt, value, values, parser):
     """ Performs list extension on plugins """
     if action == "extend":
         try:
             lvalue = value.split(",")
         except:
             pass
         else:
             values.ensure_value(dest, deque()).extend(lvalue)
     else:
         Option.take_action(self, action, dest, opt, value, values, parser)
开发者ID:nigeljonez,项目名称:sosreport,代码行数:13,代码来源:sosreport.py

示例12: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self, action, dest, opt, value, values, parser):
     if action == "extend":
         values.ensure_value(dest, []).append(value)
     else:
         Option.take_action(
             self,
             action,
             dest,
             opt,
             value,
             values,
             parser)
开发者ID:salilab,项目名称:pmi,代码行数:14,代码来源:process_output.py

示例13: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
    def take_action(self, action, dest, opt, value, values, parser):
        if action == "store_list":
            value = value.strip()
            lvalue = value.split(",")
            size = len(lvalue)
            if size > 0 and lvalue[size - 1] == "":
              lvalue.pop()

            values.ensure_value(dest, []).extend(lvalue)
        else:
            Option.take_action(
                self, action, dest, opt, value, values, parser)
开发者ID:conwetlab,项目名称:ezwebplatform,代码行数:14,代码来源:common.py

示例14: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
    def take_action(self, action, dest, opt, value, values, parser):
        if action == "extend":
            values.ensure_value(dest, []).append(value)
            for a in parser.rargs[:]:
                if a.startswith("-"):
                    break
                else:
                    values.ensure_value(dest, []).append(a)
                    parser.rargs.remove(a)

        else:
            Option.take_action(self, action, dest, opt, value, values, parser)
开发者ID:jipserver,项目名称:jip-server,代码行数:14,代码来源:__init__.py

示例15: take_action

# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import take_action [as 别名]
 def take_action(self, action, dest, opt, value, values, parser):
     if (action == "extend") :
         valueList = []
         try:
             for v in value.split(","):
                 newValue = v.strip().rstrip()
                 if (len(newValue) > 0):
                     valueList.append(newValue)
         except:
             pass
         else:
             values.ensure_value(dest, []).extend(valueList)
     else:
         Option.take_action(self, action, dest, opt, value, values, parser)
开发者ID:codificat,项目名称:dot.config,代码行数:16,代码来源:plex-csvreader.py


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