-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringsXmlFileUtil.py
More file actions
executable file
·36 lines (26 loc) · 1.02 KB
/
Copy pathStringsXmlFileUtil.py
File metadata and controls
executable file
·36 lines (26 loc) · 1.02 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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
from Log import Log
class StringsXmlFileUtil:
'android strings.xml file util'
@staticmethod
def writeToFile(keys, values,directory,additional):
if not os.path.exists(directory):
os.makedirs(directory)
Log.info("Creating android file:" + directory + "/strings.xml")
fo = open(directory + "/strings.xml", "w", encoding="utf-8")
stringEncoding = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n"
fo.write(stringEncoding)
for x in range(len(keys)):
if values[x] is None or values[x] == '' :
Log.error("Key:" + keys[x] + "\'s value is None. Index:" + str(x + 1))
continue
key = keys[x]
value = values[x]
content = " <string name=\"" + key + "\">" + value + "</string>\n"
fo.write(content);
if additional is not None:
fo.write(additional)
fo.write("</resources>");
fo.close()