propublica / Capitol-Words

Scraping, parsing and indexing the daily Congressional Record to support phrase search over time, and by legislator and date
BSD 3-Clause "New" or "Revised" License
122 stars 34 forks source link

Prevent need to symlink settings.py #90

Closed AlJohri closed 7 years ago

AlJohri commented 10 years ago

Essentially add the following snippet of code to the top of the parser, ingestor, and scraper to prevent need for symlinking settings.py.

import os, site
ROOT = os.path.dirname(os.path.realpath(__file__))
site.addsitedir(os.path.join(ROOT, "../"))

This will allow settings.py to calculate the path to the sqlite database, the csv, and other files relative to the repository.

As an example my settings.py looks like this after this PR:

CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
DB_PATH = os.path.join(CURRENT_DIR, 'api/capitolwords.db')
BIOGUIDE_LOOKUP_PATH = os.path.join(CURRENT_DIR, 'api/bioguide_lookup.csv')

CWOD_HOME = os.path.join(CURRENT_DIR, 'data/cr')
LOG_DIR = os.path.join(CWOD_HOME, 'log')
SCRAPER_LOG = os.path.join(LOG_DIR, 'scraper.log')