MCPcopy Index your code
hub / github.com/aws/aws-cli / add_timestamp_parser

Function add_timestamp_parser

awscli/customizations/timestampformat.py:49–80  ·  view source on GitHub ↗
(session, **kwargs)

Source from the content-addressed store, hash-verified

47
48
49def add_timestamp_parser(session, **kwargs):
50 factory = session.get_component('response_parser_factory')
51 default_format = 'iso8601'
52 try:
53 timestamp_format = session.get_scoped_config().get(
54 'cli_timestamp_format',
55 default_format,
56 )
57 except ProfileNotFound:
58 # If a --profile is provided that does not exist, loading
59 # a value from get_scoped_config will crash the CLI.
60 # This function can be called as the first handler for
61 # the session-initialized event, which happens before a
62 # profile can be created, even if the command would have
63 # successfully created a profile. Instead of crashing here
64 # on a ProfileNotFound the CLI should just use the default.
65 timestamp_format = default_format
66
67 if timestamp_format == 'wire':
68 # For backwards compatibility reasons, we replace botocore's timestamp
69 # parser (which parses to a datetime.datetime object) with the
70 # identity function which prints the date exactly the same as it comes
71 # across the wire.
72 timestamp_parser = identity
73 elif timestamp_format == 'iso8601':
74 timestamp_parser = iso_format
75 else:
76 raise ConfigurationError(
77 'Unknown cli_timestamp_format value: %s, valid values'
78 ' are "wire" or "iso8601"' % timestamp_format
79 )
80 factory.set_parser_defaults(timestamp_parser=timestamp_parser)

Callers

nothing calls this directly

Calls 4

ConfigurationErrorClass · 0.90
set_parser_defaultsMethod · 0.80
get_componentMethod · 0.45
get_scoped_configMethod · 0.45

Tested by

no test coverage detected