| 1 | class Station: |
| 2 | """ |
| 3 | A class representing a Meteoclimatic station. |
| 4 | |
| 5 | :param name: Name of the station |
| 6 | :type name: `str` |
| 7 | :param code: Meteoclimatic code of the station |
| 8 | :type code: `str` |
| 9 | :param url: URL of the station |
| 10 | :type url: `str` |
| 11 | :returns: a *Station* instance |
| 12 | :raises: *ValueError* when invalid empty or null values are provided |
| 13 | """ |
| 14 | |
| 15 | def __init__(self, name: str, code: str, url: str): |
| 16 | """Initialize the class.""" |
| 17 | if name is None or len(name) == 0: |
| 18 | raise ValueError("Station name cannot be empty") |
| 19 | self.name = name |
| 20 | |
| 21 | if code is None or len(code) == 0: |
| 22 | raise ValueError("Station code cannot be empty") |
| 23 | self.code = code |
| 24 | self.url = url |
| 25 | |
| 26 | def __eq__(self, other): |
| 27 | if not isinstance(other, Station): |
| 28 | return NotImplemented |
| 29 | prop_names = list(self.__dict__) |
| 30 | for prop in prop_names: |
| 31 | if self.__dict__[prop] != other.__dict__[prop]: |
| 32 | return False |
| 33 | return True |
| 34 | |
| 35 | def __repr__(self): |
| 36 | return "%s(%r)" % (self.__class__, self.__dict__) |