Skip to content

Commit

Permalink
DOCUMENTATION: Added one error handling case to postprocessing code
Browse files Browse the repository at this point in the history
  • Loading branch information
timmahrt committed Oct 29, 2016
1 parent f036f56 commit a6133f9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lmeds/user_scripts/post_process_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
ASPECT_IMAGINE = "imagine"


class EmptyUserDataFile(Exception):

def __init__(self, fn):
super(EmptyUserDataFile, self).__init__()
self.fn = fn

def __str__(self):
errMsg = ("User results file '%s' contains no user data. "
"Remove file and try again.")
return errMsg % self.fn


def extractFromTest(path, keyList, removeItemList=None, onlyKeepList=None):
'''
Extracts all matching keys from a user's results in an LMEDS test
Expand Down Expand Up @@ -96,7 +108,11 @@ def removeDuplicates(path, overwrite=False):
data = fd.read()
dataList = data.splitlines()

outputList = [dataList[0], ]
try:
outputList = [dataList[0], ]
except IndexError:
raise EmptyUserDataFile(fn)

prevString = dataList[0].split(";,")[0].rsplit("]", 1)[0]
for i in range(1, len(dataList)):
curString = dataList[i].split(";,")[0].rsplit("]", 1)[0]
Expand Down

0 comments on commit a6133f9

Please sign in to comment.