summaryrefslogtreecommitdiff
path: root/04-CustomLibrary/FileLibrary
diff options
context:
space:
mode:
Diffstat (limited to '04-CustomLibrary/FileLibrary')
-rw-r--r--04-CustomLibrary/FileLibrary/__init__.py7
-rw-r--r--04-CustomLibrary/FileLibrary/filetool.py27
2 files changed, 34 insertions, 0 deletions
diff --git a/04-CustomLibrary/FileLibrary/__init__.py b/04-CustomLibrary/FileLibrary/__init__.py
new file mode 100644
index 0000000..29db0ed
--- /dev/null
+++ b/04-CustomLibrary/FileLibrary/__init__.py
@@ -0,0 +1,7 @@
+#coding=utf-8
+from filetool import filetool
+
+version = '1.0'
+
+class FileLibrary(filetool):
+ ROBOT_LIBRARY_SCOPE = 'GLOBAL' \ No newline at end of file
diff --git a/04-CustomLibrary/FileLibrary/filetool.py b/04-CustomLibrary/FileLibrary/filetool.py
new file mode 100644
index 0000000..56eadcf
--- /dev/null
+++ b/04-CustomLibrary/FileLibrary/filetool.py
@@ -0,0 +1,27 @@
+#coding=utf-8
+import sys
+reload(sys)
+sys.setdefaultencoding("utf-8")
+
+""" 变量文件操作 """
+
+class filetool():
+ def __init__(self):
+ pass
+
+ def alter_dict(self, path, k, v):
+ data = ''
+ flag = True
+ key = '${%s}' % (k)
+ add = key + '\t%s' % (v) + '\n'
+ with open(path, 'r+') as f:
+ for line in f.readlines():
+ if(line.find(key + '\t') == 0):
+ line = add
+ flag = False
+ data += line
+ if(flag):
+ data += add
+ print data
+ with open(path, 'w+') as f:
+ f.writelines(data) \ No newline at end of file