Skip to content

Commit

Permalink
parse attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
bduhbya committed Sep 23, 2024
1 parent d4f55ff commit 7415692
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions scripts/import_mutants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,41 @@ def process_args():


def process_file(filename):
json_data = None
json_data = {}
with open(filename, "r") as f:
for line in f:
print(line)
if BULLET in line:
json_data = parse_name_line(line)
json_data.update(parse_name_line(line))
elif "STR" in line:
json_data.update(parse_attribute_line(line))
print(json_data)


def parse_attribute_line(line):
# STR 0 STA 0 AGL 0 DEX 1 FGT 1 INT 2 AWE 2 PRE 3
attributes = line.split()
attribute_dict = {}
for i in range(0, len(attributes), 2):
key = attributes[i]
value = int(attributes[i + 1])
attribute_dict[key] = value
print(attribute_dict)
return attribute_dict


def parse_name_line(line):
# data = line.split("\u2022")
name_line = {}
data = line.split(BULLET)
name_pl = data[0].split(PL_TAG)
name = name_pl[0].strip()
power_level = name_pl[1].strip()
mr = data[1].strip()
returnDict = {NAME_TAG: name, PL_TAG: power_level, MR_TAG: mr}
print(returnDict)
json_data = json.dumps(returnDict, indent=2)
print(json_data)
return json_data
name_line[NAME_TAG] = name_pl[0].strip()
name_line[PL_TAG] = name_pl[1].strip()
name_line[MR_TAG] = data[1].strip()
print(name_line)
# json_data = json.dumps(returnDict, indent=2)
# print(json_data)
return name_line


def main():
Expand Down

0 comments on commit 7415692

Please sign in to comment.