<commit_before>#!/usr/bin/python

import datetime
import logging
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.engine.url import URL
import sys

from resolution import Resolution

# Make sure we have a config
try:
    from config import config
except IOError:
    print "Cannot find database configuration"
    sys.exit(1)

# DB connection function
def db_connect():
    """
    Performs database connection using database settings from settings.py.
    Returns sqlalchemy engine instance
    """
    return create_engine(URL(**config['database']))

logging.basicConfig(level=logging.DEBUG)
# logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

logger = logging.getLogger(__name__)

engine = db_connect()
Session = sessionmaker(bind=engine)
session = Session()

# Calculate for this year
CALC_YEAR = 2012

# Start up Resolution for this year
logger.info('Starting resolution for ' + str(CALC_YEAR))
resolution = Resolution(CALC_YEAR, session)

# Set up the season framework
logger.info('Importing seasons...')
resolution.import_seasons()
logger.info('done')

# Add moveable feasts
logger.info('Adding moveable feasts...')
resolution.import_moveable_feasts()
logger.info('done')

# Add fixed feasts
logger.info('Adding fixed feasts...')
resolution.import_fixed_feasts()
logger.info('done')<commit_msg>Pass in a year rather than hardcoding<commit_after>#!/usr/bin/python

import datetime
import logging
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.engine.url import URL
import sys

from resolution import Resolution

# Make sure we have a config
try:
    from config import config
except IOError:
    print "Cannot find database configuration"
    sys.exit(1)

# DB connection function
def db_connect():
    """
    Performs database connection using database settings from settings.py.
    Returns sqlalchemy engine instance
    """
    return create_engine(URL(**config['database']))

logging.basicConfig(level=logging.DEBUG)
# logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

logger = logging.getLogger(__name__)

engine = db_connect()
Session = sessionmaker(bind=engine)
session = Session()

def usage():
    """Prints the proper usage of this script"""
    print "\n".join((
        "   calendar_builder/main.py <year>",
        "",
        "Pass in the year you want to build as the first argument.",
    ))
    sys.exit(0)

# Calculate for this year
if len(sys.argv) != 2:
    usage()
try:
    CALC_YEAR = int(sys.argv[1])
except ValueError:
    usage()

# Start up Resolution for this year
logger.info('Starting resolution for ' + str(CALC_YEAR))
resolution = Resolution(CALC_YEAR, session)

# Set up the season framework
logger.info('Importing seasons...')
resolution.import_seasons()
logger.info('done')

# Add moveable feasts
logger.info('Adding moveable feasts...')
resolution.import_moveable_feasts()
logger.info('done')

# Add fixed feasts
logger.info('Adding fixed feasts...')
resolution.import_fixed_feasts()
logger.info('done')
{'fraction_non_alphanumeric': 0.1061397779229262, 'fraction_numerical': 0.002939255388634879, 'mean_word_length': 4.779245283018868, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6859437', 'n_tokens_mistral': 918, 'n_tokens_neox': 876, 'n_words': 271}