o .&a@s`ddlZddlmZddlZddZddZGdddeZGd d d eZGd d d eZdS) N)CustomArgumentcCsN|durdStjtj|}ttjtj|tjs%td||S)z=Asserts that a path is writable and returns the expanded pathNzUnable to write to file: %s) ospath expanduser expandvarsaccessdirnameabspathW_OK ValueError)routfiler A/usr/lib/python3/dist-packages/awscli/customizations/arguments.pyresolve_given_outfile_paths  rcCs|dddkS)z-Returns True if a parsed result is successfulResponseMetadataHTTPStatusCodei,r ) parsed_resultr r ris_parsed_result_successfulsrcs8eZdZdZddiZfddZddZdd ZZS) OverrideRequiredArgsArgumentaAn argument that if specified makes all other arguments not required By not required, it refers to not having an error thrown when the parser does not find an argument that is required on the command line. To obtain this argument's property of ignoring required arguments, subclass from this class and fill out the ``ARG_DATA`` parameter as described below. Note this class is really only useful for subclassing. namezno-required-argscs*||_|tt|jdi|jdS)Nr )_session_register_argument_actionsuperr__init__ARG_DATA)selfsession __class__r rr7sz%OverrideRequiredArgsArgument.__init__cCs|jd|jdS)Nz%before-building-argument-table-parser)rregisteroverride_required_argsrr r rr<sz6OverrideRequiredArgsArgument._register_argument_actioncKs2d|j}||vr|D] }d||_q dSdS)Nz--F)rkeysrequired)rargument_tableargskwargsname_in_cmdlinearg_namer r rr @s   z3OverrideRequiredArgsArgument.override_required_args) __name__ __module__ __qualname____doc__rrrr __classcell__r r rrr!s  rcs8eZdZdZfddZfddZeddZZS)StatefulArgumentz+An argument that maintains a stateful valuecs tt|j|i|d|_dSN)rr.r_value)rr%r&rr rrLs zStatefulArgument.__init__cstt|||||_dSr/)rr. add_to_paramsr0r parametersvaluerr rr1Ps zStatefulArgument.add_to_paramscC|jSr/)r0r!r r rr4TzStatefulArgument.value) r)r*r+r,rr1propertyr4r-r r rrr.Is   r.csLeZdZdZfddZeddZeddZfdd Zd d Z Z S) QueryOutFileArgumentz8An argument that write a JMESPath query result to a filecsP||_||_||_||_d|vrd|j|d<tt|j|g|Ri|dS)N help_textz=Saves the command output contents of %s to the given filename)r_query_after_call_event_permqueryrr8r)rrrr=after_call_eventpermr%r&rr rr\s"zQueryOutFileArgument.__init__cCr5r/)r:r!r r rr=hr6zQueryOutFileArgument.querycCr5r/)r<r!r r rr?lr6zQueryOutFileArgument.permcs>t|}tt||||jdur|j|j|jdSdSr/) rrr8r1r4rrr; save_queryr2rr rr1ps  z"QueryOutFileArgument.add_to_paramscKszt|r;t|j|}t|jd }|dur|dn||t|j|j WddS1s4wYdSdS)zSaves the result of a JMESPath expression to a file. This method only saves the query data if the response code of the parsed result is < 300. wN) rjmespathsearchr=openr4writerchmodr?)rparsedr&contentsfpr r rr@ws  "zQueryOutFileArgument.save_query) r)r*r+r,rr7r=r?r1r@r-r r rrr8Ys    r8) rawscli.argumentsrrCrrrr.r8r r r rs  (