tests update + profile.py now can load and save data

This commit is contained in:
ingvar1995 2016-02-18 19:52:12 +03:00
parent 14dd46b716
commit 3481d3385b
2 changed files with 29 additions and 2 deletions

View file

@ -10,14 +10,31 @@ class Profile(object):
result = []
# check default path
for fl in os.listdir(path):
if fl.endswith(".tox"):
if fl.endswith('.tox'):
name = fl[:-4]
result.append((path, name))
path = os.path.dirname(os.path.abspath(__file__))
# check current directory
for fl in os.listdir(path):
if fl.endswith(".tox"):
if fl.endswith('.tox'):
name = fl[:-4]
result.append((path, name))
return result
@staticmethod
def open_profile(path, name):
Profile._path = path + name + '.tox'
with open(Profile._path, 'rb') as fl:
data = fl.read()
if data:
print 'Data loaded from: {}'.format(Profile._path)
return data
else:
raise IOError('Save file not found. Path: {}'.format(Profile._path))
@staticmethod
def save_profile(data):
with open(Profile._path, 'wb') as fl:
fl.write(data)
print 'Data saved to: {}'.format(Profile._path)