add parse_config_file function
diff --git a/tcutils/__init__.py b/tcutils/__init__.py
index e69de29..e0b4cdd 100644
--- a/tcutils/__init__.py
+++ b/tcutils/__init__.py
@@ -0,0 +1,27 @@
+#-*- coding: utf-8
+import fileinput
+import os
+
+
+def parse_config_file(config_file, configs, encoding='utf-8'):
+ if not os.path.exists(config_file):
+ print u"Config file <{0}> not exists".format(config_file)
+ return False
+ if isinstance(config_file, str):
+ config_file = config_file.decode(encoding)
+
+ lineno = 0
+ for line in fileinput.input(config_file):
+ lineno += 1
+ line = line.strip(' ').rstrip('\n').rstrip('\r')
+ line = line.decode(encoding)
+ if not line:
+ continue
+ if line.startswith('#'):
+ # is comment
+ continue
+ cfg = line.partition('=')
+ if not cfg[1]:
+ raise ValueError(u"Config file line %d error" % lineno)
+ configs[cfg[0].strip(' ')] = cfg[2].lstrip(' ')
+ return True