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


Python Misc.join_list_to_string方法代碼示例

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


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

示例1: report_elb

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def report_elb(self):
     '''
     This function is a wrapper for parsing arguments and printing for elb attribute reports
     Tested
     :return:
     '''
     logger.info("Started report generation command")
     a = awsrequests(session=self.account_information['session'])
     parser = argparse.ArgumentParser(description='report generation about elbs', usage='''kerrigan.py elb report_elb [<args>]]
     ''' + self.global_options, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="kerrigan")
     parser.add_argument('--columns', action='store', default=a.service_supported_columns(service="elb"),
                         help="Which columns to display")
     parser.add_argument('--filters', action='store', default=None,
                         help="The filters that should be used, example: key1:value1,key2:value2")
     args = parser.parse_args(sys.argv[3:])
     columns = Misc.parse_service_columns(columns=args.columns, service="elb")
     if args.filters:
         filters = Misc.format_boto3_filter(filters=args.filters)
     else:
         filters = None
     result = a.information_elbs(columns=columns, filters=filters)
     for res in result:
         if self.account_information['logger_arguments']['table']:
             res['AvailabilityZones'] = Misc.list_to_multiline_string(list=res['AvailabilityZones'])
             res['SecurityGroups'] = Misc.list_to_multiline_string(list=res['SecurityGroups'])
             res['Instances'] = Misc.list_to_multiline_string(list=res['Instances'])
         else:
             res['AvailabilityZones'] = Misc.join_list_to_string(list=res['AvailabilityZones'])
             res['SecurityGroups'] = Misc.join_list_to_string(list=res['SecurityGroups'])
             res['Instances'] = Misc.join_list_to_string(list=res['Instances'])
     logger.output(data=result, csvvar=self.account_information['logger_arguments']['csv'],
                   tablevar=self.account_information['logger_arguments']['table'])
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:34,代碼來源:elb.py

示例2: info_all

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def info_all(self):
     # FIXME implement possbility to scope to env
     logger.info("Gathering all elbs")
     parser = argparse.ArgumentParser(description='ec2 tool for devops', usage='''kerrigan.py elb info_all [<args>]]
     ''' + self.global_options)
     args = parser.parse_args(sys.argv[3:])
     e = awsrequests()
     res = e.elb_info_all()
     for r in res:
         if self.cli['csv']:
             r['Availability Zones'] = Misc.join_list_to_string(list=r['Availability Zones'])
             r['Securitygroups'] = Misc.join_list_to_string(list=r['Securitygroups'])
             r['InstanceIds'] = Misc.join_list_to_string(list=r['InstanceIds'])
             r['From-To-Protocol'] = Misc.join_list_to_string(list=r['From-To-Protocol'])
         elif self.cli['table']:
             r['Availability Zones'] = Misc.list_to_multiline_string(r['Availability Zones'])
             r['InstanceIds'] = Misc.list_to_multiline_string(r['InstanceIds'])
             r['Securitygroups'] = Misc.list_to_multiline_string(r['Securitygroups'])
             r['From-To-Protocol'] = Misc.list_to_multiline_string(r['From-To-Protocol'])
     logger.output(data=res, csvvar=self.cli['csv'], tablevar=self.cli['table'])
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:22,代碼來源:elb.py

示例3: info_certs

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def info_certs(self):
     logger.info("Going to list all certs")
     parser = argparse.ArgumentParser(description='ec2 tool for devops', usage='''kerrigan.py iam info_all [<args>]]
     ''' + self.global_options)
     args = parser.parse_args(sys.argv[3:])
     a = awsrequests()
     res = a.server_certificates_info_all()
     for r in res:
         if self.cli['csv']:
             r['ELB'] = Misc.join_list_to_string(list=r['ELB'])
         elif self.cli['table']:
             r['ELB'] = Misc.list_to_multiline_string(r['ELB'])
         else:
             logger.error('There is an unhandled printing. Need to investigate')
     logger.output(data=res, csvvar=self.cli['csv'], tablevar=self.cli['table'])
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:17,代碼來源:iam.py

示例4: instance_status

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def instance_status(self):
     logger.info("Started instance status command")
     a = awsrequests(session=self.account_information['session'])
     parser = argparse.ArgumentParser(description='instance status about ami', usage='''kerrigan.py ami instance_Status [<args>]]
     ''' + self.global_options, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="kerrigan")
     parser.add_argument('--imageid', action='store', default=None,
                         help="Only imageIds that should be queried")
     args = parser.parse_args(sys.argv[3:])
     result = a.image_instance_status(imageid=args.imageid)
     for res in result:
         if self.account_information['logger_arguments']['table']:
             res['Instances'] = Misc.list_to_multiline_string(list=res['Instances'])
         else:
             res['Instances'] = Misc.join_list_to_string(list=res['Instances'])
     logger.output(data=result, csvvar=self.account_information['logger_arguments']['csv'],
                   tablevar=self.account_information['logger_arguments']['table'])
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:18,代碼來源:ami.py

示例5: list_user_groups

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def list_user_groups(self):
     logger.info("Going to list groups")
     parser = argparse.ArgumentParser(description='ec2 tool for devops', usage='''kerrigan.py iam list_user_groups [<args>]]
     ''' + self.global_options)
     parser.add_argument('--username', action='store', default=None,
                         help="Should intermediate certificate be uploaded")
     args = parser.parse_args(sys.argv[3:])
     a = awsrequests()
     res = a.list_user_groups(username=args.username)
     out = []
     for r in res:
         if self.cli['csv']:
             res[r] = Misc.join_list_to_string(list=res[r])
         elif self.cli['table']:
             res[r] = Misc.list_to_multiline_string(res[r])
         out.append({'Username': r, 'Groups': res[r]})
     logger.output(data=out, csvvar=self.cli['csv'], tablevar=self.cli['table'])
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:19,代碼來源:iam.py

示例6: info

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def info(self):
     logger.info("Starting to gather information")
     a = awsrequests()
     parser = argparse.ArgumentParser(description='ec2 tool for devops', usage='''kerrigan.py route53 info [<args>]]
     ''' + self.global_options)
     parser.add_argument('--env', action='store', help="Environment to gather information about")
     args = parser.parse_args(sys.argv[3:])
     res = a.route53_info(env=args.env)
     for r in res:
         if self.cli['csv']:
             r['Values'] = Misc.join_list_to_string(list=r['Values'])
         elif self.cli['table']:
             r['Values'] = Misc.list_to_multiline_string(r['Values'])
         else:
             logger.error('There is an unhandled printing. Need to investigate')
         # Add information if not present:
         if 'Weight' not in r:
             r['Weight'] = '-'
             r['SetIdentifier'] = '-'
     logger.output(data=res, csvvar=self.cli['csv'], tablevar=self.cli['table'])
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:22,代碼來源:route53.py

示例7: test_join_string_to_list_invalid_list

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def test_join_string_to_list_invalid_list(self):
     list = "abs"
     should_be = "a_b_s"
     result = Misc.join_list_to_string(list=list, join_with="_")
     self.assertEqual(should_be, result)
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:7,代碼來源:test_Misc.py

示例8: test_join_string_to_list_special_char

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def test_join_string_to_list_special_char(self):
     list = ['a', 'b']
     should_be = "a_b"
     result = Misc.join_list_to_string(list=list, join_with="_")
     self.assertEqual(should_be, result)
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:7,代碼來源:test_Misc.py

示例9: test_join_string_to_list_default

# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import join_list_to_string [as 別名]
 def test_join_string_to_list_default(self):
     list = ['a', 'b']
     should_be = "a,b"
     result = Misc.join_list_to_string(list=list)
     self.assertEqual(should_be, result)
開發者ID:s4mur4i,項目名稱:kerrigan,代碼行數:7,代碼來源:test_Misc.py


注:本文中的misc.Misc.join_list_to_string方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。