Skip to content

Commit

Permalink
moved set directory configuration to centralized config file
Browse files Browse the repository at this point in the history
moved card database xml config to file
  • Loading branch information
chrismeyersfsu committed Jul 20, 2013
1 parent 5dbbffd commit 22d0f0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
db_file="inventory.sqlite3"
cards_file="/home/talin/Cockatrice/cards/cards.xml"
# Root directory of your magic sets
# i.e.
# base_magic_set_dir='/home/john/magic_sets/'
#
# /home/john/magic_sets/M13
# /home/john/magic_sets/P2
# /home/john/magic_sets/P3
base_magic_set_dir = '/home/talin/Cockatrice/cards/downloadedPics'
3 changes: 2 additions & 1 deletion utils/run_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from models import InvCard
from elixir import setup_all, session
from sqlalchemy import distinct
import config


if __name__ == '__main__':
setup_all(True)

sets = [s[0] for s in session.query(distinct(InvCard.set_name)).filter(InvCard.set_name != 'PROMO').all()]
base_dir = u'/home/talin/Cockatrice/cards/downloadedPics'
base_dir = config.base_magic_set_dir
known = match_card.load_sets(base_dir, sets)
cache = match_card.GradientCache(base_dir)
print "all sets loaded!"
Expand Down
5 changes: 3 additions & 2 deletions website.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
from elixir import session, setup_all, metadata
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy import func
import config

setup_all(True)
app = Flask(__name__)

BASIC_LANDS = ["Plains", "Island", "Swamp", "Mountain", "Forest"]

#on application startup, load card descriptions
tree = ET.parse("/home/talin/Cockatrice/cards/cards.xml")
tree = ET.parse(config.cards_file)
root = tree.getroot()
all_cards = filter(None,
(SearchCard.from_xml_node(n)
Expand All @@ -44,7 +45,7 @@ def db_image(img_id):

@app.route('/known_image/<set_abbrev>/<name>')
def known_image(set_abbrev,name):
base_dir = '/home/talin/Cockatrice/cards/downloadedPics' #'' #YOUR BASE_DIR HERE
base_dir = config.base_magic_set_dir
sub_path = os.path.join(set_abbrev,name+'.full.jpg')
path = safe_join(base_dir, sub_path)
if os.path.exists(path):
Expand Down

0 comments on commit 22d0f0f

Please sign in to comment.