-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
205 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import json | ||
from pathlib import Path | ||
from .patchfile import Patchfile | ||
from time import time_ns | ||
from alive_progress import alive_bar | ||
|
||
''' | ||
Generates Patchfiles for the Core Curriculum | ||
''' | ||
def generate(source: Path, destination: Path): | ||
destination.mkdir(exist_ok=True) | ||
with open(source / 'defaults.json', 'r') as f: | ||
data = json.loads(f.read()) | ||
with alive_bar(len(data)) as bar: | ||
for item in data: | ||
with open(destination / f'patch-0-{time_ns()}.json', 'w') as out: | ||
out.write(str( | ||
Patchfile(f'/groups/{item["identifier"]}').write(item) | ||
)) | ||
bar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
import csv | ||
from pathlib import Path | ||
from . import util | ||
from .patchfile import Patchfile | ||
from time import time_ns | ||
from alive_progress import alive_bar | ||
|
||
''' | ||
Generates Patchfiles for connections to the UH Publications official course catalog | ||
''' | ||
def generate(source: Path, destination: Path): | ||
print(source.name) | ||
# destination.mkdir(exist_ok=True) | ||
# with open(source / 'subjects.json', 'r') as f: | ||
# data = json.loads(f.read()) | ||
# entries = [unwrap(s) for s in data] | ||
# results = dict() | ||
# for e in entries: | ||
# results[e['abbreviation']] = e['description'] | ||
# with open(destination / 'entries.json', 'w') as ex: | ||
# ex.write(json.dumps(entries)) | ||
# with open(destination / 'dictionary.json', 'w') as ex: | ||
# ex.write(json.dumps(results)) | ||
destination.mkdir(exist_ok=True) | ||
with open(source / 'pairs.csv', 'r') as infile: | ||
with alive_bar(util.file_len((source / 'pairs.csv').resolve())-1) as bar: | ||
reader = csv.DictReader(infile) | ||
for row in reader: | ||
with open(destination / f'patch-2-{time_ns()}.json', 'w') as out: | ||
out.write(str( | ||
Patchfile(f'/catalog/{row["department"]} {row["catalogNumber"]}').merge({ | ||
"publication": { | ||
"title": row["title"], | ||
"catoid": row["catoid"], | ||
"coid": row["coid"], | ||
"classification": row["classification"], | ||
"url": f'http://publications.uh.edu/preview_course_nopop.php?catoid={row["catoid"]}&coid={row["coid"]}' if row["catoid"] != None and row["coid"] != None else "" | ||
} | ||
}) | ||
)) | ||
bar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
import json | ||
from pathlib import Path | ||
from .patchfile import Patchfile | ||
from time import time_ns | ||
from alive_progress import alive_bar | ||
|
||
''' | ||
Generates patchfiles for individual subject groups | ||
''' | ||
def generate(source: Path, destination: Path): | ||
print(source.name) | ||
# destination.mkdir(exist_ok=True) | ||
# with open(source / 'subjects.json', 'r') as f: | ||
# data = json.loads(f.read()) | ||
# entries = [unwrap(s) for s in data] | ||
# results = dict() | ||
# for e in entries: | ||
# results[e['abbreviation']] = e['description'] | ||
# with open(destination / 'entries.json', 'w') as ex: | ||
# ex.write(json.dumps(entries)) | ||
# with open(destination / 'dictionary.json', 'w') as ex: | ||
# ex.write(json.dumps(results)) | ||
destination.mkdir(exist_ok=True) | ||
with open(source / 'entries.json', 'r') as f: | ||
entries = json.loads(f.read()) | ||
with alive_bar(len(entries)) as bar: | ||
for item in entries: | ||
with open(destination / f'patch-1-{time_ns()}.json', 'w') as out: | ||
out.write(str( | ||
Patchfile(f'/groups/{item["abbreviation"]}').write({ | ||
"name": item["description"], | ||
"identifier": item["abbreviation"], | ||
"courses": [], | ||
"keywords": [], | ||
"description": f'Courses from the \"{item["abbreviation"]}\" subject.', | ||
"courses_count": 0 | ||
}) | ||
)) | ||
bar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
# see: https://stackoverflow.com/q/845058 | ||
def file_len(fname): | ||
with open(fname) as f: | ||
for i, l in enumerate(f): | ||
pass | ||
return i + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# io.cougargrades.groups | ||
|
||
## Format | ||
|
||
See: [@cougargrades/types](https://github.com/cougargrades/types/issues/5) | ||
|
||
## Data Aquisition | ||
|
||
Manually entered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
[ | ||
{ | ||
"name": "Communication", | ||
"identifier": "10", | ||
"description": "Courses which satisfy the \"Communication\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "Mathematics", | ||
"identifier": "20", | ||
"description": "Courses which satisfy the \"Mathematics\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "Life & Physical Sciences", | ||
"identifier": "30", | ||
"description": "Courses which satisfy the \"Life & Physical Sciences\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "Language, Philosophy, & Culture", | ||
"identifier": "40", | ||
"description": "Courses which satisfy the \"Language, Philosophy, & Culture\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "Creative Arts", | ||
"identifier": "50", | ||
"description": "Courses which satisfy the \"Creative Arts\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "American History", | ||
"identifier": "60", | ||
"description": "Courses which satisfy the \"American History\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "Government/Political Science", | ||
"identifier": "70", | ||
"description": "Courses which satisfy the \"Government/Political Science\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "Social & Behavioral Sciences", | ||
"identifier": "80", | ||
"description": "Courses which satisfy the \"Social & Behavioral Sciences\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "Writing in the Disciplines", | ||
"identifier": "81", | ||
"description": "Courses which satisfy the \"Writing in the Disciplines\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
}, | ||
{ | ||
"name": "Math/Reasoning", | ||
"identifier": "91", | ||
"description": "Courses which satisfy the \"Math/Reasoning\" component in the UH Core Curriculum.", | ||
"keywords": [], | ||
"courses": [], | ||
"courses_count": 0 | ||
} | ||
] |