-
Notifications
You must be signed in to change notification settings - Fork 0
/
reader.py
46 lines (32 loc) · 995 Bytes
/
reader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
from pypactQC.filerecord import InventoryFileRecord
from pypactQC.output.output import Output
class Reader(object):
"""
It can read fispact out file formats
"""
def __init__(self, filename):
self.filename = filename
def __enter__(self):
pass
def __exit__(self, *args):
pass
class InventoryReader(Reader):
"""
It can read fispact out file formats
"""
def __init__(self, filename, ignorenuclides=False):
super().__init__(filename)
self.record = InventoryFileRecord(filename)
self.output = Output(ignorenuclides=ignorenuclides)
def __enter__(self):
self.output.fispact_deserialize(self.record)
return self.output
class JSONReader(InventoryReader):
"""
It can read JSON fispact file formats
"""
def __enter__(self):
with open(self.filename, 'rt') as f:
self.output.json_deserialize(f.read())
return self.output