本文整理匯總了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))