Skip to content

Commit

Permalink
Use pkgutil to get spinners data
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Sep 27, 2019
1 parent daa8806 commit 47ed8f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[bumpversion]
current_version = 0.15.0
current_version = 0.15.0post1

[metadata]
description-file = README.rst

6 changes: 2 additions & 4 deletions tests/test_spinners.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@

from __future__ import absolute_import

import codecs
import json
from collections import OrderedDict

import pytest

from yaspin.compat import iteritems
from yaspin.spinners import SPINNERS_PATH, Spinners
from yaspin.spinners import SPINNERS_DATA, Spinners


with codecs.open(SPINNERS_PATH, encoding="utf-8") as f:
spinners_dict = OrderedDict(json.load(f))
spinners_dict = OrderedDict(json.loads(SPINNERS_DATA))


test_cases = [
Expand Down
2 changes: 1 addition & 1 deletion yaspin/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.15.0"
__version__ = "0.15.0post1"
9 changes: 3 additions & 6 deletions yaspin/spinners.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
A collection of cli spinners.
"""

import codecs
import os
import pkgutil
from collections import namedtuple

try:
Expand All @@ -17,13 +16,11 @@
import json


THIS_DIR = os.path.dirname(os.path.realpath(__file__))
SPINNERS_PATH = os.path.join(THIS_DIR, "data/spinners.json")
SPINNERS_DATA = pkgutil.get_data(__package__, "data/spinners.json")


def _hook(dct):
return namedtuple("Spinner", dct.keys())(*dct.values())


with codecs.open(SPINNERS_PATH, encoding="utf-8") as f:
Spinners = json.load(f, object_hook=_hook)
Spinners = json.loads(SPINNERS_DATA, object_hook=_hook)

0 comments on commit 47ed8f8

Please sign in to comment.