<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_history(self, exp, rep, tags):
 """ returns the whole history for one experiment and one repetition. tags can be a string or a list of strings. if tags is a string, the history is returned as list of values, if tags is a list of strings or 'all', history is returned as a dictionary of lists of values. """

        params = self.get_params(exp)
           
        if params == None:
            raise SystemExit('experiment %s not found.'%exp)         
        
        # make list of tags, even if it is only one
        if tags != 'all' and not hasattr(tags, '__iter__'):
            tags = [tags] 
        
        results = {}
        logfile = os.path.join(exp, '%i.log'%rep)
        try:
            f = open(logfile)
        except IOError:
            if len(tags) == 1:
                return []
            else:
                return {}

        for line in f:
            dic = json.loads(line)
            for tag in tags:
              if not tag in results:
                results[tag] = []

              if tag in dic:
                results[tag].append(dic[tag])
              else:
                results[tag].append(None)
                            
        f.close()
        if len(results) == 0:
            if len(tags) == 1:
                return []
            else:
                return {}
            # raise ValueError('tag(s) not found: %s'%str(tags))
        if len(tags) == 1:
            return results[results.keys()[0]]
        else:
            return results