本文整理汇总了Python中WRCCUtils.form_to_display_list方法的典型用法代码示例。如果您正苦于以下问题:Python WRCCUtils.form_to_display_list方法的具体用法?Python WRCCUtils.form_to_display_list怎么用?Python WRCCUtils.form_to_display_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WRCCUtils
的用法示例。
在下文中一共展示了WRCCUtils.form_to_display_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compose_email
# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import form_to_display_list [as 别名]
def compose_email(params, ftp_server, ftp_dir, out_files):
#NOTIFY_USER
mail_server = settings.DRI_MAIL_SERVER
fromaddr = settings.CSC_FROM_ADDRESS
user_name, user_email = get_user_info(params)
subj = 'Data request %s' % params['output_file_name']
now = datetime.datetime.now()
date = now.strftime( '%Y-%m-%d %H:%M' )
pick_up_latest = (now + datetime.timedelta(days=25)).strftime( '%Y-%m-%d' )
display_keys = [params['area_type'],'variables','units', 'start_date', 'end_date']
if 'data_type' in params.keys():
display_keys.insert(0,'data_type')
params_display_list = WRCCUtils.form_to_display_list(display_keys, params)
dp = '';files=''
for item in params_display_list:
key = item[0]
val = item[1]
dp+=key + ': ' + val +'\n' + ' '
zip_file = out_files[0].split('/')[-1]
for f in out_files[1:]:
files+= f + '\n' + ' '
message_text ='''
Date: %s
Dear %s,
Your data request has been processed.
^ ^
(O,O)
( )
-"-"-
The data is available here:
%s
Please connect as Guest. You will not need a password.
The data is stored in the zip archive:
%s
The individual file names are:
%s
You can pick up your data until: %s.
Your parameters were:
%s
'''%(date, user_name,'ftp://' + ftp_server + ftp_dir, zip_file, files, str(pick_up_latest), dp)
return subj, message_text
示例2: test_defaults
# 需要导入模块: import WRCCUtils [as 别名]
# 或者: from WRCCUtils import form_to_display_list [as 别名]
def test_defaults(self):
#Test most general case:
#convert all form aprameters to display
key_order_list = None
for app_name, params in self.test_params.iteritems():
display_params = WRCCUtils.form_to_display_list(key_order_list, params)
try:
self.assertIsInstance(display_params, list)
except AssertionError as err:
logger.error('AssertionError' + str(err))
try:
self.assertNotEqual(display_params,[])
except AssertionError as err:
logger.error('AssertionError' + str(err))
logger.info(display_params)
for dp in display_params:
try:
self.assertEqual(len(dp),2)
except AssertionError as err:
logger.error('AssertionError' + str(err))