-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add class to load PaNOSC mappings into the code #265
- Loading branch information
1 parent
978a8bd
commit f9bb6de
Showing
2 changed files
with
35 additions
and
0 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,29 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
from datagateway_api.src.common.exceptions import SearchAPIError | ||
|
||
|
||
class PaNOSCMappings: | ||
def __init__( | ||
self, path=Path(__file__).parent.parent.parent / "search_api_mapping.json", | ||
): | ||
try: | ||
with open(path, encoding="utf-8") as target: | ||
self.mappings = json.load(target) | ||
except IOError as e: | ||
raise SearchAPIError(e) | ||
|
||
|
||
# TODO - don't think I'll need this | ||
def load_mappings(path=Path(__file__).parent.parent.parent / "search_api_mapping.json"): | ||
try: | ||
with open(path, encoding="utf-8") as target: | ||
data = json.load(target) | ||
except IOError as e: | ||
raise SearchAPIError(e) | ||
|
||
return data | ||
|
||
|
||
mappings = PaNOSCMappings() |