Skip to content

Commit

Permalink
Completed getCataId
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavac committed Dec 9, 2023
1 parent 22df765 commit 6dd6fde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rpi_data/modules/notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ API Key: 3eef8a28f26fb2bcc514e6f1938929a1f9317628

Default link? http://rpi.apis.acalog.com/v2/content?

Get courses - http://rpi.apis.acalog.com/v1/content?key=3eef8a28f26fb2bcc514e6f1938929a1f9317628&method=getItems&options[full]=1&catalog=26
Get courses - http://rpi.apis.acalog.com/v1/content?key=3eef8a28f26fb2bcc514e6f1938929a1f9317628&method=getItems&options[full]=1&catalog=26&type=courses


http://rpi.apis.acalog.com/v1/content?key=3eef8a28f26fb2bcc514e6f1938929a1f9317628&format=xml&method=getItems&options[full]=1&catalog=26&type=courses&ids[]=59451&ids[]=59452&ids[]=60917&ids[]=60918&ids[]=59454&ids[]=59455&ids[]=59456&ids[]=60955&ids[]=61524&ids[]=61525&ids[]=61526&ids[]=59457&ids[]=60933&ids[]=60934&ids[]=60935&ids[]=60936&ids[]=60939&ids[]=60940&ids[]=60941&ids[]=60942&ids[]=60948&ids[]=60949&ids[]=59458&ids[]=59459&ids[]=60956&ids[]=60913&ids[]=60938&ids[]=61007&ids[]=60919&ids[]=60920&ids[]=60921&ids[]=59453&ids[]=60916&ids[]=60915&ids[]=67677&ids[]=59460&ids[]=61527&ids[]=61528&ids[]=60951&ids[]=60952&ids[]=60950&ids[]=59461&ids[]=60953&ids[]=59462&ids[]=60914&ids[]=60954&ids[]=59463&ids[]=60945&ids[]=61245&ids[]=60946&ids[]=61246&ids[]=61253&ids[]=61196&ids[]=60943&ids[]=60944&ids[]=59464&ids[]=59465&ids[]=59466&ids[]=61186&ids[]=61136&ids[]=61137&ids[]=60937&ids[]=60947&ids[]=59467&ids[]=59468&ids[]=61016&ids[]=61021&ids[]=61018&ids[]=61027&ids[]=61020&ids[]=61024&ids[]=61017&ids[]=61023&ids[]=61019&ids[]=61022&ids[]=61025&ids[]=61033&ids[]=61030&ids[]=61034&ids[]=61036&ids[]=59469&ids[]=59470&ids[]=59471&ids[]=59472&ids[]=59473&ids[]=59474&ids[]=60924&ids[]=60925&ids[]=61070&ids[]=61067&ids[]=59475&ids[]=59476&ids[]=61026&ids[]=61029&ids[]=61032&ids[]=61028&ids[]=61031&ids[]=59477&ids[]=59478&ids[]=59479
Expand Down
19 changes: 9 additions & 10 deletions rpi_data/modules/prereq_parse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Ok so this file should take in some inputs (what though) and output a dictionary.
#This dictionary has all of the courses' crn as the keys and the value as the relevant information
#This dictionary has all of the courses' course code as the keys and the value as the relevant information
#See fetch_catalog_course_info.py for the source of a lot of the code
#It's just that I will be rewriting it so that it is (hopefully) more understandable and better documented
import requests as req
Expand All @@ -20,7 +20,7 @@
class PrereqParse:
def __init__(self, api_key):
self.key = api_key
self.search_endpoint = "http://rpi.apis.acalog.com/v2/search/courses"
self.search_endpoint = "http://rpi.apis.acalog.com/v2/search/courses?"
self.course_detail_endpoint = "http://rpi.apis.acalog.com/v2/content?options[full]=1&method=getItems&type=courses"
self.catalogIdEndpoint = "http://rpi.apis.acalog.com/v2/content?key=3eef8a28f26fb2bcc514e6f1938929a1f9317628&format=xml&method=getCatalogs"
self.resFormat = "xml"
Expand All @@ -37,19 +37,18 @@ def getCataId(self, year : int):
tree = etree.parse(StringIO(res.content.decode()))
root = tree.getroot()
try:
pdb.set_trace()
#currentCatalog = root.xpath("//*[local-name() = 'archived'][contains(text(), 'No')]")
#currentCatalog = root.xpath("//*[local-name() = 'archived']")
#tree.xpath("//*[local-name() = 'archived']")[0].getparent().getparent().attrib['id']
#TODO: Rewrite in regex
#TODO: get the catalog id from this
retCata = root.xpath("//*[local-name() = 'archived']")[0].getparent().getparent().attrib['id']
return 0
#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'])
except Exception as exception:
print("Failed to get the catalog id")
#Return the endpoint of the course ids
def getCourseIds(self):
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 Down

0 comments on commit 6dd6fde

Please sign in to comment.