Skip to content

Commit

Permalink
update how we include json files
Browse files Browse the repository at this point in the history
  • Loading branch information
dorklein authored and dorklein committed Oct 6, 2020
1 parent 3cc6b73 commit d8a165c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
15 changes: 4 additions & 11 deletions gics/gics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@

from gics.map import Map

try:
import importlib.resources as pkg_resources
except ImportError as e:
print(e)
# Try backported to PY<37 `importlib_resources`.
import importlib_resources as pkg_resources

from . import definitions_module
import pkgutil


def json_to_map(path: str):
f = pkg_resources.open_text(definitions_module, path)
data = pkgutil.get_data('gics.definitions', path)

return Map.create_recursively(json.load(f))
return Map.create_recursively(json.loads(data))

DEFINITIONS = {
"20140228": json_to_map('20140228.json'),
Expand Down Expand Up @@ -46,7 +39,7 @@ def __init__(self, code: str = None, version: str = DEFAULT_VERSION):
self._definition_version = version

if not self._definition:
raise ValueError(f'Unsupported GICS version: {version}. Available versions are {list(definitions.keys())}')
raise ValueError(f'Unsupported GICS version: {version}. Available versions are {list(DEFINITIONS.keys())}')

self._code = code

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
setup(
name='gics',
packages=['gics'],
version='0.1-alpha.3',
version='0.1-alpha.4',
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
description='This library provides a way to parse, manipulate and analyze GICS codes.',
author='Dor Klein',
author_email='[email protected]',
url='https://github.com/dorklein/py-gics',
download_url='https://github.com/dorklein/py-gics/archive/v0.1-alpha.3.tar.gz',
download_url='https://github.com/dorklein/py-gics/archive/v0.1-alpha.4.tar.gz',
keywords=['GICS', 'Global Industry Classification Standard'], # Keywords that define your package best
install_requires=[],
classifiers=[
Expand Down

0 comments on commit d8a165c

Please sign in to comment.