/usr/local/Vellumbot

changeset 95:f4dbaecc3172

update to be compatible with half-finished playtools.fact system
author Cory Dodt <corymercurial@spam.goonmill.org>
date Sun May 10 22:15:35 2009 -0700 (2009-05-10)
parents 3f42437ad431
children f4d09da908dd
files vellumbot/server/_formattingkludge.py vellumbot/server/reference.py
line diff
     1.1 --- a/vellumbot/server/_formattingkludge.py	Sun May 10 13:11:42 2009 -0700
     1.2 +++ b/vellumbot/server/_formattingkludge.py	Sun May 10 22:15:35 2009 -0700
     1.3 @@ -8,13 +8,17 @@
     1.4  from zope.interface.interface import adapter_hooks
     1.5  
     1.6  from playtools.interfaces import IRuleFact
     1.7 -from playtools import query
     1.8 +from playtools import fact
     1.9 +from playtools.plugins import d20srd35
    1.10  
    1.11  from goonmill import history
    1.12  
    1.13  from . import interface
    1.14  
    1.15  
    1.16 +SRD = fact.systems['D20 SRD']
    1.17 +
    1.18 +
    1.19  class IOneLine(Interface):
    1.20      """
    1.21      An object which can be formatted as a single-line description
    1.22 @@ -36,7 +40,7 @@
    1.23              'range':spell.range,
    1.24              'duration':spell.duration,
    1.25              'short':spell.short_description,
    1.26 -            'url':query.srdReferenceURL(spell),
    1.27 +            'url':d20srd35.srdReferenceURL(spell),
    1.28              }
    1.29      
    1.30      if spell.subschool:
    1.31 @@ -64,8 +68,8 @@
    1.32      return tmpl.safe_substitute(dct)
    1.33  
    1.34  
    1.35 -_ONELINE_MAPPING = {query.Monster: history.oneLineDescription,
    1.36 -        query.Spell: oneLineForSpell
    1.37 +_ONELINE_MAPPING = {SRD.facts['monster'].klass: history.oneLineDescription,
    1.38 +        SRD.facts['spell'].klass: oneLineForSpell
    1.39          }
    1.40  
    1.41  
     2.1 --- a/vellumbot/server/reference.py	Sun May 10 13:11:42 2009 -0700
     2.2 +++ b/vellumbot/server/reference.py	Sun May 10 22:15:35 2009 -0700
     2.3 @@ -6,10 +6,12 @@
     2.4  from contextlib import contextmanager
     2.5  
     2.6  
     2.7 -from playtools import search, query
     2.8 +from playtools import search, fact
     2.9  from . import _formattingkludge
    2.10  import hypy
    2.11  
    2.12 +SRD = fact.systems['D20 SRD']
    2.13 +
    2.14  @contextmanager
    2.15  def openIndex(filename):
    2.16      estdb = hypy.HDatabase()
    2.17 @@ -19,19 +21,6 @@
    2.18      finally:
    2.19          estdb.close()
    2.20  
    2.21 -DOMAINS = {
    2.22 -        u'monster': query.Monster,
    2.23 -        u'spell': query.Spell,
    2.24 -        }
    2.25 -
    2.26 -def lookup(id, domain):
    2.27 -    """
    2.28 -    Get the database-backed Thing which corresponds to the domain and altname,
    2.29 -    mapping through DOMAINS to get the Thing's class as understood by
    2.30 -    playtools.query
    2.31 -    """
    2.32 -    return query.lookup(id, DOMAINS[domain])
    2.33 -
    2.34  
    2.35  def find(domain, terms, max=5):
    2.36      """
    2.37 @@ -45,7 +34,7 @@
    2.38          for look in looked:
    2.39              if look[u'altname'] == normTerms:
    2.40                  _ignored_domain, id = look[u'@uri'].split(u'/')
    2.41 -                thing = lookup(int(id), domain)
    2.42 +                thing = SRD.facts[domain].lookup(int(id))
    2.43                  if thing:
    2.44                      return [_formattingkludge.IOneLine(thing).format()]
    2.45              ret.append('"%s": %s' % (look[u'altname'], look.teaser(terms,