-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbaa4ee
commit ea607d5
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from types import NoneType | ||
|
||
import validators | ||
|
||
|
||
class Image: | ||
def __init__(self, image_id: str, page_number: int, url: str | None): | ||
self.id = image_id | ||
self.page_number = page_number | ||
self.__url = None | ||
|
||
self.url = url | ||
|
||
@property | ||
def url(self): | ||
return self.__url | ||
|
||
@url.setter | ||
def url(self, url: str | None): | ||
if not isinstance(url, (str, NoneType)): | ||
raise TypeError(f"Url must be str or None got {type(url)}") | ||
if url is not None and not validators.url(url): | ||
raise ValueError(f"Url {url} is not valid") | ||
self.__url = url | ||
|
||
@staticmethod | ||
def get_empty_instance(): | ||
return Image("", 1, None) |