Base

Just another Python API for Travis CI (API).

A module which provides the base of all communicator.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Project link:
https://github.com/funilrys/PyTravisCI
Project documentation:
https://pytravisci.readthedocs.io/en/latest/

License

MIT License

Copyright (c) 2019, 2020 Nissar Chababy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
class PyTravisCI.communicator.base.CommunicatorBase(req: PyTravisCI.requester.Requester)[source]

Provides the base of all communicator.

complete_response()[source]

A decorator which complete the responses before giving it back to the end-user.

delete_response(endpoint: str) → Union[dict, bool][source]

DELETE and provides the response from the API.

classmethod encode_slug(slug: str) → str[source]

Encodes the (repository) slug.

endpoints = {}

Should be a dict in format:

{
    "from_id": "/build/%(build_id)s"
}

from_id is the name of the method and build/%(build_id)s is the endpoint we need to communicate with. %(build_id)s is what the method will expect as variable name. In fact, if the end-user give us build_id=4 as argument, the system will replace %(build_id)s with 4.

filter_before_action()[source]

A decorator which filter/format the given arguments before giving it back to the communicator method.

This is useful in order to avoid having the same thing over and over everywhere.

get_and_construct_endpoint(kwargs: dict) → str[source]

Provides the endpoint to call from the given method name.

static get_method_name() → str[source]

Provides the method name.

Warning

You are not invited to use this method outside of PyTravisCI’s communicators.

get_response(endpoint: str) → dict[source]

Provides the response from the API.

get_standardized(data: dict) → Any[source]

Provides the standardized version of the given dataset.

static is_digit(data: Union[str, int]) → bool[source]

Checks if the given data is an integer or a digit string.

patch_response(endpoint: str, data: dict = None) → dict[source]

PATCH and provides the response from the API.

post_response(endpoint: str, data: dict = None) → dict[source]

POST and provides the response from the API.

classmethod propagate_internal_vars(variables: dict, start_obj: Any) → object[source]

Propagate the given var to all objects.

Warning

You are not invited to use this method outside of PyTravis’s communicators.