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)
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))
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()])
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()])
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)