Skip to content

Commit

Permalink
Put cache in the correct place
Browse files Browse the repository at this point in the history
Closes #90.
  • Loading branch information
laraross authored and suchow committed Sep 28, 2015
1 parent 57c8e04 commit 13e2895
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
*.pyc
cached_func_calls/*
site/_posts/*
proselint/cache/*
profile_output
site/write/*
tests/corpus/newyorker/*
cache/*
proselint/cache/*
16 changes: 15 additions & 1 deletion proselint/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@
import re


def on_heroku():
"""Figure out if we're on Heroku."""
if 'DYNO' in os.environ:
return True
else:
return False


def memoize(f):
"""Cache results of computations on disk."""
path_of_this_file = os.path.dirname(os.path.realpath(__file__))
cache_dirname = os.path.join(path_of_this_file, "cache")

# Determine the location of the cache.
if on_heroku():
cache_dirname = os.path.join(os.path.dirname(path_of_this_file), "tmp")
else:
cache_dirname = os.path.join(path_of_this_file, "cache")

# Create the cache if it does not already exist.
if not os.path.isdir(cache_dirname):
os.mkdir(cache_dirname)

Expand Down

0 comments on commit 13e2895

Please sign in to comment.