Exemplo n.º 1
0
 def testNewBasicSchema(self):
     basic_schema = Schema(self.server)
     expected = {'camliVersion': camlipy.CAMLIVERSION}
     self.assertEqual(basic_schema.json(), json.dumps(expected))
     signed = json.loads(basic_schema.sign())
     self.assertTrue('camliSigner' in signed)
     self.assertTrue('camliSig' in signed)
Exemplo n.º 2
0
 def testNewBasicSchema(self):
     basic_schema = Schema(self.server)
     expected = {'camliVersion': camlipy.CAMLIVERSION}
     self.assertEqual(basic_schema.json(), json.dumps(expected))
     signed = json.loads(basic_schema.sign())
     self.assertTrue('camliSigner' in signed)
     self.assertTrue('camliSig' in signed)
Exemplo n.º 3
0
 def _load_spans(self, blob_ref):
     spans = []
     parts = Schema(self.con, blob_ref).data['parts']
     for index, part in enumerate(parts):
         if 'bytesRef' in part:
             # The associated blobRef => the span
             blob_ref = parts[index + 1]
             parts.remove(blob_ref)
             # If a the blob ref is followed by a bytesRef,
             # it represents the same Span
             children = self._load_spans(part['bytesRef'])
             spans.append(Span(br=blob_ref['blobRef'], children=children))
         elif 'blobRef' in part:
             # If the blobRef is alone, just append it
             spans.append(Span(br=part['blobRef'], size=part['size']))
         else:
             raise Exception('Part lost: {0}'.format(part))
     return spans
Exemplo n.º 4
0
 def _load_spans(self, blob_ref):
     spans = []
     parts = Schema(self.con, blob_ref).data['parts']
     for index, part in enumerate(parts):
         if 'bytesRef' in part:
             # The associated blobRef => the span
             blob_ref = parts[index + 1]
             parts.remove(blob_ref)
             # If a the blob ref is followed by a bytesRef,
             # it represents the same Span
             children = self._load_spans(part['bytesRef'])
             spans.append(Span(br=blob_ref['blobRef'],
                               children=children))
         elif 'blobRef' in part:
             # If the blobRef is alone, just append it
             spans.append(Span(br=part['blobRef'], size=part['size']))
         else:
             raise Exception('Part lost: {0}'.format(part))
     return spans
Exemplo n.º 5
0
 def build(self, fileobj=None):
     if fileobj is None:
         fileobj = tempfile.TemporaryFile()
     for br in self.spans_to_br():
         blob = self.con.get_blob(br)
         fileobj.write(blob.read())
     fileobj.seek(0)
     if hasattr(fileobj, 'name'):
         apply_stat_info(fileobj.name, Schema(self.con, self.blob_ref).data)
     return fileobj