Skip to content

Commit

Permalink
fix: don't require ijson if @decorators.cache_iterator is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
user2589 committed Feb 5, 2019
1 parent 058868a commit 9918e2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
19 changes: 10 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist: xenial
# do not use xenial, or it will fail pages deploy
# https://travis-ci.community/t/failed-to-deploy-because-of-ruby-error/1143
sudo: required
language: python
python:
Expand Down Expand Up @@ -27,14 +28,6 @@ jobs:
script: make html

deploy:
- provider: pages
skip-cleanup: true
github-token: $GH_TOKEN
keep-history: true
on:
branch: master
local-dir: docs/build/html

- provider: script
skip_cleanup: true
on:
Expand All @@ -48,5 +41,13 @@ jobs:
tags: true
file: dist/*

- provider: pages
skip-cleanup: true
github-token: $GH_TOKEN
keep-history: true
on:
branch: master
local-dir: docs/build/html

after_failure:
- pip freeze
10 changes: 7 additions & 3 deletions stutils/decorators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

import ijson.backends.yajl2 as ijson
import pandas as pd

import json
import logging
import os
Expand All @@ -11,6 +8,7 @@
import tempfile
import threading

import pandas as pd
import stutils
from stutils.sysutils import mkdir

Expand Down Expand Up @@ -191,7 +189,13 @@ class cache_iterator(fs_cache):
in Python2, json instantiates loaded strings as unicode, so cached
result might be slightly different from original
"""

def __call__(self, func):
try:
import ijson.backends.yajl2 as ijson
except ImportError:
raise ImportError("Please install yajl-tools to use this decorator")

@wraps(func)
def wrapper(*args):
cache_fpath = self.get_cache_fname(
Expand Down

0 comments on commit 9918e2c

Please sign in to comment.