__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

�w�g�\���SrSSKJr SSKJr "SS\5r"SS5rSrS	rS
r	"SS5r
"S
S\
5r"SS\
5r"SS\
5r
g)a�Testing API allows fake data to be used in unit tests.

Testing launchpadlib code is tricky, because it depends so heavily on a
remote, unique webservice: Launchpad.  This module helps you write tests for
your launchpadlib application that can be run locally and quickly.

Say you were writing some code that needed to call out to Launchpad and get
the branches owned by the logged-in person, and then do something to them. For
example, something like this::

  def collect_unique_names(lp):
      names = []
      for branch in lp.me.getBranches():
          names.append(branch.unique_name)
      return names

To test it, you would first prepare a L{FakeLaunchpad} object, and give it
some sample data of your own devising::

  lp = FakeLaunchpad()
  my_branches = [dict(unique_name='~foo/bar/baz')]
  lp.me = dict(getBranches: lambda status: my_branches)

Then, in the test, call your own code and assert that it behaves correctly
given the data.

  names = collect_unique_names(lp)
  self.assertEqual(['~foo/bar/baz'], names)

And that's it.

The L{FakeLaunchpad} code uses a WADL file to type-check any objects created
or returned.  This means you can be sure that you won't accidentally store
sample data with misspelled attribute names.

The WADL file that we use by default is for version 1.0 of the Launchpad API.
If you want to work against a more recent version of the API, download the
WADL yourself (see <https://help.launchpad.net/API/Hacking>) and construct
your C{FakeLaunchpad} like this::

  from wadllib.application import Application
  lp = FakeLaunchpad(
      Application('https://api.launchpad.net/devel/',
                  '/path/to/wadl.xml'))

Where 'https://api.launchpad.net/devel/' is the URL for the WADL file, found
also in the WADL file itelf.
�)�Callable)�datetimec��\rSrSrSrSrg)�IntegrityError�HzERaised when bad sample data is used with a L{FakeLaunchpad} instance.�N��__name__�
__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__r��@/usr/lib/python3/dist-packages/launchpadlib/testing/launchpad.pyrrHs��Orrc��\rSrSrSrSSjrSrSr\SSj5r	\SSj5r
\SS	j5rS
rg)
�
FakeLaunchpad�Lz�A fake Launchpad API class for unit tests that depend on L{Launchpad}.

@param application: A C{wadllib.application.Application} instance for a
    Launchpad WADL definition file.
Nc�x�Uc
SSKJn U"5n[U5nURR	UUUS.5 g)Nr��get_application)�credentials�_application�
_service_root)�launchpadlib.testing.resourcesr�FakeRoot�__dict__�update)	�selfr�service_root�cache�timeout�
proxy_info�applicationr�
root_resources	         r�__init__�FakeLaunchpad.__init__Ss?����F�)�+�K� ��-�
��
�
���*� +�!.�
�	
rc�4�URn[X1U5 g)z�Set sample data.

@param name: The name of the attribute.
@param values: A dict representing an object matching a resource
    defined in Launchpad's WADL definition.
N)r�setattr)r�name�valuesr s    r�__setattr__�FakeLaunchpad.__setattr__is���)�)����F�+rc�.�[URU5$)�:Get sample data.

@param name: The name of the attribute.
)�getattrr)rr*s  r�__getattr__�FakeLaunchpad.__getattr__ss��
�t�)�)�4�0�0rc�6�SSKJn U"[5U"5S9$)z.Convenience for setting up access credentials.rr�r$�rr�object)	�cls�
consumer_name�token_string�
access_secretr r!r"r#rs	         r�login�FakeLaunchpad.loginzs��	C��6�8��):�;�;rc�6�SSKJn U"[5U"5S9$)z=Get credentials from Launchpad and log into the service root.rrr4r5)r7r8r r!r"r#rs       r�get_token_and_login�!FakeLaunchpad.get_token_and_login����	C��6�8��):�;�;rc�6�SSKJn U"[5U"5S9$)z5Log in to Launchpad with possibly cached credentials.rrr4r5)r7r8r �launchpadlib_dirr"r#rs       r�
login_with�FakeLaunchpad.login_with�r@rr)NNNNNN)NNNN)
r
rrr
rr&r,r1�classmethodr;r>rCrrrrrrLs����������
�,,�1������
<��
<������
<��<������
<��<rrc�^�UVs/sHo3RU5U:XdMUPM sn$s snf)z@Find children of element where attribute name is equal to value.)�get)�elementr*�value�childs    r�find_by_attributerK�s'��&�C�w�e�)�)�D�/�U�*B�E�w�C�C��Cs�*�*c�P�URU5(aUS[U5*$U$�N)�endswith�len)�string�suffixs  r�strip_suffixrR�s)��
���v����n��V���%�%��Mrc��SU-$)z)Scope a tag name with the WADL namespace.z&{http://research.sun.com/wadl/2006/10}r)�tag_names r�wadl_tagrU�s
��3�h�>�>rc��\rSrSrSrS/rSSjrSr\"54Sjr	Sr
S	rS
rSr
SrS
rSrSrSrSrSrSrSrSrSrg)�FakeResource�a�
Represents valid sample data on L{FakeLaunchpad} instances.

@ivar _children: A dictionary of child resources, each of type
    C{FakeResource}.
@ivar _values: A dictionary of values associated with this resource. e.g.
    "display_name" or "date_created".  The values of this dictionary will
    never be C{FakeResource}s.

Note that if C{_children} has a key, then C{_values} will not, and vice
versa. That is, they are distinct dicts.
�lp_saveNc�N�Uc0nURRUU0US.5 g)aConstruct a FakeResource.

@param application: A C{waddlib.application.Application} instance.
@param resource_type: A C{wadllib.application.ResourceType} instance
    for this resource.
@param values: Optionally, a dict representing attribute key/value
    pairs for this resource.
N)r�_resource_type�	_children�_values)rr)rr$�
resource_typer+s    rr&�FakeResource.__init__�s1���>��F��
�
��� +�"/��!�	
�	
rc��[U[5(aURX5URU'g0nUR	UR
5 X#U'UR
URU5 X0RS'g)z�Set sample data.

C{value} can be a dict representing an object matching a resource
defined in the WADL definition.  Alternatively, C{value} could be a
resource itself.  Either way, it is checked for type correctness
against the WADL definition.
r]N)	�
isinstance�dict�_create_child_resourcer\rr]�_check_resource_typer[r)rr*rIr+s    rr,�FakeResource.__setattr__�sj���e�T�"�"�#'�#>�#>�t�#K�D�N�N�4� ��F��M�M�$�,�,�'� �4�L�
�%�%�d�&9�&9�6�B�'-�M�M�)�$rc��URRX5nX2LaAURRX5n[U[5(aURX5$XR;aS$X2La[U<SU<S35eU$)r/c��g)NTrrrr�<lambda>�*FakeResource.__getattr__.<locals>.<lambda>�s��4rz has no attribute '�')r\rGr]rar�_wrap_method�special_methods�AttributeError)rr*�_marker�results    rr1�FakeResource.__getattr__�s}��
���#�#�D�2�����\�\�%�%�d�4�F��&�(�+�+��(�(��6�6��'�'�'����� �t�T�!J�K�K��
rc�^^^�UUU4SjnU$)z�Wrapper around methods validates results when it's run.

@param name: The name of the method.
@param method: The callable to run when the method is called.
c�2>�TR"TT/UQ70UD6$rM)�_run_method)�args�kwargs�methodr*rs  ���r�wrapper�*FakeResource._wrap_method.<locals>.wrappers ����#�#�D�&�B�4�B�6�B�Brr)rr*rvrws``` rrk�FakeResource._wrap_method�s���	C��rc�&�URURS5nURRUnUR	U5Vs0sHnUR
U_M nnSnUR
US-5nUcSnUR
US-5nUc[U<S35eURU5n	U(a'URX�5 [URX�5$URX�5up[URU	UUU
5$s snf)aq
Ensure that C{values} is a valid object for the C{name} attribute and
return a resource object to represent it as API data.

@param name: The name of the attribute to check the C{values} object
    against.
@param values: A dict with key/value pairs representing attributes and
    methods of an object matching the C{name} resource's definition.
@return: A L{FakeEntry} for an ordinary resource or a
    L{FakeCollection} for a resource that represents a collection.
@raises IntegrityError: Raised if C{name} isn't a valid attribute for
    this resource or if C{values} isn't a valid object for the C{name}
    attribute.
rGF�_collection_linkT�_linkz isn't a valid property.)
�_find_representation_idr[r�representation_definitions�paramsr*rGr�_get_resource_typerd�	FakeEntry�_check_collection_type�FakeCollection)rr*r+�xml_id�representationrJr�is_link�paramr^�child_resource_types           rrc�#FakeResource._create_child_resource
s%���-�-�d�.A�.A�5�I���*�*�E�E�f�M��(�.�.�~�>�
�>��
�J�J���>�	�
����
�
�4�"4�4�5���=��G��J�J�t�g�~�.�E��=� ��!G�H�H��/�/��6�
���%�%�m�<��T�.�.�
�F�F�(,�(C�(C��)�%�D�"��!�!����#��
��'
s�	Dc��URR[S55nURS5nURRU5$)z�Get the resource type for C{param}.

@param param: An object representing a C{_link} or C{_collection_link}
    parameter.
@return: The resource type for the parameter, or None if one isn't
    available.
�linkr^)�tag�findrUrGr�get_resource_type)rr�r�r*s    rr��FakeResource._get_resource_type6s@���y�y�~�~�h�v�.�/���x�x��(��� � �2�2�4�8�8rc��UR5H?up4[U[5(aURX5 M-UR	XU5 MA g)a3
Ensure that attributes and methods defined for C{partial_object} match
attributes and methods defined for C{resource_type}.

@param resource_type: The resource type to check the attributes and
    methods against.
@param partial_object: A dict with key/value pairs representing
    attributes and methods.
N)�itemsrar�_get_method�_check_attribute)rr^�partial_objectr*rIs     rrd�!FakeResource._check_resource_typeBsD��*�/�/�1�K�D��%��*�*�� � ��5��%�%�m�5�A�2rc���SnSnUR5HZup5US:XaURX5up4M [U[5(aUR	X5 MHURXU5 M\ X44$)a�
Ensure that attributes and methods defined for C{partial_object} match
attributes and methods defined for C{resource_type}.  Collection
entries are treated specially.

@param resource_type: The resource type to check the attributes and
    methods against.
@param partial_object: A dict with key/value pairs representing
    attributes and methods.
@return: (name, resource_type), where 'name' is the name of the child
    resource type and 'resource_type' is the corresponding resource
    type.
N�entries)r��_check_entriesrarr�r�)rr^r�r*r�rIs      rr��#FakeResource._check_collection_typeSs}����"��)�/�/�1�K�D��y� �,0�,?�,?�!�-�)��)��E�8�,�,�� � ��5��%�%�m�5�A�2��(�(rc��URX5nUH?nUH6nURS5nUcMURRU5s s $ MA g)z�Find the WADL XML id for the representation of C{resource_type}.

Looks in the WADL for the first representiation associated with the
method for a resource type.

:return: An XML id (a string).
�hrefN)r�rGr�
lookup_xml_id)rr^r*�
get_method�responser��representation_urls       rr}�$FakeResource._find_representation_idosW���%�%�m�:�
�"�H�"*��%3�%7�%7��%?�"�%�1��,�,�:�:�;M�N�N�#+�#rc�L�URUS5nURXBU5 g)ag
Ensure that C{value} is a valid C{name} attribute on C{resource_type}.

Does this by finding the representation for the default, canonical GET
method (as opposed to the many "named" GET methods that exist.)

@param resource_type: The resource type to check the attribute
    against.
@param name: The name of the attribute.
@param value: The value to check.
rGN)r}�_check_attribute_representation)rr^r*rIr�s     rr��FakeResource._check_attribute~s&���-�-�m�U�C���,�,�V�5�Arc�~�URRUnURU5Vs0sHnURU_M nnUS-U;a*UR	XbS-5nURXs5up�gUS-U;a(UR	XbS-5nUR
Xs5 gURU5n
U
c[SU-5eU
Rc([U[5(d[U<SU<35egU
RS:Xa([U[5(d[U<SU<35eggs snf)a�
Ensure that C{value} is a valid value for C{name} with the
representation definition matching C{xml_id}.

@param xml_id: The XML ID for the representation to check the
    attribute against.
@param name: The name of the attribute.
@param value: The value to check.
@raises IntegrityError: Raised if C{name} is not a valid attribute
    name or if C{value}'s type is not valid for the attribute.
r{r|Nz%s not foundz is not a str or unicode for zxsd:dateTimez is not a datetime for )
rr~rr*r�r�rdrGr�typera�strr)rr�r*rIr�rJrr^�
child_namer�r�s           rr��,FakeResource._check_attribute_representation�s]���*�*�E�E�f�M��(�.�.�~�>�
�>��
�J�J���>�	�
��$�$��.� �3�3��0�0�1��M�/3�.I�.I��/�+�J�+��G�^�v�
%� �3�3�F�'�>�4J�K�M��%�%�m�;��J�J�t�$�E��}�$�^�d�%:�;�;��z�z�!�!�%��-�-�(�?D�d�K���.����~�-�!�%��2�2�(�9>��E���3�.��/
s�D:c���X R;agURRS5nU<SU<3n[URSU5unU$![a [U<SU<35ef=f)aGet the C{name} method on C{resource_type}.

@param resource_type: The method's resource type.
@param name: The name of the method.
@raises IntegrityError: Raised if a method called C{name} is not
    available on C{resource_type}.
@return: The XML element for the method from the WADL.
N�id�-z is not a method of )rlr�rGrK�
ValueErrorr)rr^r*�
resource_namer�r�s      rr��FakeResource._get_method�s|���'�'�'��%�)�)�-�-�d�3�
�)�4�0��	�,�]�->�->��f�M�L�Z�
���	�	� �.2�M�B��
�	�s�A�A.c�r�U"U0UD6nXR;dUcU$URURX5$)a�Run a method and convert its result into a L{FakeResource}.

If the result represents an object it is validated against the WADL
definition before being returned.

@param name: The name of the method.
@param method: A callable.
@param args: Arguments to pass to the callable.
@param kwargs: Keyword arguments to pass to the callable.
@return: A L{FakeResource} representing the result if it's an object.
@raises IntegrityError: Raised if the return value from the method
    isn't valid.
)rl�_create_resourcer[)rr*rvrtruros      rrs�FakeResource._run_method�sA����(��(���'�'�'�6�>��M��(�(��)<�)<�d�K�Krc��URRS5nXB:XaSnURX5nUcU$[US5nXPRR
;aUS-
nURR
UnUR
S5(a,URXc5up'[URUUUU5$URXc5 [URU5nUR5Hup�[X�U
5 M U$)a�Create new L{FakeResource} for C{resource_type} method call result.

@param resource_type: The resource type of the method.
@param name: The name of the method on C{resource_type}.
@param result: The result of calling the method.
@raises IntegrityError: Raised if C{result} is an invalid return value
    for the method.
@return: A L{FakeResource} for C{result}, or just C{result} if no
    response representation is defined for the method.
r�rGz-fullz	-resourcez-page-resource)
r�rGr}rRr�resource_typesrNr�r�rdr�r�r))rr^r*ror�r��result_resource_typer��resourcer��child_values           rr��FakeResource._create_resource�s��&�)�)�-�-�d�3�
�� ��D��-�-�m�B���>��M��f�g�.���*�*�9�9�9��k�!�F�#�0�0�?�?��G���?�?�+�,�,�(,�(C�(C�$�)�%�D�"��!�!�$���#��
�
�%�%�&:�C� ��!2�!2�4H�I�H�+1�<�<�>�'�
���k�:�,:��Orc�(�URUS5nURRUn[URSS5un[U5unUR
S5nURS5SnUURRU54$)aGet the name and resource type for the entries in a collection.

@param resource_type: The resource type for a collection.
@return: (name, resource_type), where 'name' is the name of the child
    resource type and 'resource_type' is the corresponding resource
    type.
rGr*�entry_linksr^�#�)	r}rr~rKr��listrG�splitr�)rr^r��representation_definitionr��resource_type_url�resource_type_names       r�_get_child_resource_type�%FakeResource._get_child_resource_types����-�-�m�U�C�����8�8��@�	"�*�%�)�)�6�=�
�
���{�+���)�-�-�o�>��.�4�4�S�9�!�<������/�/�0A�B�
�	
rc�b�URU5up4UHnURXE5 M X44$)awEnsure that C{entries} are valid for a C{resource_type} collection.

@param resource_type: The resource type of the collection the entries
    are in.
@param entries: A list of dicts representing objects in the
    collection.
@return: (name, resource_type), where 'name' is the name of the child
    resource type and 'resource_type' is the corresponding resource
    type.
)r�rd)rr^r�r*r��entrys      rr��FakeResource._check_entriess>��%)�$A�$A��%
�!���E��%�%�&9�A���(�(rc�2�URRRS5nSnURRSU5nURRSU5nSURR
<SU<SU<S[
[U55<S3	$)z}
The resource type, identifier if available, and memory address are
used to generate a representation of this fake resource.
r�r6r*�<� z at �>)r[r�rGr]�	__class__r
�hexr�)rr*�keys   r�__repr__�FakeResource.__repr__1sy��
�"�"�&�&�*�*�4�0�����l�l���t�S�)���l�l���v�s�+���N�N�#�#�����4��M�	
�	
rrrM)r
rrr
rrlr&r,r6r1rkrcr�rdr�r}r�r�r�rsr�r�r�r�rrrrrWrW�ss���!�k�O�
�(.�&)/��� 
�*�X
9�B�")�8
O�
B�(�T�*L�(%�N
�0)�$
rrWc�,^�\rSrSrSrU4SjrSrU=r$)riBz$Fake root object for an application.c�`>�URURS-5n[TU]
X5 g)z�Create a L{FakeResource} for the service root of C{application}.

@param application: A C{wadllib.application.Application} instance.
z
#service-rootN)r��
markup_url�superr&)rr$r^r�s   �rr&�FakeRoot.__init__Es2���
$�5�5��"�"�_�4�
�
�	����4rr)r
rrr
rr&r�
__classcell__�r�s@rrrBs���.�5�5rrc��\rSrSrSrSrg)r�iPzA fake resource for an entry.rNr	rrrr�r�Ps��'rr�c�B^�\rSrSrSrSU4SjjrSrSrSrU=r	$)r�iTz!A fake resource for a collection.c�`>�[TU]XU5 URRXES.5 g)N)�_name�_child_resource_type)r�r&rr)rr$r^r+r*r�r�s      �rr&�FakeCollection.__init__Ws,���	����V�<��
�
����H�	
rc#�# �URRSS5nUH,nURURURU5v� M. g7f)z;Iterate items if this resource has an C{entries} attribute.r�rN)r]rGr�r�r�)rr�r�s   r�__iter__�FakeCollection.__iter__dsI����,�,�"�"�9�b�1���E��'�'��)�)�4�:�:�u��
��s�AAc�L�[U5n[U[5(aTUR=(d SnURnUS:a[S5eUS:a[S5eUR
U5$[U[5(aUR
U5$[S5e)z�Look up a slice, or a subordinate resource by index.

@param key: An individual object key or a C{slice}.
@raises IndexError: Raised if an invalid key is provided.
@return: A L{FakeResource} instance for the entry matching C{key}.
rz6Collection slices must have a nonnegative start point.z>Collection slices must have a definite, nonnegative end point.z!Do not support index lookups yet.)	r�ra�slice�start�stopr��__getitem__�int�
IndexError)rr�r�r�r�s     rr��FakeCollection.__getitem__ls����t�*���c�5�!�!��I�I�N��E��8�8�D��q�y� �O����a�x� �-����&�&�s�+�+�
��S�
!�
!��&�&�s�+�+��@�A�Arr)NNN)
r
rrr
rr&r�r�rr�r�s@rr�r�Ts'���+��
� �

��B�Brr�N)r�collections.abcrr�	ExceptionrrrKrRrUrWrr�r�rrr�<module>r�sq��&/�b%��P�Y�P�X<�X<�vD�
�?�
H
�H
�V5�|�5�(��(�0B�\�0Br

Filemanager

Name Type Size Permission Actions
__init__.cpython-313.pyc File 160 B 0644
helpers.cpython-313.pyc File 8.2 KB 0644
launchpad.cpython-313.pyc File 25.11 KB 0644
resources.cpython-313.pyc File 1.65 KB 0644
Filemanager