本文整理汇总了Python中util.Util.string_to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Util.string_to_dict方法的具体用法?Python Util.string_to_dict怎么用?Python Util.string_to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.string_to_dict方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_args
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import string_to_dict [as 别名]
def parse_args(args_list):
log.info("Stetl version = %s" % __version__)
argparser = argparse.ArgumentParser(description='Invoke Stetl')
argparser.add_argument('-c ', '--config', type=str, help='ETL config file in .ini format', dest='config_file',
required=False)
argparser.add_argument('-s ', '--section', type=str, help='Section in the config file to execute, default is [etl]',
dest='config_section', required=False)
argparser.add_argument('-a ', '--args', type=str,
help='Arguments or .properties files to be substituted for symbolic {argN}s in Stetl config file,\
as -a "arg1=foo arg2=bar" and/or -a args.properties, multiple -a options are possible',
dest='config_args', required=False, action='append')
argparser.add_argument('-d ', '--doc', type=str,
help='Get component documentation like its configuration parameters, e.g. stetl doc stetl.inputs.fileinput.FileInput',
dest='doc_args', required=False)
args = argparser.parse_args(args_list)
if args.config_args:
args_total = dict()
for arg in args.config_args:
if os.path.isfile(arg):
log.info('Found args file at: %s' % arg)
args_total = Util.merge_two_dicts(args_total, Util.propsfile_to_dict(arg))
else:
# Convert string to dict: http://stackoverflow.com/a/1248990
args_total = Util.merge_two_dicts(args_total, Util.string_to_dict(arg))
args.config_args = args_total
return args
示例2: parse_args
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import string_to_dict [as 别名]
def parse_args():
log.info("Stetl version = %s" % __version__)
argparser = argparse.ArgumentParser(description='Invoke Stetl')
argparser.add_argument('-c ', '--config', type=str, help='ETL config file in .ini format', dest='config_file',
required=False)
argparser.add_argument('-s ', '--section', type=str, help='Section in the config file to execute, default is [etl]',
dest='config_section', required=False)
argparser.add_argument('-a ', '--args', type=str,
help='Arguments or .properties file to be substituted for {argN}s in config file, as -a "arg1=foo arg2=bar" or -a args.properties',
dest='config_args', required=False)
argparser.add_argument('-d ', '--doc', type=str,
help='Get component documentation like its configuration parameters, e.g. stetl doc stetl.inputs.fileinput.FileInput',
dest='doc_args', required=False)
args = argparser.parse_args()
if args.config_args:
if os.path.isfile(args.config_args):
log.info('Found args file at: %s' % args.config_args)
args.config_args = Util.propsfile_to_dict(args.config_args)
else:
# Convert string to dict: http://stackoverflow.com/a/1248990
args.config_args = Util.string_to_dict(args.config_args)
return args
示例3: parse_args
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import string_to_dict [as 别名]
def parse_args():
log.info("Stetl version = %s" % __version__)
argparser = argparse.ArgumentParser(description="Invoke Stetl")
argparser.add_argument(
"-c ", "--config", type=str, help="ETL config file in .ini format", dest="config_file", required=False
)
argparser.add_argument(
"-s ",
"--section",
type=str,
help="Section in the config file to execute, default is [etl]",
dest="config_section",
required=False,
)
argparser.add_argument(
"-a ",
"--args",
type=str,
help='Arguments to be substituted for {argN}s in config file, as "arg1=foo arg2=bar" etc',
dest="config_args",
required=False,
)
argparser.add_argument(
"-d ",
"--doc",
type=str,
help="Get component documentation like its configuration parameters, e.g. stetl doc stetl.inputs.fileinput.FileInput",
dest="doc_args",
required=False,
)
args = argparser.parse_args()
if args.config_args:
# Convert string to dict: http://stackoverflow.com/a/1248990
args.config_args = Util.string_to_dict(args.config_args)
return args
示例4: parse_args
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import string_to_dict [as 别名]
def parse_args():
log.info("Stetl version = %s" % __version__)
argparser = argparse.ArgumentParser(description='Invoke Stetl')
argparser.add_argument('-c ', '--config', type=str, help='ETL config file in .ini format', dest='config_file',
required=True)
argparser.add_argument('-s ', '--section', type=str, help='Section in the config file to execute, default is [etl]',
dest='config_section', required=False)
argparser.add_argument('-a ', '--args', type=str,
help='Arguments to be substituted for {argN}s in config file, as "arg1=foo arg2=bar" etc',
dest='config_args', required=False)
args = argparser.parse_args()
if args.config_args:
# Convert string to dict: http://stackoverflow.com/a/1248990
args.config_args = Util.string_to_dict(args.config_args)
return args