-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 45 #82
Issue 45 #82
Changes from all commits
99f1a38
60849fc
8b5c60d
0758ca5
1042e34
f62d664
7e7c42d
a1b305e
388d3fb
3195f2d
1085c76
98a9660
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Contributing Guidelines | ||
1. Please maintain proper commenting etiqiutte. Pretend that this is a work environment and that the comments are being reviewed by coworkers. | ||
1. Please maintain proper commenting etiquette. Pretend that this is a work environment and that the comments are being reviewed by coworkers. | ||
1. Ensure that your changes compile/work before opening a PR. | ||
1. Follow style guidelines where applicable. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
|
||
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally I wouldn't impose my style on the project, but I already had this committed and this stuck around after rebasing... |
||
from typing import List, Dict | ||
|
||
session = requests.session() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
from typing import Dict, List | ||
from typing import Dict, List, Union | ||
|
||
session = requests.session() | ||
|
||
|
@@ -77,7 +77,7 @@ def get_status_simple(building_name: str) -> Dict[str,str]: | |
return di | ||
|
||
|
||
def get_status_detailed(building_name: str) -> List[Dict[str,str]]: | ||
def get_status_detailed(building_name: str) -> List[Dict[str,Union[str,int]]]: | ||
building_name = building_name.upper() | ||
|
||
# Get a cookie | ||
|
@@ -88,34 +88,34 @@ def get_status_detailed(building_name: str) -> List[Dict[str,str]]: | |
# Get the weird laundry data | ||
headers = {"Cookie": "PHPSESSID={}".format(cookie)} | ||
response = requests.get("http://www.laundryview.com/dynamicRoomData.php?location={}".format( | ||
location_dict[building_name]), headers=headers).text | ||
resp_split = response.split('&')[3:] | ||
location_dict[building_name]), headers=headers) | ||
resp_split = response.text.split('&')[3:] | ||
|
||
cleaned_resp = [] | ||
cleaned_resp = [] # type: List[List[str]] | ||
for status_string in resp_split: | ||
if "machine" not in status_string: | ||
continue | ||
machine_name = status_string[:status_string.index('=')].replace('Status', '') #type: str | ||
status_string = status_string[status_string.index('=') + 1:].strip() | ||
|
||
old_machine_split = status_string.split("\n") #type: List[str] | ||
old_machine_split[0] += machine_name | ||
status_lines = status_string.split("\n") #type: List[str] | ||
status_lines[0] += machine_name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is another instance where I normally wouldn't have renamed this variable, but my changes conflicted with someone else who renamed it, and I think the name |
||
|
||
try: | ||
old_machine_split[1] += machine_name | ||
status_lines[1] += machine_name | ||
except IndexError: | ||
pass | ||
|
||
machine_split = [x.split(':') for x in old_machine_split] | ||
cleaned_resp.append(machine_split[0]) | ||
split_status_lines = [x.split(':') for x in status_lines] | ||
cleaned_resp.append(split_status_lines[0]) | ||
try: | ||
cleaned_resp.append(machine_split[1]) | ||
cleaned_resp.append(split_status_lines[1]) | ||
except IndexError: | ||
pass | ||
|
||
cleaned_resp = [x for x in cleaned_resp if len(x) == 10] | ||
|
||
di = [] # type: List[Dict[str,str]] | ||
di = [] # type: List[Dict[str,Union[str,int]]] | ||
for machine in cleaned_resp: | ||
time_left = -1 | ||
machine_name = "{}_{}".format(machine[9], machine[3]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,8 +107,8 @@ def test_make_status(self): | |
self.assertEqual(open[keys[0]], 'open') | ||
|
||
for key in keys[1:]: | ||
self.assertEqual(closed[key], 0) | ||
self.assertEqual(open[key], 1) | ||
self.assertEqual(closed[key], '0') | ||
self.assertEqual(open[key], '1') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are all cast to strings here: https://github.com/Pitt-CSC/PittAPI/pull/82/files#diff-1c156c9a7cf25c89ef4fd8323d5c4d35L66 |
||
|
||
def test_extract_machines(self): | ||
data = '123 hello_world, 456 macOS, 789 cool, 3 nice' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase conflicts... I just tend to put things in alphabetical order.