Skip to content

check_web_hosting_service

WebHostingServiceChecker

Check if CI config is out-of-the-box ok to integrate with hosting services

Source code in src/cookiecutter_python/backend/hosting_services/check_web_hosting_service.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
@attr.s(auto_attribs=True, slots=True, frozen=True)
class WebHostingServiceChecker:
    # Check if CI config is out of the box ok to integrate with hosting services
    # or due to namespace collisions (ie on pypi.org/project/<name>, slight change is needed
    """Check if CI config is out-of-the-box ok to integrate with hosting services"""
    url_getter: Callable[[str], str]

    def __call__(self, name: str):
        session = FuturesSession()
        future = session.get(self.url_getter(name))
        return type(
            'RequestResult',
            (),
            {'future': future, 'name': name, 'service_name': str(self.url_getter)},
        )

    def __str__(self):
        return str(self.url_getter)

    @staticmethod
    def create(hosting_service):
        return WebHostingServiceChecker(hosting_service.url)