本文整理匯總了Python中botocore.utils.parse_to_aware_datetime方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.parse_to_aware_datetime方法的具體用法?Python utils.parse_to_aware_datetime怎麽用?Python utils.parse_to_aware_datetime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類botocore.utils
的用法示例。
在下文中一共展示了utils.parse_to_aware_datetime方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _run_main
# 需要導入模塊: from botocore import utils [as 別名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 別名]
def _run_main(self, args, parsed_globals):
signer = CloudFrontSigner(
args.key_pair_id, RSASigner(args.private_key).sign)
date_less_than = parse_to_aware_datetime(args.date_less_than)
date_greater_than = args.date_greater_than
if date_greater_than is not None:
date_greater_than = parse_to_aware_datetime(date_greater_than)
if date_greater_than is not None or args.ip_address is not None:
policy = signer.build_policy(
args.url, date_less_than, date_greater_than=date_greater_than,
ip_address=args.ip_address)
sys.stdout.write(signer.generate_presigned_url(
args.url, policy=policy))
else:
sys.stdout.write(signer.generate_presigned_url(
args.url, date_less_than=date_less_than))
return 0
示例2: _convert_timestamp_to_str
# 需要導入模塊: from botocore import utils [as 別名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 別名]
def _convert_timestamp_to_str(self, value):
datetime_obj = parse_to_aware_datetime(value)
converter = getattr(
self, '_timestamp_%s' % self.TIMESTAMP_FORMAT.lower())
final_value = converter(datetime_obj)
return final_value
示例3: _convert_header_value
# 需要導入模塊: from botocore import utils [as 別名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 別名]
def _convert_header_value(self, shape, value):
if shape.type_name == 'timestamp':
datetime_obj = parse_to_aware_datetime(value)
timestamp = calendar.timegm(datetime_obj.utctimetuple())
return self._timestamp_rfc822(timestamp)
else:
return value
示例4: _convert_timestamp_to_str
# 需要導入模塊: from botocore import utils [as 別名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 別名]
def _convert_timestamp_to_str(self, value, timestamp_format=None):
if timestamp_format is None:
timestamp_format = self.TIMESTAMP_FORMAT
timestamp_format = timestamp_format.lower()
datetime_obj = parse_to_aware_datetime(value)
converter = getattr(
self, '_timestamp_%s' % timestamp_format)
final_value = converter(datetime_obj)
return final_value
示例5: _convert_header_value
# 需要導入模塊: from botocore import utils [as 別名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 別名]
def _convert_header_value(self, shape, value):
if shape.type_name == 'timestamp':
datetime_obj = parse_to_aware_datetime(value)
timestamp = calendar.timegm(datetime_obj.utctimetuple())
timestamp_format = shape.serialization.get(
'timestampFormat', self.HEADER_TIMESTAMP_FORMAT)
return self._convert_timestamp_to_str(timestamp, timestamp_format)
elif is_json_value_header(shape):
# Serialize with no spaces after separators to save space in
# the header.
return self._get_base64(json.dumps(value, separators=(',', ':')))
else:
return value
示例6: _convert_header_value
# 需要導入模塊: from botocore import utils [as 別名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 別名]
def _convert_header_value(self, shape, value):
if shape.type_name == 'timestamp':
datetime_obj = parse_to_aware_datetime(value)
timestamp = calendar.timegm(datetime_obj.utctimetuple())
return self._timestamp_rfc822(timestamp)
elif is_json_value_header(shape):
# Serialize with no spaces after separators to save space in
# the header.
return self._get_base64(json.dumps(value, separators=(',', ':')))
else:
return value