|
1
|
|
|
from niprov.dependencies import Dependencies |
|
2
|
|
|
from niprov.basefile import BaseFile |
|
3
|
|
|
from niprov.pipeline import Pipeline |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class Format(object): |
|
7
|
|
|
"""Parent Format class from which specific formats are derived. |
|
8
|
|
|
""" |
|
9
|
|
|
|
|
10
|
|
|
def __init__(self, dependencies=Dependencies()): |
|
11
|
|
|
self.fileExtension = 'txt' |
|
12
|
|
|
|
|
13
|
|
|
def serialize(self, provenance): |
|
14
|
|
|
"""Publish provenance. |
|
15
|
|
|
|
|
16
|
|
|
This determines if the provenance is for a single file or multiple, |
|
17
|
|
|
and then calls the appropriate more specific serialize method. |
|
18
|
|
|
""" |
|
19
|
|
|
if isinstance(provenance, Pipeline): |
|
20
|
|
|
return self.serializePipeline(provenance) |
|
21
|
|
|
elif isinstance(provenance, list): |
|
22
|
|
|
return self.serializeList(provenance) |
|
23
|
|
|
elif isinstance(provenance, dict): |
|
24
|
|
|
return self.serializeStatistics(provenance) |
|
25
|
|
|
else: |
|
26
|
|
|
return self.serializeSingle(provenance) |
|
27
|
|
|
|
|
28
|
|
|
def serializeList(self, provenance): |
|
29
|
|
|
raise NotImplementedError('serializeList') |
|
30
|
|
|
|
|
31
|
|
|
def serializeSingle(self, provenance): |
|
32
|
|
|
raise NotImplementedError('serializeSingle') |
|
33
|
|
|
|
|
34
|
|
|
def serializeStatistics(self, provenance): |
|
35
|
|
|
raise NotImplementedError('serializeStatistics') |
|
36
|
|
|
|
|
37
|
|
|
def serializePipeline(self, pipeline): |
|
38
|
|
|
raise NotImplementedError('serializePipeline') |
|
39
|
|
|
|