• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SwissDataScienceCenter / renku-python / 6875247711

15 Nov 2023 09:16AM UTC coverage: 82.786% (-0.05%) from 82.831%
6875247711

Pull #3300

github

web-flow
Merge e2d3269e8 into 4726f660e
Pull Request #3300: chore: do not always retry load tests requests

25441 of 30731 relevant lines covered (82.79%)

3.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.65
/renku/domain_model/image.py
1
# Copyright Swiss Data Science Center (SDSC). A partnership between
2
# École Polytechnique Fédérale de Lausanne (EPFL) and
3
# Eidgenössische Technische Hochschule Zürich (ETHZ).
4
#
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
8
#
9
#     http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
"""Image model."""
7✔
17

18
from pathlib import Path
7✔
19
from typing import Union
7✔
20
from urllib.parse import urlparse
7✔
21

22
from renku.core.util.urls import get_path, is_remote
7✔
23
from renku.infrastructure.immutable import Slots
7✔
24

25

26
class ImageObject(Slots):
7✔
27
    """Represents a schema.org ``ImageObject``."""
28

29
    __slots__ = ("content_url", "id", "position")
7✔
30

31
    id: str
7✔
32
    content_url: str
7✔
33
    position: int
7✔
34

35
    def __init__(self, *, content_url: Union[str, Path], id: str, position: int):
7✔
36
        id = get_path(id)
1✔
37
        super().__init__(content_url=str(content_url), position=position, id=id)
1✔
38

39
    @staticmethod
7✔
40
    def generate_id(owner_id: str, position: int) -> str:
7✔
41
        """Generate @id field."""
42
        return f"{owner_id}/images/{position}"
1✔
43

44
    @property
7✔
45
    def is_absolute(self):
7✔
46
        """Whether content_url is an absolute or relative url."""
47
        return bool(urlparse(self.content_url).netloc)
×
48

49
    @property
7✔
50
    def is_remote(self) -> bool:
7✔
51
        """Return True if the URI isn't on the local filesystem."""
52
        return is_remote(self.content_url)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc