Skip to content

Commit

Permalink
Removed old images
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavac committed Jan 15, 2024
1 parent 3d78120 commit 29c7ace
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions rpi_data/modules/READEME.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ lxml
regex
pyyaml
selenium
regex
lxml

# Course Parser
Hopefully this will be the last one.
Expand Down
Binary file removed rpi_data/modules/image-1.png
Binary file not shown.
Binary file removed rpi_data/modules/image-2.png
Binary file not shown.
Binary file removed rpi_data/modules/image-3.png
Binary file not shown.
Binary file removed rpi_data/modules/image-4.png
Binary file not shown.
Binary file removed rpi_data/modules/image-5.png
Binary file not shown.
28 changes: 16 additions & 12 deletions rpi_data/modules/prereq_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def __init__(self, api_key):
self.catalogIdEndpoint = "http://rpi.apis.acalog.com/v2/content?key=3eef8a28f26fb2bcc514e6f1938929a1f9317628&format=xml&method=getCatalogs"
self.resFormat = "xml"
self.catalogId = 0
self.lock = Lock()
self.courseDetailsXMLStr = []
self.xmlProlog = ""
self.catalogRoot = ""
self._lock = Lock()
self._courseDetailsXMLStr = []
self._xmlProlog = ""
self._catalogRoot = ""
self.chunkSize = 100
self.courses = dict()
#Returns the current catalog id for the specified year
Expand All @@ -37,18 +37,22 @@ def getCataId(self, year : int):
tree = etree.parse(StringIO(res.content.decode()))
root = tree.getroot()
try:
#TODO: Test this
key = "Rennselaer Catalog " + year + "-" + (year + 1)
for paths in root.xpath("//text()"):
if path == key:
return re.search("(?P<id>\d+)$", path.getparent().getparent().attrib['id'])
key = "Rensselaer Catalog " + str(year) + "-" + str(year + 1)
#https://stackoverflow.com/questions/53459703/type-lxml-etree-elementunicoderesult-cannot-be-serialized
for path in root.xpath("//text()"):
if ''.join(str(s) for s in path) == key: #Could also use path.__str__() == key
return re.search("(?P<id>\d+)$", path.getparent().getparent().attrib['id']).group('id')
except Exception as exception:
print("Failed to get the catalog id")
#Return the endpoint of the course ids
def getCourseIds(self):
pdb.set_trace()
#http://rpi.apis.acalog.com/v2/search/courses?key=3eef8a28f26fb2bcc514e6f1938929a1f9317628&format=xml&method=listing&catalog=26&options[limit]=0
xmlLink = (f"{self.search_endpoint}key={self.key}&format={self.resFormat}&method=listing&catalog={self.catalogId}&options[limit]=0")
idXML = req.get(xmlLink).content.decode("utf8") #The xml is returned as bytes, so we need to turn it into a string
with self._lock:

return 0
idXML = req.get("{self.search_endpoint}?key={self.key}&format={self.resFormat}&method=listing&catalog={self.cataId}&options[limit]=0").content

#Return a dictionary of every course in the catalog
def getAllCourses(self):
return 0
Expand All @@ -60,7 +64,7 @@ def run(self, year):
#Maybe make some feature to get the catalog for every year?
self.catalogId = self.getCataId(year)
ids = self.getCourseIds()
courses = getAllCourses()
courses = self.getAllCourses()

def main():
parser = PrereqParse("3eef8a28f26fb2bcc514e6f1938929a1f9317628")
Expand Down

0 comments on commit 29c7ace

Please sign in to comment.