FRTc@s|ddlZddlZddlmZddlmZdZdZdZdddZ de fd YZ dS( iN(tjson(tBotoClientErrorcCs)t|d}tj|SWdQXdS(s Loads a given JSON file & returns it. :param path: The path to the JSON file :type path: string :returns: The loaded data trN(topenRtload(tpathtendpoints_file((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pytload_endpoint_jsons cCsBx;|jD]-\}}|j|i||j|q W|S(sW Given an existing set of endpoint data, this will deep-update it with any similarly structured data in the additions. :param defaults: The existing endpoints data :type defaults: dict :param defaults: The additional endpoints data :type defaults: dict :returns: The modified endpoints data :rtype: dict (titemst setdefaulttupdate(tdefaultst additionstservicet region_info((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pytmerge_endpoints+scCsttj}d}tjjdr7tjd}n-tjjddrdtjjdd}n|rt|}t||}n|S(s Actually load the region/endpoint information from the JSON files. By default, this loads from the default included ``boto/endpoints.json`` file. Users can override/extend this by supplying either a ``BOTO_ENDPOINTS`` environment variable or a ``endpoints_path`` config variable, either of which should be an absolute path to the user's JSON file. :returns: The endpoints data :rtype: dict tBOTO_ENDPOINTStBototendpoints_pathN( RtbototENDPOINTS_PATHtNonetostenvirontgettconfigR(t endpointstadditional_patht additional((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pyt load_regionsDs c Cst}||kr(td|n|dkr=t}ng}xH|j|ijD].\}}|j|d|d|d|q\W|S(se Given a service name (like ``ec2``), returns a list of ``RegionInfo`` objects for that service. This leverages the ``endpoints.json`` file (+ optional user overrides) to configure/construct all the objects. :param service_name: The name of the service to construct the ``RegionInfo`` objects for. Ex: ``ec2``, ``s3``, ``sns``, etc. :type service_name: string :param region_cls: (Optional) The class to use when constructing. By default, this is ``RegionInfo``. :type region_cls: class :param connection_cls: (Optional) The connection class for the ``RegionInfo`` object. Providing this allows the ``connect`` method on the ``RegionInfo`` to work. Default is ``None`` (no connection). :type connection_cls: class :returns: A list of configured ``RegionInfo`` objects :rtype: list s$Service '%s' not found in endpoints.tnametendpointtconnection_clsN(RRRt RegionInfoRRtappend(t service_namet region_clsR Rt region_objst region_nameR((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pyt get_regionses    %R!cBsGeZdZdddddZdZdZdZdZRS(s" Represents an AWS Region cCs(||_||_||_||_dS(N(t connectionRRR (tselfR(RRR ((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pyt__init__s   cCs d|jS(Ns RegionInfo:%s(R(R)((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pyt__repr__scCsdS(N(R(R)RtattrsR(((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pyt startElementscCsD|dkr||_n(|dkr0||_nt|||dS(Nt regionNametregionEndpoint(RRtsetattr(R)RtvalueR(((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pyt endElements     cKs |jr|jd||SdS(s Connect to this Region's endpoint. Returns an connection object pointing to the endpoint associated with this region. You may pass any of the arguments accepted by the connection class's constructor as keyword arguments and they will be passed along to the connection object. :rtype: Connection object :return: The connection to this regions endpoint tregionN(R (R)t kw_params((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pytconnects N( t__name__t __module__t__doc__RR*R+R-R2R5(((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pyR!s     ( RRt boto.compatRtboto.exceptionRRRRRR'tobjectR!(((s</opt/freeware/lib/python2.7/site-packages/boto/regioninfo.pyts    !0