Esempio n. 1
0
 def test_library(self):
   r = Resource()
   self.assertEqual(len(Library.list()), 0)
   Library.add("r1", r)
   self.assertEqual(len(Library.list()), 1)
   r1 = Library.get("r1")
   self.assertEqual(r1, r)
Esempio n. 2
0
 def test_library(self):
     r = Resource()
     self.assertEqual(len(Library.list()), 0)
     Library.add("r1", r)
     self.assertEqual(len(Library.list()), 1)
     r1 = Library.get("r1")
     self.assertEqual(r1, r)
Esempio n. 3
0
def tagref_createform(request, tag_name=None):
  """ Form to create a single tag reference.
  """
  return render_to_response('tags/tagref_create.html',
      {'tag_name': tag_name, 
       'resources': library.list(),
       'res_default': 'NKJV'
       }, context_instance=RequestContext(request))
Esempio n. 4
0
def load_library(resources):
    """ Load textual resources given by command-line args 
  else all default.
  """
    if len(resources) > 0:
        import os
        for arg in resources:
            f = os.path.realpath(
                os.path.join(os.path.dirname(library.__file__),
                             "data/{}.bible.json".format(arg.upper())))
            library.load(f)
    else:
        # load everything we find
        library.load_resources()
    print "Loading into library:", library.list()
    # map to lowercase resource names
    return dict([(k.lower(), library.get(k)) for k in library.list()])
Esempio n. 5
0
def load_library(resources):
  """ Load textual resources given by command-line args 
  else all default.
  """
  if len(resources) > 0:
    import os
    for arg in resources:
      f = os.path.realpath(
        os.path.join(os.path.dirname(library.__file__), 
          "data/{}.bible.json".format(arg.upper())))
      library.load(f)
  else:
    # load everything we find
    library.load_resources()
  print "Loading into library:", library.list()
  # map to lowercase resource names
  return dict([(k.lower(),library.get(k)) for k in library.list()])
Esempio n. 6
0
def lib(request):
    """ Library root.

  Also receives searches performed when no resource is selected.
  """
    query = request.GET.get('q', None)
    # generic library response
    if not query:
        return render_to_response('texts/library.html',
                                  {'resources': library.list()},
                                  context_instance=RequestContext(request))
    else:
        return tag_search(request, query)
Esempio n. 7
0
def lib(request):
  """ Library root.

  Also receives searches performed when no resource is selected.
  """
  query = request.GET.get('q', None)
  # generic library response
  if not query:
    return render_to_response('texts/library.html', 
        {'resources': library.list()}, 
        context_instance=RequestContext(request))
  else:
    return tag_search(request, query)