Skip to content

Commit efbc811

Browse files
committed
v0.65.6: Reverted some of the error checking from v0.65.2 and updated README
1 parent cd559e1 commit efbc811

6 files changed

Lines changed: 28 additions & 69 deletions

File tree

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ professors = Professors()
3535
courses = Courses()
3636
```
3737

38+
```python
39+
from umd_api.weather import Weather, Forecast
40+
41+
weather = Weather()
42+
forecast = Forecast()
43+
```
44+
3845
## Methods
3946

4047
<details>
@@ -103,6 +110,22 @@ courses = Courses()
103110
- `get_course(name, reviews=False)`
104111
- `get_courses(department=None, reviews=False, limit=100, offset=0)`
105112
</details>
113+
<details>
114+
<summary><strong>Weather</strong></summary>
115+
116+
**Weather**
117+
- `get_weather_data(station="", start_time="", end_time=")`
118+
- `get_hourly_forecast()`
119+
- `save_radar_gif()`
120+
- `get_weather_descrption()`
121+
---
122+
123+
**Forecast**
124+
- `get_hourly_forecast()`
125+
- `get_weekly_forecast()`
126+
127+
</details>
128+
106129

107130
### Wakatime (Time Spent Programming)
108131

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "umd-api"
7-
version = "0.65.5"
7+
version = "0.65.6"
88
description = "A package for accessing the UMD API in Python"
99
readme = "README.md"
1010
authors = [
@@ -22,5 +22,5 @@ dependencies = [
2222
requires-python = ">=3.10"
2323

2424
[project.urls]
25-
"Documentation" = "https://github.com/Nazchanel/umd-api-python"
25+
"Documentation" = "https://github.com/Nazchanel/umd-api-python/blob/master/README.md"
2626
"Source" = "https://github.com/Nazchanel/umd-api-python"

umd_api/planet_terp/courses.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,4 @@ def get_courses(self, department=None, reviews=False, limit=100, offset=0):
2222
2323
"""
2424

25-
if department is not None and len(department) != 4:
26-
raise ValueError("If provided, department must be exactly 4 characters long.")
27-
28-
if limit is not None and not (1 <= limit <= 1000):
29-
raise ValueError("Limit must be between 1 and 1000 inclusive.")
30-
31-
if offset is not None and offset < 0:
32-
raise ValueError("Offset must be a non-negative integer.")
33-
3425
return self._make_request(self._ENDPOINT_COURSES, department=department, reviews=self._bool_to_string(reviews), limit=limit, offset=offset)

umd_api/planet_terp/grades.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ def get_grades(self, course=None, professor=None, semester=None, section=None):
1111
1212
"""
1313

14-
1514
return self._make_request(self._ENDPOINT_GRADES, course=course, professor=professor, semester=semester, section=section)
16-

umd_api/planet_terp/professors.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,4 @@ def get_all_professors(self, type=None, reviews=False, limit=100, offset=0):
2222
2323
"""
2424

25-
if isinstance(type, str):
26-
type = type.lower()
27-
28-
if type != 'professor' and type != 'ta':
29-
raise ValueError("Type must be 'professor' or 'ta'")
30-
31-
if not (1 <= limit <= 1000):
32-
raise ValueError("Limit must be between 1 and 1000 inclusive.")
33-
34-
if offset is not None and offset < 0:
35-
raise ValueError("Offset must be a non-negative integer.")
36-
37-
return self._make_request(self._ENDPOINT_PROFESSORS, type=type, reviews=self._bool_to_string(reviews), limit=limit,
38-
offset=offset)
25+
return self._make_request(self._ENDPOINT_PROFESSORS, type=type, reviews=self._bool_to_string(reviews), limit=limit, offset=offset)

umd_api/weather/weather.py

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from datetime import datetime
88

99
class Weather():
10-
def get_weather_data(station="", start_time="", end_time=""):
10+
def get_weather_data(self, station="", start_time="", end_time=""):
1111
"""
1212
Valid Parameters:
1313
station: 'williams', 'atlantic', 'vmh', 'golf', 'chem'
@@ -118,47 +118,7 @@ def validate_date_format(date_str):
118118
except requests.exceptions.RequestException as e:
119119
raise RuntimeError(f"API request failed: {e}")
120120

121-
def get_hourly_forecast():
122-
hourly_forecast = []
123-
url = "https://weather.umd.edu/"
124-
125-
response = requests.get(url)
126-
soup = BeautifulSoup(response.text, 'html.parser')
127-
a = soup.find('div', id="umdwx_weeklyfcst_widget-9")
128-
129-
for day in a.find_all('div', class_='fcst_day')[:5]: # First 5 elements are hourly forecast
130-
time = day.find('div', class_='fcst_txt-day').text.strip()
131-
temp = day.find('div', class_='fcst_txt-temp')
132-
wind = day.find('div', class_='fcst_txt-wind')
133-
134-
temp = temp.text.replace('\u2009', ' ').replace('F', ' ').strip()
135-
136-
wind = re.sub(r'[^\x00-\x7F]+', '', wind.text)
137-
138-
wind = wind.replace('mph', '').strip()
139-
140-
hour, period = time.split()
141-
142-
hour = int(hour)
143-
144-
if period == 'PM' and hour != 12:
145-
hour += 12
146-
elif period == 'AM' and hour == 12:
147-
hour = 0
148-
149-
time = hour
150-
151-
152-
if time and temp and wind: # Ensure elements exist
153-
hourly_forecast.append({
154-
'time': time,
155-
'temperature': temp,
156-
'wind': wind
157-
})
158-
return hourly_forecast
159-
160-
161-
def save_radar_gif(dir=""):
121+
def save_radar_gif(self, dir=""):
162122
"""
163123
Downloads the latest radar GIF and saves it to the specified directory.
164124

0 commit comments

Comments
 (0)