This repository has been archived on 2020-04-18. You can view files and clone it, but cannot push or open issues or pull requests.
photo/photo/util/properties.py

29 lines
740 B
Python

# -*- coding: UTF-8 -*-
class properties(object):
def __init__(self, filename):
self.filename = filename
self.properties = {}
def get_properties(self):
try:
pro_file = open(self.filename)
for line in pro_file.readlines():
line = line.strip().replace('\n', '')
if line.find('=') > 0:
s = line.split('=')
self.properties[s[0].strip()] = s[1]
else:
self.properties[line] = ''
except Exception as e:
raise e
else:
pro_file.close()
return self.properties
# tmp = properties('../photo.properties').get_properties()
# print(tmp)