Skip to content

Commit

Permalink
bump: 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdur-rahmaanJ committed Jan 19, 2023
1 parent a41cc6e commit 854c4f3
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 16 deletions.
78 changes: 67 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,61 @@ Venv explanations at footer.

# Examples

NOTE: Add `print=True` to get a tabular representation

```python
>>> from meteomoris import *

>>> get_main_message()
"A Strong Wind Warning and High Wave Warning for Mauritius | Aucun avertissement de cyclone n'est en vigueur a Maurice | Avertissement de fortes houles pour Rodrigues"
>>> get_main_message(links=True)
[
('The Mauritius Meteorological Services (Warnings) Regulations 2023', 'http://metservice.intnet.mu/about-us/legislations/'),
('Heavy Rain warning Bulletin for Mauritius issued at 0500 hours on Thursday 19 January 2023, valid until 0500 hours Friday 20 January 2023.', 'http://metservice.intnet.mu/warning-bulletin-special-weather.php')
]
>>> get_special_whether_bulletin()
Special Weather Bulletin
Thu, Jan 19, 2023Heavy Rain warning Bulletin for Mauritius issued at 0500 hours on Thursday 19 January 2023, valid until 0500 hours  Friday 20 January 2023.

Heavy rain warning is in force in Mauritius
Active clouds coming from the North-East are influencing the local weather.
Moderate to heavy showers with thunderstorms are expected over the island.

The public is advised to:
1. Remain in safe places and avoid open areas, hikings, sea ventures and sheltering under trees during thunderstorms.
2. Avoid places prone to water accumulation, river banks and other water courses which are flooded and certain mountain slopes prone to landslide
3. Be very cautious on the roads due to reduced visibility resulting from heavy rains and fog patches

...
>>> get_weekforecast()
[
{'condition': 'Few showers highgrounds',
'date': 'Apr 22',
'day': 'Mon',
'max': '32�',
'min': '21�',
'probability': 'High',
'sea condition': 'rough',
'wind': 'E25G50'},
{
'condition': 'Few showers highgrounds',
'date': 'Apr 22',
'day': 'Mon',
'max': '32�',
'min': '21�',
'probability': 'High',
'sea condition': 'rough',
'wind': 'E25G50'
},
{
...
}
]

>>> get_weekforecast(print=True)
Week forecast
┏━━━━━┳━━━━━━━━┳━━━━━┳━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Day ┃ Date ┃ Min ┃ Max ┃ Condition ┃ Sea condition ┃ Wind ┃
┡━━━━━╇━━━━━━━━╇━━━━━╇━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Thu │ Jan 1919° │ 30° │ Moderate to locally heavy showers with isolated thunderstorms │ rough │ ENE25G50
│ Fri │ Jan 2020° │ 30° │ Moderate to locally heavy showers with isolated thunderstorms │ rough │ NE20
│ Sat │ Jan 2120° │ 30° │ Moderate showers with isolated thunderstorms │ moderate │ NE20
│ Sun │ Jan 2220° │ 30° │ Moderate showers with isolated thunderstorms │ moderate │ N15 │
│ Mon │ Jan 2320° │ 30° │ Moderate to heavy thundery showers │ rough │ N15 │
│ Tue │ Jan 2420° │ 30° │ Moderate to heavy thundery showers │ rough │ N20 │
│ Wed │ Jan 2520° │ 30° │ Moderate to heavy thundery showers │ rough │ N25 │
└─────┴────────┴─────┴─────┴───────────────────────────────────────────────────────────────┴───────────────┴──────────┘
>>> get_weekforecast(day=3)
{'condition': 'Few passing showers',
'date': 'Apr 25',
Expand All @@ -57,10 +91,12 @@ Venv explanations at footer.


>>> get_moonphase()
{'April 2019': {'first quarter': {'date': '12', 'hour': '23', 'minute': '06'},
{'April 2019': {
'first quarter': {'date': '12', 'hour': '23', 'minute': '06'},
'full moon': {'date': '19', 'hour': '15', 'minute': '12'},
'last quarter': {'date': '27', 'hour': '02', 'minute': '18'},
'new moon': {'date': '05', 'hour': '12', 'minute': '50'}},
'new moon': {'date': '05', 'hour': '12', 'minute': '50'}
},
'May 2019': {'first quarter': {'date': '12', 'hour': '05', 'minute': '12'},
...

Expand Down Expand Up @@ -130,6 +166,22 @@ dict_keys(['february', 'march'])

```

# Cli

```
Usage: meteomoris [OPTIONS] COMMAND [ARGS]...

Options:
--help Show this message and exit.

Commands:
dashboard
forecast Week forecast
message Message of the day
sunrisemu Sunrise (Mauritius)
sunriserodr Sunrise (Rodrigues)
```

# Global settings

```python
Expand Down Expand Up @@ -195,6 +247,10 @@ Run
# Changelog


## 2.2.0

- Add print commands and API

## 2.1.0

- Fix get_moonphase
Expand Down
2 changes: 1 addition & 1 deletion meteomoris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
get_equinoxes = Meteo.get_equinoxes
get_solstices = Meteo.get_solstices

__version__ = "2.1.0"
__version__ = "2.2.0"
7 changes: 4 additions & 3 deletions meteomoris/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ def sunrisemu():
def sunriserodr():
get_sunriserodr(print=True)

@cli.command(help="Sunrise (Rodrigues)")
def message():
get_main_message(print=True)
@cli.command(help="Message of the day")
@click.option("--links", is_flag=True, show_default=True, default=False, help="Show message links")
def message(links):
get_main_message(print_=True, links=links)

def main():
cli(obj={})
Expand Down
18 changes: 17 additions & 1 deletion meteomoris/meteo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pprint import pprint
from rich.console import Console
from rich.table import Table
from rich.panel import Panel
except Exception as e:
pass

Expand Down Expand Up @@ -340,10 +341,11 @@ def get_moon_str(d, key):
return data[month]

@classmethod
def get_main_message(cls, links=False):
def get_main_message(cls, print_=False, links=False):
"""
Get the main message of website
"""
print_ = print_
cls.check_internet()
URL = "http://metservice.intnet.mu"
r = requests.get(URL, headers=cls.headers)
Expand All @@ -353,7 +355,21 @@ def get_main_message(cls, links=False):

if links:
message_links = [(link.text.strip(), link.get('href')) for link in message.find_all('a')]
if print_:
console = Console()
table = Table(title='Info')
table.add_column('Message')
table.add_column('Link')
for l in message_links:
table.add_row(l[0], l[1])
console.print(table)
return message_links


if print_:
console = Console()
console.print(Panel(message.text.strip(), title="Meteo message"))
return
return message.text.strip()

@classmethod
Expand Down
4 changes: 4 additions & 0 deletions mmm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from meteomoris import *


get_sunriserodr(print=True)

0 comments on commit 854c4f3

Please sign in to comment.