Skip to content

Commit

Permalink
Fixed location where jsons are stored. Now jsons are dl'd into the pa…
Browse files Browse the repository at this point in the history
…ckage folder
  • Loading branch information
fu committed Dec 5, 2018
1 parent b9e8e7a commit 2031e02
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions uparma/uparma.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
import requests
import os
import json
from collections import defaultdict as ddict
import uparma


URLS = {
('general', 'parameters') : 'https://raw.githubusercontent.com/uparma/uparma-lib/master/general_parameters.json',
('spectrum', 'parameters') : 'https://raw.githubusercontent.com/uparma/uparma-lib/master/spectrum_parameters.json',
Expand Down Expand Up @@ -39,15 +37,15 @@ def __init__(self, refresh_jsons=False, source_style="ursgal_style_1"):
for url_id, url in URLS.items():
json_file_name = os.path.basename(url)
full_path = os.path.join(
os.path.dirname(__file__), json_file_name
os.path.dirname(uparma.uparma.__file__), json_file_name
)
if os.path.exists(full_path) is False:
refresh_jsons = True
# we will have to pull

if refresh_jsons is True:
with requests.get(url) as req:
with open(json_file_name, 'w') as j:
with open(full_path, 'w') as j:
print(req.json(), file=j)
self.jsons[url_id] = req.json()
else:
Expand Down Expand Up @@ -140,7 +138,7 @@ def translate(self, param_dict, source_style=None, target_style=None):
"""
cannot_be_translated = "{0} for {1} cannot be translated into {2}"

translated_params = uparma.UParmaDict()
translated_params = UParmaDict()
for param_name, param_value in param_dict.items():

_id = self.parameter2id[source_style].get(param_name, None)
Expand Down

0 comments on commit 2031e02

Please sign in to comment.