Exemple #1
0
 def test_vector_builder(self):
     vectors = VectorBuilder(Nodetype.objects.all(),
                             ['title', 'excerpt', 'content'])
     params = {
         'title': 'My nodetype 1',
         'content': 'This is my first content',
         'tags': 'gstudio, test',
         'slug': 'my-nodetype-1'
     }
     Nodetype.objects.create(**params)
     params = {
         'title': 'My nodetype 2',
         'content': 'My second nodetype',
         'tags': 'gstudio, test',
         'slug': 'my-nodetype-2'
     }
     Nodetype.objects.create(**params)
     columns, dataset = vectors()
     self.assertEquals(
         columns,
         ['content', 'This', 'my', 'is', '1', 'second', '2', 'first'])
     self.assertEquals(dataset.values(),
                       [[1, 1, 1, 1, 1, 0, 0, 1], [0, 0, 0, 0, 0, 1, 1, 0]])
Exemple #2
0
from gstudio.comparison import pearson_score
from gstudio.templatetags.zcalendar import GstudioCalendar
from gstudio.templatetags.zbreadcrumbs import retrieve_breadcrumbs
from django.http import HttpResponseRedirect

from gstudio.CNL import *
from gstudio.methods import check_release_or_not
import os
from settings import STATIC_URL,ADMIN_MEDIA_PREFIX
import tarfile
from gstudio.methods import *
import contextlib
register = Library()

VECTORS = None
VECTORS_FACTORY = lambda: VectorBuilder(Nodetype.published.all(),
                                        ['title', 'excerpt', 'content'])
CACHE_NODETYPES_RELATED = {}

@contextlib.contextmanager
def cd_change(tmp_location):
    cd = os.getcwd()
    os.chdir(tmp_location)
    try:
        yield
    finally:
        os.chdir(cd)

@register.assignment_tag
def get_slug_of_video(videoid):
    print "videoid",videoid
    slug=""