-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode Note Generator.py
More file actions
67 lines (63 loc) · 1.7 KB
/
Code Note Generator.py
File metadata and controls
67 lines (63 loc) · 1.7 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import re
with open('Input.txt', 'r') as file_a:
Code_Notes = file_a.readlines()
"""
Separate each line in 3 components, the
addres, the Bitx and the note and save
it in a tuple
"""
lines = [] # List to save each tuple
for line in Code_Notes:
match = re.match(r'^\w+', line)
if match:
Addres = match.group(0)
else:
Addres = ""
rest = line[len(Addres):]
match = re.search(r'Bit\d\s*=', line)
if match:
Bit = match.group(0)
else:
Bit = ""
rest = line[match.end():].lstrip()
rest = rest.rstrip("\n")
Tuple = (Addres, Bit, rest)
lines.append(Tuple)
#--------------------------------
"""
Save each addres in a list to use later
"""
Addreses = []
for element in lines:
if element[0] not in Addreses:
Addreses.append(element[0])
#-------------------------------
"""
Create a string with the format of the
unpublished code notes in RACache for
each different addres
"""
addres = "z"
new_list = []
Line = ""
for element in lines:
if element[0] != addres:
if Line != "":
new_list.append(Line)
addres = element[0]
Line = "\\r\\n"+element[1]+" "+element[2]
else:
Line+= "\\r\\n"+element[1]+" "+element[2]
new_list.append(Line)
#---------------------------------
"""
Write each Code note with the correct
format in another .txt ready to copy
and paste in the [Game ID]-User.txt file
"""
with open('Output.txt', 'w') as file_b:
counter = 0
for addres in Addreses:
file_b.write("N0:"+Addreses[counter]+":\"[Offset] Event Flags\\r\\n"+new_list[counter]+"\"\n")
counter += 1
print("Thanks for using this program")