-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_config.py
More file actions
46 lines (34 loc) · 1.1 KB
/
format_config.py
File metadata and controls
46 lines (34 loc) · 1.1 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
36
37
38
39
40
41
42
43
44
45
46
from ruamel.yaml import YAML
import os
def get_share_length(path):
content = get_share_data(path)
if content is None:
return 0
print("Format", content)
p_total_length = 0
for p in content:
p_total_length += p["length"]
return p_total_length
def get_share_data(path):
if not os.path.exists(path):
print("File does not exist", path)
return None
yaml = YAML()
with open(path, 'r') as file:
content = yaml.load(file)
return content
def get_total_share_length(format_dir, player_count):
player_input_list = []
for i in range(player_count):
filename = 'Input-Binary-P%d-0-format' % i
path = os.path.join(format_dir, filename)
data = get_share_data(path)
player_input_list.append(data)
filename = "Output-format"
path = os.path.join(format_dir, filename)
output_data = get_share_data(path)
total_output_length = 0
if output_data is not None:
for p in output_data:
total_output_length += p["length"]
return player_input_list, output_data, total_output_length