--- a/src/spel/__init__.py Wed Sep 10 16:41:33 2014 +0200
+++ b/src/spel/__init__.py Wed Oct 01 13:14:23 2014 +0200
@@ -1,4 +1,4 @@
-VERSION = (0, 5, 27, "final", 0)
+VERSION = (0, 6, 0, "final", 0)
VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2])))
--- a/src/spel/urls.py Wed Sep 10 16:41:33 2014 +0200
+++ b/src/spel/urls.py Wed Oct 01 13:14:23 2014 +0200
@@ -6,7 +6,7 @@
from django.views.generic import RedirectView, TemplateView
from ldt.auth.views import login as pf_login
from ldt.text import VERSION_STR
-from .views import AnnotationRequest, ChapterRequest, Theatre, Opera, OperaRequest
+from .views import AnnotationRequest, ChapterRequest, Theatre, Opera, OperaRequest, JsonRdfExport
#from django.conf import settings
@@ -28,6 +28,7 @@
(r'^admin/', include(admin.site.urls)),
(r'^i18n/', include('django.conf.urls.i18n')),
+ url(r'^ldt/cljson/id/(?P<id>.*)$', JsonRdfExport.as_view(), name="json_rdf_export"),
(r'^ldt/', include('ldt.ldt_utils.urls')),
(r'^user/', include('ldt.user.urls')),
(r'^api/', include('ldt.api.urls')),
--- a/src/spel/views.py Wed Sep 10 16:41:33 2014 +0200
+++ b/src/spel/views.py Wed Oct 01 13:14:23 2014 +0200
@@ -10,16 +10,20 @@
from django.db.models.aggregates import Count
from django.db.models.query import RawQuerySet
from django.http.response import HttpResponse
-from django.views.generic import TemplateView
+from django.shortcuts import get_object_or_404
+from django.views.generic import TemplateView, View
from itertools import groupby
from ldt.indexation import get_results_with_context
-from ldt.ldt_utils.models import Segment, Content
+from ldt.ldt_utils.models import Segment, Content, Project
+from ldt.ldt_utils.projectserializer import ProjectJsonSerializer
+from ldt.ldt_utils.views.json import project_json_id
from ldt.ldt_utils.views.workspace import get_search_results
from operator import itemgetter
from taggit.models import Tag, TaggedItem
import json
import re
import time
+import uuid
import logging
@@ -477,6 +481,38 @@
+class JsonRdfExport(View):
+
+ def get(self, request, id):
+
+ """
+ This helper module allows to convert advene 2packages from one format to another
+ without having to depend on the whole advene2 library.
+ It does so by invoking advene-convert as a subprocess.
+ """
+ format = request.GET.get("format","")
+ if format == "rdf" or format == "ttl":
+ from libadvene.model.cam.package import Package
+ from libadvene.model.parsers.cinelab_json import Parser
+ from libadvene.model.serializers.cinelab_rdf import serialize_to as serialize_to_rdf
+ from libadvene.model.serializers.cinelab_ttl import serialize_to as serialize_to_ttl
+
+ project = get_object_or_404(Project, ldt_id=id)
+ ps = ProjectJsonSerializer(project)
+ project_dict = ps.serialize_to_cinelab()
+ p = Package("http://spectacleenligne.fr", create=True)
+ Parser.parse_into(project_dict, p)
+ outfile = "/tmp/" + unicode(uuid.uuid1())
+ filedata = ""
+ if format == "rdf":
+ serialize_to_rdf(p, outfile)
+ elif format == "ttl":
+ serialize_to_ttl(p, outfile)
+ with open(outfile, "r") as myfile:
+ filedata = myfile.read()
+ return HttpResponse(filedata, content_type="text/plain")
+ return project_json_id(request, id)
+
\ No newline at end of file
--- a/virtualenv/res/lib/lib_create_env.py Wed Sep 10 16:41:33 2014 +0200
+++ b/virtualenv/res/lib/lib_create_env.py Wed Oct 01 13:14:23 2014 +0200
@@ -49,6 +49,10 @@
'DJANGO-TASTYPIE' : {'setup':'django-tastypie', 'url':'https://github.com/toastdriven/django-tastypie/archive/v0.9.15.tar.gz', 'local': 'django-tastypie-0.9.15.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
'DJANGO-CHUNCKED-UPLOADS' : {'setup': 'django-chuncked-uploads', 'url':'https://github.com/IRI-Research/django-chunked-uploads/archive/v0.5.tar.gz', 'local':'django-chunked-uploads-0.5.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
'LDT' : {'setup': 'ldt', 'url':'http://www.iri.centrepompidou.fr/dev/hg/spel/raw-file/e61d81e7ab8f/virtualenv/res/src/ldt-1.53.4.tar.gz', 'local':'ldt-1.53.4.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
+ 'SIMPLETAL' : {'setup': 'ldt', 'url':'http://www.owlfish.com/software/simpleTAL/downloads/SimpleTAL-4.3.tar.gz', 'local':'SimpleTAL-4.3.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
+ 'RDFLIB' : {'setup': 'rdflib', 'url':'https://github.com/RDFLib/rdflib/archive/master.zip', 'local':'rdflib-master.zip', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
+ 'ISODATE' : {'setup': 'isodate', 'url':'https://github.com/gweis/isodate/archive/master.zip', 'local':'isodate-master.zip', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
+ 'LIBADVENE' : {'setup': 'libadvene', 'url':'https://github.com/oaubert/advene2/archive/9ac68177a0e1ee8a38471d60f983aa234799a6ed.zip', 'local':'advene2-9ac68177a0e1ee8a38471d60f983aa234799a6ed.zip', 'install' : {'method':'install_libadvene', 'option_str': None, 'dict_extra_env': None}},
}
if system_str == 'Windows':
@@ -142,7 +146,17 @@
psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0])
shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'psycopg2')))
- shutil.copy(os.path.join(psycopg2_src_path, 'psycopg2-2.4.5-py2.7.egg-info'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'site-packages')))
+ shutil.copy(os.path.join(psycopg2_src_path, 'psycopg2-2.4.5-py2.7.egg-info'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'site-packages')))
+
+def install_libadvene(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop):
+ # extract advene2
+ zf = zipfile.ZipFile(res_env.URLS['LIBADVENE'][res_source_key])
+ libadvene_base_path = os.path.join(src_dir,"advene2")
+ zf.extractall(libadvene_base_path)
+ zf.close()
+
+ libadvene_src_path = os.path.join(libadvene_base_path, "advene2-9ac68177a0e1ee8a38471d60f983aa234799a6ed", "libadvene")
+ shutil.copytree(os.path.join(libadvene_src_path), os.path.abspath(os.path.join(lib_dir, 'site-packages', 'libadvene')))
def install_mysql(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop):
Binary file virtualenv/res/src/SimpleTAL-4.3.tar.gz has changed
Binary file virtualenv/res/src/advene2-9ac68177a0e1ee8a38471d60f983aa234799a6ed.zip has changed
Binary file virtualenv/res/src/isodate-master.zip has changed
Binary file virtualenv/res/src/rdflib-master.zip has changed
--- a/virtualenv/web/res/res_create_env.py Wed Sep 10 16:41:33 2014 +0200
+++ b/virtualenv/web/res/res_create_env.py Wed Oct 01 13:14:23 2014 +0200
@@ -39,6 +39,10 @@
'DJANGO-TASTYPIE',
'DJANGO-CHUNCKED-UPLOADS',
'LDT',
+ 'SIMPLETAL',
+ 'RDFLIB',
+ 'ISODATE',
+ 'LIBADVENE'
]
if system_str == "Linux":