From da4752626bc57e15672c92c9191184966c9af8c1 Mon Sep 17 00:00:00 2001 From: Guinslym Date: Tue, 19 Nov 2024 14:59:02 -0500 Subject: [PATCH] new version --- README.md | 66 ++- ask_schools/__init__.py | 252 ----------- poetry.lock | 270 ++++++++++++ pyproject.toml | 46 +- sp_ask_school/__init__.py | 17 + sp_ask_school/schools.py | 415 ++++++++++++++++++ .../{test_ask_schools.py => test_schools.py} | 7 +- 7 files changed, 775 insertions(+), 298 deletions(-) delete mode 100644 ask_schools/__init__.py create mode 100644 poetry.lock create mode 100644 sp_ask_school/__init__.py create mode 100644 sp_ask_school/schools.py rename tests/{test_ask_schools.py => test_schools.py} (56%) diff --git a/README.md b/README.md index e68470e..6c40473 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,58 @@ -# Ask Schools - -[ -![PyPI](https://img.shields.io/pypi/v/ask_schools.svg) -![PyPI](https://img.shields.io/pypi/pyversions/ask_schools.svg) -![PyPI](https://img.shields.io/github/license/guinslym/ask_schools.svg) -](https://pypi.org/project/ask_schools/) -[![TravisCI](https://travis-ci.org/guinslym/ask_schools.svg?branch=master)](https://travis-ci.org/guinslym/ask_schools) - - -This package helps convert Ask School suffixes to the school full name. +# SP Ask School +A Python package for managing school information and queues for Scholars Portal Ask service. This package provides utilities to manage and query information about various Ontario universities and their associated chat queues. ## Installation -**Ask Schools** can be installed from PyPI using `pip` or your package manager of choice: +You can install the package via pip: -``` -pip install ask_schools +```bash +pip install sp-ask-school ``` ## Usage +```python +from sp_ask_school import ( + find_school_by_operator_suffix, + find_queues_from_a_school_name, + find_school_by_queue_or_profile_name +) + +# Find school from operator suffix +school = find_school_by_operator_suffix("operator_tor") +print(school) # Output: "toronto" + +# Get queues for a school +queues = find_queues_from_a_school_name("Toronto") +print(queues) # Output: ["toronto", "toronto-mississauga", ...] + +# Find school from queue name +school = find_school_by_queue_or_profile_name("western-proactive") +print(school) # Output: "Western" +``` + +## Features -Example: +- Find school information by operator suffix +- Get queue lists for specific schools +- Find school information by queue name +- Support for French and SMS queues +- Practice queue management +- Support for multiple university profiles -```python +## Contributing -from ask_schools import find_school_by_operator_suffix +Contributions are welcome! Please feel free to submit a Pull Request. -def test_check_school_name_equal_toronto(): - result = find_school_by_operator_suffix('_tor') - assert result == 'Tordonto' -``` +## License + +This project is licensed under the MIT License - see the LICENSE file for details. + +## Authors + +- Guinsly Mondésir -## Code of Conduct +## Maintained by -Everyone interacting in the project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [PyPA Code of Conduct](https://www.pypa.io/en/latest/code-of-conduct/). +[Scholars Portal](https://scholarsportal.info/) \ No newline at end of file diff --git a/ask_schools/__init__.py b/ask_schools/__init__.py deleted file mode 100644 index bdce5fd..0000000 --- a/ask_schools/__init__.py +++ /dev/null @@ -1,252 +0,0 @@ -__version__ = "0.3.8" - -suffixes = ["york","tor","sp","gue","otech","mac","west","ott","rye","brk","queens","lake","guehum","york.fr","ocad","car","stp.fr","lan","lan.fr","alg","int","int.fr","uoit"] -suffixes_school = ["York University","University of Toronto","Scholars-Portal","Guelph University","Ontario Tech","McMaster University","Western University","Ottawa University","Ryerson University","Brock University","Queen's University","Lakehead University","Guelph-Humber University","York University","OCAD University","Carleton University","Saint-Paul University","Laurentian University","Laurentian University","Algoma University","Mentees","Mentees","Ontario Tech University"] - -queue = ["algoma","algoma-fr","brock","carleton-txt","carleton","guelph","guelph-humber","guelph-humber-txt","lakehead","laurentian","laurentian-fr","mcmaster","mcmaster-txt","ocad","otech","ottawa","ottawa-fr","ottawa-fr-txt","ottawa-txt","practice-webinars","practice-webinars-fr","practice-webinars-txt","queens","ryerson","saintpaul","saintpaul-fr","scholars-portal","toronto","toronto-mississauga","toronto-scarborough","toronto-st-george","western","western-fr","western-proactive","western-txt","york","york-glendon","york-glendon-fr","york-txt"] -queue_simple_name = ["algoma","algoma","brock","carleton","carleton","guelph","guelph","guelph","lakehead","laurentian","laurentian","mcmaster","mcmaster","ocad","otech","ottawa","ottawa","ottawa","ottawa","practice","practice","practice","queens","ryerson","saintpaul","saintpaul","scholars","toronto","toronto","toronto","toronto","western","western","western","western","york","york","york","york"] -queue_university = ["Algoma University","Algoma University","Brock University","Carleton University","Carleton University","Guelph University","Guelph-Humber University","Guelph-Humber University","Lakehead University","Laurentian University","Laurentian University","McMaster University","McMaster University","OCAD University","Ontario Tech","Ottawa University","Ottawa University","Ottawa University","Ottawa University","practice","practice","practice","Queen's University","Ryerson University","Saint-Paul University","Saint-Paul University","Scholars-Portal","University of Toronto","University of Toronto","University of Toronto","University of Toronto","Western University","Western University","Western University","Western University","York-University","York-University","York-University","York-University"] - -school_name = { - 'Toronto':{'suffix':'_tor', 'short':'Toronto', 'full':'University of Toronto'}, - 'Mentees':{'suffix':'_int', 'short':'Mentees', 'full':'Mentees'}, - 'Western':{'suffix':'_west', 'short':'Western', 'full':'University of Western Ontario'}, - 'Carleton':{'suffix':'_car', 'short':'Carleton', 'full':'Carleton University'}, - 'Ryerson':{'suffix':'_rye', 'short':'Ryerson', 'full':'Ryerson University'}, - 'Laurentian':{'suffix':'_lan', 'short':'Laurentian', 'full':'Laurentian University'}, - 'Queens':{'suffix':'_queens', 'short':'Queens', 'full':'Queens university'}, - 'Brock':{'suffix':'_brk', 'short':'Brock', 'full':'Brock University'}, - 'Guelph-Humber':{'suffix':'_guehum', 'short':'Guelph-Humber', 'full':'University of Guelph-Humber'}, - 'Guelph':{'suffix':'_gue', 'short':'Guelph', 'full':'University of Guelph'}, - 'UOIT':{'suffix':'_uoit', 'short':'Ontario Tech', 'full':'Ontario Tech University'}, - 'Ontario Tech':{'suffix':'_otech', 'short':'Ontario Tech', 'full':'Ontario Tech University'}, - 'Saint-Paul':{'suffix':'_stp', 'short':'Saint-Paul', 'full':'Saint-Paul University'}, - 'OCAD':{'suffix':'_ocad', 'short':'OCAD', 'full':'OCAD'}, - 'Lakehead':{'suffix':'_lake', 'short':'Lakehead', 'full':'Lakehead university'}, - 'Algoma':{'suffix':'_alg', 'short':'Algoma', 'full':'Algoma university'}, - 'McMaster':{'suffix':'_mac', 'short':'McMaster', 'full':'McMaster university'}, - 'York':{'suffix':'_york', 'short':'York', 'full':'York university'}, - 'Scholars Portal':{'suffix':'_sp', 'short':'Scholars Portal', 'full':'Scholars Portal'}, - 'Ottawa':{'suffix':'_ott', 'short':'Ottawa', 'full':'Ottawa University'} -} - -def find_school_by_operator_suffix(operator): - """from a suffix find the short name of that School - - Arguments: - operator {str} -- suffix of the schoo i.e. _tor - - Returns: - str -- The short name of the school i.e. Toronto - """ - if operator is None: - return operator - - - if "_tor" in operator: - return "Toronto" - elif "_int" in operator: - return "Mentees" - elif "_west" in operator: - return "Western" - elif "_car" in operator: - return "Carleton" - elif "_rye" in operator: - return "Ryerson" - elif "_lan" in operator: - return "Laurentian" - elif "_queens" in operator: - return "Queens" - elif "_brk" in operator: - return "Brock" - elif "_guehum" in operator: - return "Guelph-Humber" - elif "_gue" in operator: - return "Guelph" - elif "_uoit" in operator: - return "Ontario Tech" - elif "_otech" in operator: - return "Ontario Tech" - elif "_stp" in operator: - return "Saint-Paul" - elif "_ocad" in operator: - return "OCAD" - elif "_lake" in operator: - return "Lakehead" - elif "_alg" in operator: - return "Algoma" - elif "_mac" in operator: - return "McMaster" - elif "_york" in operator: - return "York" - elif "_sp" in operator: - return "Scholars Portal" - elif "_ott" in operator: - return "Ottawa" - else: - return "Unknown" - -def get_shortname_by_full_school_name(school): - - if school is None: - return school - school = school.lower() - - if 'toronto' in school: - return "Toronto" - elif "humber" in school: - return 'Guelph-Humber' - elif "ryerson" in school: - return 'Ryerson' - elif "western" in school: - return "Western" - elif "mentees" in school: - return 'Mentees' - elif "guelph" in school: - return "Guelph" - elif "york" in school: - return "York" - elif "mcmaster" in school: - return "McMaster" - elif "tech" in school: - return "Ontario Tech" - elif "queen" in school: - return "Queens" - elif "paul" in school: - return "Saint-Paul" - elif "ottawa" in school: - return "Ottawa" - elif "brock" in school: - return "Brock" - elif "algoma" in school: - return "Algoma" - elif "laurentian" in school: - return "Laurentian" - elif "ocad" in school: - return "OCAD" - elif "uoit" in school: - return "Ontario Tech" - elif "portal" in school: - return "Scholars Portal" - elif "carleton" in school: - return "Carleton" - elif "lakehead" in school: - return 'Lakehead' - else: - return "unknown" - -def find_school_by_queue_or_profile_name(queue): - if queue is None: - return queue - - if queue in ["toronto-st-george", 'toronto-st-george-proactive', 'toronto-scarborough', 'toronto-mississauga']: - return "University of Toronto" - elif queue in ["york-txt", "york", 'york-glendon-fr', 'york-glendon']: - return "York University" - elif queue in ['guelph']: - return 'Guelph University' - elif queue in ['ryerson']: - return 'Ryerson University' - elif queue in ["western", 'western-proactive', 'western-fr', 'western-txt']: - return "Western Ontario University" - elif queue in ["lakehead-proactive", 'lakehead']: - return "Lakehead University" - elif queue in ["mcmaster", 'mcmaster-txt']: - return "McMaster University" - elif queue in ['queens']: - return "Queens University" - elif queue in ['brock']: - return "Brock University" - elif queue in ['uoit']: - return "Ontario Tech Universtiy" - elif queue in ['otech']: - return "Ontario Tech Universtiy" - elif queue in ['carleton', 'carleton-txt']: - return "Carleton University" - elif queue in ['saintpaul', 'saintpaul-fr']: - return "St-Paul University" - elif queue in ['ottawa', 'ottawa-txt', 'ottawa-fr']: - return "Ottawa University" - elif queue in ['laurentian','laurentian-fr' ]: - return "Laurentian University" - elif queue in ['guelph-humber','guelph-humber-txt' ]: - return "Guelph-Humber University" - elif queue in ["ocad"]: - return "OCAD University" - elif queue in ['algoma-proactive','algoma', 'algoma-fr']: - return "Algoma University" - elif queue in ['practice-webinars-fr', 'practice-webinars']: - return "SP-Practice-queue" - elif queue in ['scholars-portal']: - return "Scholars-Portal" - else: - return "Unknown" - -def find_school_abbr_by_queue_or_profile_name(queue): - if queue is None: - return queue - - if queue in ["toronto-st-george", 'toronto-st-george-proactive', 'toronto-scarborough', 'toronto-mississauga']: - return "UofT" - elif queue in ["york", 'york-glendon-fr', 'york-glendon']: - return "YorkU" - elif queue in ['guelph']: - return 'GuelphU' - elif queue in ['ryerson']: - return 'RyersonU' - elif queue in ["western", 'western-proactive', 'western-fr']: - return "Western" - elif queue in ["lakehead-proactive", 'lakehead']: - return "Lakehead" - elif queue in ["mcmaster", 'mcmaster-txt']: - return "McMaster" - elif queue in ['queens']: - return "Queens" - elif queue in ['brock']: - return "Brock" - elif queue in ['otech']: - return "Ontario Tech" - elif queue in ['carleton', 'carleton-txt']: - return "Carleton" - elif queue in ['saintpaul', 'saintpaul-fr']: - return "St-Paul" - elif queue in ['ottawa', 'ottawa-txt', 'ottawa-fr']: - return "Ottawa" - elif queue in ['laurentian','laurentian-fr' ]: - return "Laurentian" - elif queue in ['guelph-humber','guelph-humber-txt' ]: - return "Guelph-Humber" - elif queue in ["ocad"]: - return "OCAD" - elif queue in ['algoma-proactive','algoma', 'algoma-fr']: - return "Algoma" - elif queue in ['practice-webinars-fr', 'practice-webinars']: - return "SP-Practice" - elif queue in ['scholars-portal']: - return "Scholars-Portal" - else: - return "Unknown" - -HTF_schools = ["Brock University", "Carleton University", - "Laurentian University", "University of Toronto", - "Ontario Tech University", "Western Ontario University", - "Queens University"] - -FRENCH_QUEUES = ['algoma-fr', 'clavardez', 'laurentian-fr', 'ottawa-fr', - 'saintpaul-fr', 'western-fr', 'york-glendon-fr'] -SMS_QUEUES = ['carleton-txt', 'clavardez-txt', 'guelph-humber-txt', - 'mcmaster-txt', 'ottawa-fr-txt', 'ottawa-txt', - 'scholars-portal-txt', 'western-txt', 'york-txt'] -PRACTICE_QUEUES = ['practice-webinars', 'practice-webinars-fr', 'practice-webinars-txt'] - -def find_routing_model_by_profile_name(university_name): - if university_name is None: - return university_name - if university_name in HTF_schools: - return "HTF" - else: - return "FLAT" - - -if __name__ == '__main__': - pass \ No newline at end of file diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..63cd246 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,270 @@ +# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. + +[[package]] +name = "black" +version = "23.9.1" +description = "The uncompromising code formatter." +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "black-23.9.1-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:d6bc09188020c9ac2555a498949401ab35bb6bf76d4e0f8ee251694664df6301"}, + {file = "black-23.9.1-cp310-cp310-macosx_10_16_universal2.whl", hash = "sha256:13ef033794029b85dfea8032c9d3b92b42b526f1ff4bf13b2182ce4e917f5100"}, + {file = "black-23.9.1-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:75a2dc41b183d4872d3a500d2b9c9016e67ed95738a3624f4751a0cb4818fe71"}, + {file = "black-23.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13a2e4a93bb8ca74a749b6974925c27219bb3df4d42fc45e948a5d9feb5122b7"}, + {file = "black-23.9.1-cp310-cp310-win_amd64.whl", hash = "sha256:adc3e4442eef57f99b5590b245a328aad19c99552e0bdc7f0b04db6656debd80"}, + {file = "black-23.9.1-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:8431445bf62d2a914b541da7ab3e2b4f3bc052d2ccbf157ebad18ea126efb91f"}, + {file = "black-23.9.1-cp311-cp311-macosx_10_16_universal2.whl", hash = "sha256:8fc1ddcf83f996247505db6b715294eba56ea9372e107fd54963c7553f2b6dfe"}, + {file = "black-23.9.1-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:7d30ec46de88091e4316b17ae58bbbfc12b2de05e069030f6b747dfc649ad186"}, + {file = "black-23.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:031e8c69f3d3b09e1aa471a926a1eeb0b9071f80b17689a655f7885ac9325a6f"}, + {file = "black-23.9.1-cp311-cp311-win_amd64.whl", hash = "sha256:538efb451cd50f43aba394e9ec7ad55a37598faae3348d723b59ea8e91616300"}, + {file = "black-23.9.1-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:638619a559280de0c2aa4d76f504891c9860bb8fa214267358f0a20f27c12948"}, + {file = "black-23.9.1-cp38-cp38-macosx_10_16_universal2.whl", hash = "sha256:a732b82747235e0542c03bf352c126052c0fbc458d8a239a94701175b17d4855"}, + {file = "black-23.9.1-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:cf3a4d00e4cdb6734b64bf23cd4341421e8953615cba6b3670453737a72ec204"}, + {file = "black-23.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cf99f3de8b3273a8317681d8194ea222f10e0133a24a7548c73ce44ea1679377"}, + {file = "black-23.9.1-cp38-cp38-win_amd64.whl", hash = "sha256:14f04c990259576acd093871e7e9b14918eb28f1866f91968ff5524293f9c573"}, + {file = "black-23.9.1-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:c619f063c2d68f19b2d7270f4cf3192cb81c9ec5bc5ba02df91471d0b88c4c5c"}, + {file = "black-23.9.1-cp39-cp39-macosx_10_16_universal2.whl", hash = "sha256:6a3b50e4b93f43b34a9d3ef00d9b6728b4a722c997c99ab09102fd5efdb88325"}, + {file = "black-23.9.1-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:c46767e8df1b7beefb0899c4a95fb43058fa8500b6db144f4ff3ca38eb2f6393"}, + {file = "black-23.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50254ebfa56aa46a9fdd5d651f9637485068a1adf42270148cd101cdf56e0ad9"}, + {file = "black-23.9.1-cp39-cp39-win_amd64.whl", hash = "sha256:403397c033adbc45c2bd41747da1f7fc7eaa44efbee256b53842470d4ac5a70f"}, + {file = "black-23.9.1-py3-none-any.whl", hash = "sha256:6ccd59584cc834b6d127628713e4b6b968e5f79572da66284532525a042549f9"}, + {file = "black-23.9.1.tar.gz", hash = "sha256:24b6b3ff5c6d9ea08a8888f6977eae858e1f340d7260cf56d70a49823236b62d"}, +] + +[package.dependencies] +click = ">=8.0.0" +mypy-extensions = ">=0.4.3" +packaging = ">=22.0" +pathspec = ">=0.9.0" +platformdirs = ">=2" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.7.4)"] +jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] +uvloop = ["uvloop (>=0.15.2)"] + +[[package]] +name = "click" +version = "8.1.7" +description = "Composable command line interface toolkit" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.2" +description = "Backport of PEP 654 (exception groups)" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, +] + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +category = "dev" +optional = false +python-versions = ">=3.5" +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] + +[[package]] +name = "packaging" +version = "24.2" +description = "Core utilities for Python packages" +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, +] + +[[package]] +name = "pathspec" +version = "0.12.1" +description = "Utility library for gitignore style pattern matching of file paths." +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, + {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, +] + +[[package]] +name = "platformdirs" +version = "4.3.6" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, + {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, +] + +[package.extras] +docs = ["furo (>=2024.8.6)", "proselint (>=0.14)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=8.3.2)", "pytest-cov (>=5)", "pytest-mock (>=3.14)"] +type = ["mypy (>=1.11.2)"] + +[[package]] +name = "pluggy" +version = "1.5.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, +] + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "pyclean" +version = "3.0.0" +description = "Pure Python cross-platform pyclean. Clean up your Python bytecode." +category = "dev" +optional = false +python-versions = ">=3.5" +files = [ + {file = "pyclean-3.0.0-py3-none-any.whl", hash = "sha256:a1d8114991cf09994bc511cd0b050f3e398ae2bc8bfc0bbd1bdbec8ba048e6dd"}, + {file = "pyclean-3.0.0.tar.gz", hash = "sha256:a48be7afd512b1923a7b9decc1219bbbe2d73199c939b46c936448f904a180ce"}, +] + +[[package]] +name = "pytest" +version = "7.4.4" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, + {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] + +[[package]] +name = "pytest-sugar" +version = "1.0.0" +description = "pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly)." +category = "dev" +optional = false +python-versions = "*" +files = [ + {file = "pytest-sugar-1.0.0.tar.gz", hash = "sha256:6422e83258f5b0c04ce7c632176c7732cab5fdb909cb39cca5c9139f81276c0a"}, + {file = "pytest_sugar-1.0.0-py3-none-any.whl", hash = "sha256:70ebcd8fc5795dc457ff8b69d266a4e2e8a74ae0c3edc749381c64b5246c8dfd"}, +] + +[package.dependencies] +packaging = ">=21.3" +pytest = ">=6.2.0" +termcolor = ">=2.1.0" + +[package.extras] +dev = ["black", "flake8", "pre-commit"] + +[[package]] +name = "termcolor" +version = "2.4.0" +description = "ANSI color formatting for output in terminal" +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "termcolor-2.4.0-py3-none-any.whl", hash = "sha256:9297c0df9c99445c2412e832e882a7884038a25617c60cea2ad69488d4040d63"}, + {file = "termcolor-2.4.0.tar.gz", hash = "sha256:aab9e56047c8ac41ed798fa36d892a37aca6b3e9159f3e0c24bc64a9b3ac7b7a"}, +] + +[package.extras] +tests = ["pytest", "pytest-cov"] + +[[package]] +name = "tomli" +version = "2.1.0" +description = "A lil' TOML parser" +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "tomli-2.1.0-py3-none-any.whl", hash = "sha256:a5c57c3d1c56f5ccdf89f6523458f60ef716e210fc47c4cfb188c5ba473e0391"}, + {file = "tomli-2.1.0.tar.gz", hash = "sha256:3f646cae2aec94e17d04973e4249548320197cfabdf130015d023de4b74d8ab8"}, +] + +[[package]] +name = "typing-extensions" +version = "4.12.2" +description = "Backported and Experimental Type Hints for Python 3.8+" +category = "dev" +optional = false +python-versions = ">=3.8" +files = [ + {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, + {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.8" +content-hash = "54111d95cb52dc2740aa6cd1efa224dbabb59f0283fce3f4a07dc561cbe38ec4" diff --git a/pyproject.toml b/pyproject.toml index 41b94ba..f485f80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,35 @@ [tool.poetry] -name = "ask_schools" -version = "0.3.8" -description = "Ask Scholars Portal School Name Conversion" -authors = ["Guinsly Mondesir "] -keywords = ["Ask", "Scholars Portal", "Ontario"] -license = "MIT" +name = "sp-ask-school" +version = "0.3.9" +description = "A package for managing school information and queues for Scholars Portal Ask" +authors = ["Guinsly Mondésir"] readme = "README.md" -homepage = "https://github.com/guinslym/ask_schools" -repository = "https://github.com/guinslym/ask_schools" +packages = [{include = "sp_ask_school"}] +license = "MIT" +homepage = "https://github.com/scholarsportal/sp-ask-school" +repository = "https://github.com/scholarsportal/sp-ask-school" +keywords = ["school", "queue", "management", "scholars portal", "ask a librarian"] classifiers = [ - "Operating System :: OS Independent", - "Topic :: Software Development :: Documentation", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Software Development :: Quality Assurance", -] -include = [ - "LICENSE", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10" ] [tool.poetry.dependencies] -python = "^3.4" +python = "^3.8" + +[tool.poetry.group.test.dependencies] +pytest = "^7.0" -[tool.poetry.dev-dependencies] -pytest = "^3.0" +[tool.poetry.group.dev.dependencies] +pytest-sugar = "^1.0.0" +pyclean = "^3.0.0" +black = "23.9.1" [build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" \ No newline at end of file diff --git a/sp_ask_school/__init__.py b/sp_ask_school/__init__.py new file mode 100644 index 0000000..b690831 --- /dev/null +++ b/sp_ask_school/__init__.py @@ -0,0 +1,17 @@ +from .schools import ( + find_school_by_operator_suffix, + find_queues_from_a_school_name, + get_shortname_by_full_school_name, + find_school_by_queue_or_profile_name, + find_school_abbr_by_queue_or_profile_name, + find_queue_by_criteria, + find_routing_model_by_profile_name, + sp_ask_school_dict, + FRENCH_QUEUES, + SMS_QUEUES, + PRACTICE_QUEUES, + HTF_schools, +) + +__version__ = "0.3.9" +__author__ = "Guinsly Mondésir" diff --git a/sp_ask_school/schools.py b/sp_ask_school/schools.py new file mode 100644 index 0000000..abf54d1 --- /dev/null +++ b/sp_ask_school/schools.py @@ -0,0 +1,415 @@ +__version__ = "0.3.9" +__author__ = "Guinsly Mondésir" + +sp_ask_school_dict = [ + { + "school": { + "id": 1, + "queues": [ + "toronto", + "toronto-mississauga", + "toronto-scarborough", + "toronto-st-george", + "toronto-st-george-proactive", + ], + "suffix": ["_tor"], + "short_name": "toronto", + "full_name": "University of Toronto", + } + }, + { + "school": { + "id": 2, + "queues": [], + "suffix": ["_int", "_int.fr"], + "short_name": "Scholars Portal - Mentees", + "full_name": "Scholars Portal - Mentees", + } + }, + { + "school": { + "id": 3, + "queues": [ + "western", + "western-fr", + "western-proactive", + "western-txt", + ], + "suffix": ["_west", "_west.fr"], + "short_name": "Western", + "full_name": "University of Western Ontario", + } + }, + { + "school": { + "id": 4, + "queues": [ + "carleton-txt", + "carleton", + "carleton-access-services-txt", + "carleton-access-services", + ], + "suffix": ["_car"], + "short_name": "Carleton", + "full_name": "Carleton University", + } + }, + { + "school": { + "id": 5, + "queues": ["tmu", "tmu-proactive", "tmu-txt"], + "suffix": ["_tmu"], + "short_name": "TMU", + "full_name": "Toronto Metropolitan University", + } + }, + { + "school": { + "id": 6, + "queues": ["laurentian", "laurentian-fr"], + "suffix": ["_lan", "_lan.fr"], + "short_name": "Laurentian", + "full_name": "Laurentian University", + } + }, + { + "school": { + "id": 7, + "queues": ["queens", "queens-proactive", "queens-txt"], + "suffix": ["_queens"], + "short_name": "Queen's", + "full_name": "Queen's university", + } + }, + { + "school": { + "id": 8, + "queues": ["brock"], + "suffix": ["_brk"], + "short_name": "Brock", + "full_name": "Brock University", + } + }, + { + "school": { + "id": 9, + "queues": ["guelph-humber", "guelph-humber-txt"], + "suffix": ["_guehum"], + "short_name": "Guelph-Humber", + "full_name": "University of Guelph-Humber", + } + }, + { + "school": { + "id": 10, + "queues": ["guelph"], + "suffix": ["_gue"], + "short_name": "Guelph", + "full_name": "University of Guelph", + } + }, + { + "school": { + "id": 12, + "queues": ["ontario-tech"], + "suffix": ["_ontech", "_uoit"], + "short_name": "Ontario Tech", + "full_name": "Ontario Tech University", + } + }, + { + "school": { + "id": 13, + "queues": ["saintpaul", "saintpaul-fr"], + "suffix": ["_stp", "_stp.fr"], + "short_name": "Saint-Paul", + "full_name": "Saint-Paul University", + } + }, + { + "school": { + "id": 14, + "queues": ["ocad"], + "suffix": ["_ocad"], + "short_name": "OCAD", + "full_name": "OCAD U", + } + }, + { + "school": { + "id": 15, + "queues": ["lakehead", "lakehead-proactive"], + "suffix": ["_lake"], + "short_name": "Lakehead", + "full_name": "Lakehead university", + } + }, + { + "school": { + "id": 16, + "queues": ["algoma", "algoma-fr", "algoma-proactive"], + "suffix": ["_alg"], + "short_name": "Algoma", + "full_name": "Algoma university", + } + }, + { + "school": { + "id": 17, + "queues": ["mcmaster", "mcmaster-txt"], + "suffix": ["_mac"], + "short_name": "McMaster", + "full_name": "McMaster university", + } + }, + { + "school": { + "id": 18, + "queues": [ + "york", + "york-glendon", + "york-glendon-fr", + "york-txt", + "york-fr-txt", + ], + "suffix": ["_york", "_york.fr"], + "short_name": "York", + "full_name": "York university", + } + }, + { + "school": { + "id": 19, + "queues": [ + "scholars-portal", + "scholars-portal-txt", + "scholars portal", + "clavardez", + "clavardez-txt", + ], + "suffix": ["_sp"], + "short_name": "Scholars Portal", + "full_name": "Scholars Portal", + } + }, + { + "school": { + "id": 20, + "queues": ["ottawa", "ottawa-fr", "ottawa-fr-txt", "ottawa-txt"], + "suffix": ["_ott"], + "short_name": "Ottawa", + "full_name": "Ottawa University", + } + }, + { + "school": { + "id": 21, + "queues": [ + "practice-webinars", + "practice-webinars-fr", + "practice-webinars-txt", + ], + "suffix": [], + "short_name": "Practice queue", + "full_name": "SP Practice Queue", + } + }, + { + "school": { + "id": 22, + "queues": ["sp-always-offline"], + "suffix": [], + "short_name": "LibraryH3lp", + "full_name": "LibraryH3lp", + } + }, +] + + +def find_school_by_operator_suffix(username): + """from an username suffix find the short name of that School + + Arguments: + username {str} -- suffix of the schoo i.e. nalini_tor + + Returns: + str -- The short name of the school i.e. Toronto + """ + # print("This username :{0}".format(username)) + + if username is None: + return username + + if "_" in username: + # print("_ found in {0}".format(username)) + suffix = username.split("_") + try: + suffix = "_" + suffix[1] + except: + # print(username) + # breakpoint() + pass + # print("suffix:{0}".format(suffix)) + for item in sp_ask_school_dict: + if suffix in item.get("school").get("suffix"): + # print(item.get('school').get('short_name') ) + return item.get("school").get("short_name") + elif "admin" in username: + school = username.split("-")[0] + return school + elif "guelph-librarian1" == username: + return "Guelph" + elif "lakehead-librarian1" == username: + return "lakehead" + elif "sp-demo" == username: + return "Scholars Portal" + elif "test" == username: + return "Scholars Portal" + else: + return "Unknown" + + +def find_queues_from_a_school_name(school): + if school is None: + return school + school = school.lower() + + for item in sp_ask_school_dict: + if school == item.get("school").get("short_name").lower(): + return item.get("school").get("queues") + return "Unknown" + + +def get_shortname_by_full_school_name(school): + """from a University Full name find the shortname of that School + + Arguments: + school {str} -- school (i.e. Full name) + + Returns: + str -- The short name of the school i.e. Toronto + """ + if school is None: + return school + school = school.lower() + + for item in sp_ask_school_dict: + if school == item.get("school").get("full_name"): + return item.get("school").get("short_name") + + +def find_school_by_queue_or_profile_name(queue): + """from the name of a queue find the full name of that School + + Arguments: + queue {str} -- queue/service i.e. western-proactive + + Returns: + str -- The full name of the school i.e. Toronto + """ + if queue is None: + return queue + + for item in sp_ask_school_dict: + if queue in item.get("school").get("queues"): + return item.get("school").get("short_name") + return "Unknown" + + +def find_school_abbr_by_queue_or_profile_name(queue): + """from a queue name or the name of a Queue Profile find the short name of that School + + Arguments: + queue {str} -- queue/service i.e. tmu-proactive + + Returns: + str -- The short name of the school i.e. Toronto + """ + if queue is None: + return queue + + for item in sp_ask_school_dict: + if queue in item.get("school").get("queues"): + return item.get("school").get("short_name") + return "Unknown" + + +HTF_schools = [ + "Brock University", + "Carleton University", + "Laurentian University", + "University of Toronto", + "Ontario Tech University", + "Western Ontario University", + "Queens University", + "Ryerson University", +] + + +def find_queue_by_criteria(criteria=None): + """Find queues that match the given criteria + + Args: + criteria (str, optional): Search string to match in queue names. Defaults to None. + + Returns: + list: List of queue names containing the criteria + """ + queue_list = [] + for item in sp_ask_school_dict: + for element in item.get("school", {}).get("queues", []): + if criteria and criteria in element: + queue_list.append(element) + return queue_list + + +FRENCH_QUEUES = [ + "algoma-fr", + "clavardez", + "laurentian-fr", + "ottawa-fr", + "saintpaul-fr", + "western-fr", + "york-glendon-fr", +] + +SMS_QUEUES = [ + "carleton-txt", + "clavardez-txt", + "guelph-humber-txt", + "mcmaster-txt", + "ottawa-fr-txt", + "ottawa-txt", + "scholars-portal-txt", + "western-txt", + "queens-txt", + "york-txt", + "york-fr-txt", + "txt-carleton-access-services", + "carleton-access-services-txt", +] + +PRACTICE_QUEUES = ["practice-webinars", "practice-webinars-fr", "practice-webinars-txt"] + + +def find_routing_model_by_profile_name(university_name): + """[summary] + + Args: + university_name ([type]): [description] + + Returns: + [type]: [description] + """ + if university_name is None: + return university_name + if university_name in HTF_schools: + return "HTF" + else: + return "FLAT" + + +if __name__ == "__main__": + FRENCH_QUEUES = find_queue_by_criteria(criteria="-fr") + SMS_QUEUES = find_queue_by_criteria(criteria="-txt") + PRACTICE_QUEUES = find_queue_by_criteria(criteria="practice") diff --git a/tests/test_ask_schools.py b/tests/test_schools.py similarity index 56% rename from tests/test_ask_schools.py rename to tests/test_schools.py index ec60e30..fc56168 100644 --- a/tests/test_ask_schools.py +++ b/tests/test_schools.py @@ -3,8 +3,9 @@ def test_version(): - assert __version__ == '0.1.0' + assert __version__ == "0.1.0" + def check_school_name_equal_toronto(): - result = find_school_by_operator_suffix('_tor') - assert result == 'Tordonto' + result = find_school_by_operator_suffix("_tor") + assert result == "Tordonto"