ld.properties
#配置信息
database.type=Argo
database.name=dd
database.ip=10.12.15.225
database.port=10000
database.username=user
database.password=passwd
properties_handler.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
脚本名称:properties_handler.py
脚本功能:解析.properties配置文件
编写人: pangtaishi
编写日期:2021-02-28
'''
import os
import sys
class Properties(object):
def __init__(self, fileName):
self.fileName = fileName
self.properties = {}
def __getDict(self,strName,dictName,value):
if(strName.find('.')>0):
k = strName.split('.')[0]
dictName.setdefault(k,{})
return self.__getDict(strName[len(k)+1:],dictName[k],value)
else:
dictName[strName] = value
return
def getProperties(self):
try:
pro_file = open(self.fileName,