web/ldt/ldt_utils/projectserializer.py
changeset 85 3b70d84e661a
parent 49 55f91a1f9df8
child 88 7f2c2d9adf58
equal deleted inserted replaced
84:6c3162d9e632 85:3b70d84e661a
     8 """
     8 """
     9 Serialize a project object to a cinelab compatible array
     9 Serialize a project object to a cinelab compatible array
    10 """
    10 """
    11 class ProjectSerializer:
    11 class ProjectSerializer:
    12     
    12     
    13     def __init__(self, project):
    13     def __init__(self, project, serialize_contents=True):
    14         self.project = project
    14         self.project = project
    15         self.ldt_doc = None
    15         self.ldt_doc = None
    16         self.medias = []
    16         self.medias = []
    17         self.annotations = []
    17         self.annotations = []
    18         self.tags = {}
    18         self.tags = {}
    19         self.annotation_types = []
    19         self.annotation_types = []
    20         self.views = []
    20         self.views = []
    21         self.lists = []
    21         self.lists = []
       
    22         self.serialize_contents = serialize_contents
    22         
    23         
    23     
    24     
    24     def __parse_ensemble(self, ensemble_node, content):
    25     def __parse_ensemble(self, ensemble_node, content):
    25         
    26         
    26         ensemble_id = ensemble_node.attrib[u"id"]
    27         ensemble_id = ensemble_node.attrib[u"id"]
   263              }
   264              }
   264         }
   265         }
   265         
   266         
   266         self.medias.append(new_media)
   267         self.medias.append(new_media)
   267         
   268         
   268         
   269         if self.serialize_contents:        
   269         res = doc.xpath("/iri/body/ensembles/ensemble")
   270             res = doc.xpath("/iri/body/ensembles/ensemble")
   270         
   271             for ensemble_node in res:
   271         for ensemble_node in res:
   272                 self.__parse_ensemble(ensemble_node, content)
   272             self.__parse_ensemble(ensemble_node, content)
       
   273 
   273 
   274     
   274     
   275     def serialize_to_cinelab(self):
   275     def serialize_to_cinelab(self):
   276     
   276     
   277         res = {}
   277         res = {}