3 from __future__
import print_function
10 fw
= open(filename
+ ".new", "w")
11 ew
= open(filename
+ ".en", "w")
12 hw
= open(filename
+ ".stringsh", "w")
13 cw
= open(filename
+ ".stringsc", "w")
17 for line
in fr
.readlines():
18 pos_pstr
= line
.find("PSTR(\"")
21 pos_pstr
= line
.find("MENU(\"")
26 pos_endparenthesis
= line
.find('"', pos_pstr
+ 7)
28 pos_endparenthesis
= line
.find("\")", pos_pstr
)
29 pstr
= line
[pos_pstr
+ 6:pos_endparenthesis
]
31 str_rep
= "STR_" + pstr
.upper()
32 for s
in (" ", ".", "[", "]", "-", "!", "/", ")", "(", "%", "+", ":"):
33 str_rep
= str_rep
.replace(s
, "")
35 if "14" in pstr
or "32" in pstr
or "@" in pstr
or len(str_rep
) <= 5:
39 glob_str
= line
[pos_pstr
+ 5:pos_endparenthesis
+ 1]
40 str_rep
= "STR_MENU" + pstr
.upper()
42 glob_str
= line
[pos_pstr
:pos_endparenthesis
+ 2]
43 str_rep
= "STR_" + pstr
.upper()
44 for s
in (" ", ".", "[", "]", "-", "!", "/", ")", "(", "%", "+", ":"):
45 str_rep
= str_rep
.replace(s
, "")
47 line
= line
.replace(glob_str
, str_rep
)
49 if str_rep
in replacements
.keys():
50 if replacements
[str_rep
] != pstr
:
51 print("!!!!! NON !!!!!")
53 replacements
[str_rep
] = pstr
54 print(glob_str
, "=>", pstr
, str_rep
)
55 ew
.write("#define " + str_rep
[1:] + " " * (17 - len(str_rep
)) + '"%s"\n' % pstr
)
56 hw
.write("extern const PROGMEM char %s[];\n" % str_rep
)
57 cw
.write("const prog_char APM %s[] = %s;\n" % (str_rep
, str_rep
[1:]))
59 pos_pstr
= line
.find("PSTR(\"")