-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdummy_parser.py
More file actions
35 lines (29 loc) · 1.41 KB
/
dummy_parser.py
File metadata and controls
35 lines (29 loc) · 1.41 KB
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
from consensus_decentralization.parsers.default_parser import DefaultParser
class DummyParser(DefaultParser):
"""
Dummy parser that only sorts the raw data. Used when the data are already in the required format.
"""
def __init__(self, project_name, input_dir):
super().__init__(project_name, input_dir)
@staticmethod
def parse_identifiers(block_identifiers):
"""
Overrides the parse_identifiers method of the DefaultParser class. Does nothing (returns the input as is).
:param block_identifiers: the content of the "identifiers" field of a block (string)
:returns: the content of the "identifiers" field of a block (string)
"""
return block_identifiers
def parse(self):
"""
Sorts the data, makes sure that each entry includes all required fields and writes the results into a file in a
directory associated with the parser instance (specifically in <general output directory>/<project_name>)
"""
data = self.read_and_sort_data()
for block in data:
if 'identifiers' not in block.keys():
block['identifiers'] = None
else:
block['identifiers'] = self.parse_identifiers(block['identifiers'])
if 'reward_addresses' not in block.keys():
block['reward_addresses'] = None
yield block